summaryrefslogtreecommitdiff
path: root/library
authorllornkcor <llornkcor>2004-04-25 13:05:00 (UTC)
committer llornkcor <llornkcor>2004-04-25 13:05:00 (UTC)
commit4e4586dc20a0a8befe808d7c89ee2fb3222c63b6 (patch) (unidiff)
tree3d67622f58160d0df8e69f75129be1ef6cdb9d03 /library
parent6182b509bdb16dd4d1e95b9a570219ef6c15ed21 (diff)
downloadopie-4e4586dc20a0a8befe808d7c89ee2fb3222c63b6.zip
opie-4e4586dc20a0a8befe808d7c89ee2fb3222c63b6.tar.gz
opie-4e4586dc20a0a8befe808d7c89ee2fb3222c63b6.tar.bz2
escape close
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index d0e9613..040b2fe 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -871,518 +871,520 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
871 argv[ a ] = argv[ a + 1 ]; 871 argv[ a ] = argv[ a + 1 ];
872 a++; 872 a++;
873 d->preloaded = TRUE; 873 d->preloaded = TRUE;
874 d->forceshow = TRUE; 874 d->forceshow = TRUE;
875 argc -= 1; 875 argc -= 1;
876 } 876 }
877 } 877 }
878 878
879 /* overide stored arguments */ 879 /* overide stored arguments */
880 setArgs( argc, argv ); 880 setArgs( argc, argv );
881 881
882#endif 882#endif
883#else 883#else
884 initApp( argc, argv ); 884 initApp( argc, argv );
885#endif 885#endif
886 // qwsSetDecoration( new QPEDecoration() ); 886 // qwsSetDecoration( new QPEDecoration() );
887 887
888#ifndef QT_NO_TRANSLATION 888#ifndef QT_NO_TRANSLATION
889 889
890 d->langs = Global::languageList(); 890 d->langs = Global::languageList();
891 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 891 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
892 QString lang = *it; 892 QString lang = *it;
893 893
894 installTranslation( lang + "/libopie.qm"); 894 installTranslation( lang + "/libopie.qm");
895 installTranslation( lang + "/libqpe.qm" ); 895 installTranslation( lang + "/libqpe.qm" );
896 installTranslation( lang + "/" + d->appName + ".qm" ); 896 installTranslation( lang + "/" + d->appName + ".qm" );
897 897
898 898
899 //###language/font hack; should look it up somewhere 899 //###language/font hack; should look it up somewhere
900#ifdef QWS 900#ifdef QWS
901 901
902 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 902 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
903 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 903 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
904 setFont( fn ); 904 setFont( fn );
905 } 905 }
906#endif 906#endif
907 } 907 }
908#endif 908#endif
909 909
910 applyStyle(); 910 applyStyle();
911 911
912 if ( type() == GuiServer ) { 912 if ( type() == GuiServer ) {
913 setVolume(); 913 setVolume();
914 } 914 }
915 915
916 installEventFilter( this ); 916 installEventFilter( this );
917 917
918 QPEMenuToolFocusManager::initialize(); 918 QPEMenuToolFocusManager::initialize();
919 919
920#ifdef QT_NO_QWS_CURSOR 920#ifdef QT_NO_QWS_CURSOR
921 // if we have no cursor, probably don't want tooltips 921 // if we have no cursor, probably don't want tooltips
922 QToolTip::setEnabled( FALSE ); 922 QToolTip::setEnabled( FALSE );
923#endif 923#endif
924} 924}
925 925
926 926
927#ifdef QTOPIA_INTERNAL_INITAPP 927#ifdef QTOPIA_INTERNAL_INITAPP
928void QPEApplication::initApp( int argc, char **argv ) 928void QPEApplication::initApp( int argc, char **argv )
929{ 929{
930 delete pidChannel; 930 delete pidChannel;
931 d->keep_running = TRUE; 931 d->keep_running = TRUE;
932 d->preloaded = FALSE; 932 d->preloaded = FALSE;
933 d->forceshow = FALSE; 933 d->forceshow = FALSE;
934 934
935 QCString channel = QCString(argv[0]); 935 QCString channel = QCString(argv[0]);
936 936
937 channel.replace(QRegExp(".*/"),""); 937 channel.replace(QRegExp(".*/"),"");
938 d->appName = channel; 938 d->appName = channel;
939 939
940 #if QT_VERSION > 235 940 #if QT_VERSION > 235
941 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 941 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
942 #endif 942 #endif
943 943
944 channel = "QPE/Application/" + channel; 944 channel = "QPE/Application/" + channel;
945 pidChannel = new QCopChannel( channel, this); 945 pidChannel = new QCopChannel( channel, this);
946 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 946 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
947 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 947 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
948 948
949 949
950 950
951 processQCopFile(); 951 processQCopFile();
952 d->keep_running = d->qcopq.isEmpty(); 952 d->keep_running = d->qcopq.isEmpty();
953 953
954 for (int a=0; a<argc; a++) { 954 for (int a=0; a<argc; a++) {
955 if ( qstrcmp(argv[a],"-preload")==0 ) { 955 if ( qstrcmp(argv[a],"-preload")==0 ) {
956 argv[a] = argv[a+1]; 956 argv[a] = argv[a+1];
957 a++; 957 a++;
958 d->preloaded = TRUE; 958 d->preloaded = TRUE;
959 argc-=1; 959 argc-=1;
960 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 960 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
961 argv[a] = argv[a+1]; 961 argv[a] = argv[a+1];
962 a++; 962 a++;
963 d->preloaded = TRUE; 963 d->preloaded = TRUE;
964 d->forceshow = TRUE; 964 d->forceshow = TRUE;
965 argc-=1; 965 argc-=1;
966 } 966 }
967 } 967 }
968 968
969 /* overide stored arguments */ 969 /* overide stored arguments */
970 setArgs(argc, argv); 970 setArgs(argc, argv);
971 971
972 /* install translation here */ 972 /* install translation here */
973 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 973 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
974 installTranslation( (*it) + "/" + d->appName + ".qm" ); 974 installTranslation( (*it) + "/" + d->appName + ".qm" );
975} 975}
976#endif 976#endif
977 977
978 978
979static QPtrDict<void>* inputMethodDict = 0; 979static QPtrDict<void>* inputMethodDict = 0;
980static void createInputMethodDict() 980static void createInputMethodDict()
981{ 981{
982 if ( !inputMethodDict ) 982 if ( !inputMethodDict )
983 inputMethodDict = new QPtrDict<void>; 983 inputMethodDict = new QPtrDict<void>;
984} 984}
985 985
986/*! 986/*!
987 Returns the currently set hint to the system as to whether 987 Returns the currently set hint to the system as to whether
988 widget \a w has any use for text input methods. 988 widget \a w has any use for text input methods.
989 989
990 990
991 \sa setInputMethodHint() InputMethodHint 991 \sa setInputMethodHint() InputMethodHint
992*/ 992*/
993QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 993QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
994{ 994{
995 if ( inputMethodDict && w ) 995 if ( inputMethodDict && w )
996 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 996 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
997 return Normal; 997 return Normal;
998} 998}
999 999
1000/*! 1000/*!
1001 \enum QPEApplication::InputMethodHint 1001 \enum QPEApplication::InputMethodHint
1002 1002
1003 \value Normal the application sometimes needs text input (the default). 1003 \value Normal the application sometimes needs text input (the default).
1004 \value AlwaysOff the application never needs text input. 1004 \value AlwaysOff the application never needs text input.
1005 \value AlwaysOn the application always needs text input. 1005 \value AlwaysOn the application always needs text input.
1006*/ 1006*/
1007 1007
1008/*! 1008/*!
1009 Hints to the system that widget \a w has use for text input methods 1009 Hints to the system that widget \a w has use for text input methods
1010 as specified by \a mode. 1010 as specified by \a mode.
1011 1011
1012 \sa inputMethodHint() InputMethodHint 1012 \sa inputMethodHint() InputMethodHint
1013*/ 1013*/
1014void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1014void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1015{ 1015{
1016 createInputMethodDict(); 1016 createInputMethodDict();
1017 if ( mode == Normal ) { 1017 if ( mode == Normal ) {
1018 inputMethodDict->remove 1018 inputMethodDict->remove
1019 ( w ); 1019 ( w );
1020 } 1020 }
1021 else { 1021 else {
1022 inputMethodDict->insert( w, ( void* ) mode ); 1022 inputMethodDict->insert( w, ( void* ) mode );
1023 } 1023 }
1024} 1024}
1025 1025
1026class HackDialog : public QDialog 1026class HackDialog : public QDialog
1027{ 1027{
1028public: 1028public:
1029 void acceptIt() 1029 void acceptIt()
1030 { 1030 {
1031 accept(); 1031 accept();
1032 } 1032 }
1033 void rejectIt() 1033 void rejectIt()
1034 { 1034 {
1035 reject(); 1035 reject();
1036 } 1036 }
1037}; 1037};
1038 1038
1039 1039
1040void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1040void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1041{ 1041{
1042 // specialised actions for certain widgets. May want to 1042 // specialised actions for certain widgets. May want to
1043 // add more stuff here. 1043 // add more stuff here.
1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1045 && activePopupWidget() ->parentWidget() 1045 && activePopupWidget() ->parentWidget()
1046 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1046 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1047 key = Qt::Key_Return; 1047 key = Qt::Key_Return;
1048 1048
1049 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1049 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1050 key = Qt::Key_Return; 1050 key = Qt::Key_Return;
1051 1051
1052#ifdef QWS 1052#ifdef QWS
1053 1053
1054 ke->simpleData.keycode = key; 1054 ke->simpleData.keycode = key;
1055#endif 1055#endif
1056} 1056}
1057 1057
1058 1058
1059/*! 1059/*!
1060 \internal 1060 \internal
1061*/ 1061*/
1062 1062
1063#ifdef QWS 1063#ifdef QWS
1064bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1064bool QPEApplication::qwsEventFilter( QWSEvent * e )
1065{ 1065{
1066 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1066 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1067 if ( qApp->type() != QApplication::GuiServer ) { 1067 if ( qApp->type() != QApplication::GuiServer ) {
1068 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1068 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1069 e << d->appName; 1069 e << d->appName;
1070 } 1070 }
1071 d->notbusysent = TRUE; 1071 d->notbusysent = TRUE;
1072 } 1072 }
1073 if ( type() == GuiServer ) { 1073 if ( type() == GuiServer ) {
1074 switch ( e->type ) { 1074 switch ( e->type ) {
1075 case QWSEvent::Mouse: 1075 case QWSEvent::Mouse:
1076 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1076 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1077 emit clientMoused(); 1077 emit clientMoused();
1078 break; 1078 break;
1079 default: 1079 default:
1080 break; 1080 break;
1081 } 1081 }
1082 } 1082 }
1083 if ( e->type == QWSEvent::Key ) { 1083 if ( e->type == QWSEvent::Key ) {
1084 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1084 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1085 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1085 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1086 // Use special "OK" key to press "OK" on top level widgets 1086 // Use special "OK" key to press "OK" on top level widgets
1087 QWidget * active = activeWindow(); 1087 QWidget * active = activeWindow();
1088 QWidget *popup = 0; 1088 QWidget *popup = 0;
1089 if ( active && active->isPopup() ) { 1089 if ( active && active->isPopup() ) {
1090 popup = active; 1090 popup = active;
1091 active = active->parentWidget(); 1091 active = active->parentWidget();
1092 } 1092 }
1093 if ( active && ( int ) active->winId() == ke->simpleData.window && 1093 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1094 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1094 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1095 if ( ke->simpleData.is_press ) { 1095 if ( ke->simpleData.is_press ) {
1096 if ( popup ) 1096 if ( popup )
1097 popup->close(); 1097 popup->close();
1098 if ( active->inherits( "QDialog" ) ) { 1098 if ( active->inherits( "QDialog" ) ) {
1099 HackDialog * d = ( HackDialog * ) active; 1099 HackDialog * d = ( HackDialog * ) active;
1100 d->acceptIt(); 1100 d->acceptIt();
1101 return TRUE; 1101 return TRUE;
1102 } 1102 }
1103 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1103 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1104 QSignal s; 1104 QSignal s;
1105 s.connect( active, SLOT( accept() ) ); 1105 s.connect( active, SLOT( accept() ) );
1106 s.activate(); 1106 s.activate();
1107 } 1107 }
1108 else { 1108 else {
1109 // do the same as with the select key: Map to the default action of the widget: 1109 // do the same as with the select key: Map to the default action of the widget:
1110 mapToDefaultAction( ke, Qt::Key_Return ); 1110 mapToDefaultAction( ke, Qt::Key_Return );
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1115 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1116 // Use special "select" key to do whatever default action a widget has 1116 // Use special "select" key to do whatever default action a widget has
1117 mapToDefaultAction( ke, Qt::Key_Space ); 1117 mapToDefaultAction( ke, Qt::Key_Space );
1118 } 1118 }
1119 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1119 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1120 ke->simpleData.is_press ) { 1120 ke->simpleData.is_press ) {
1121 // Escape key closes app if focus on toplevel 1121 // Escape key closes app if focus on toplevel
1122 QWidget * active = activeWindow(); 1122 QWidget * active = activeWindow();
1123 if ( active && active->testWFlags( WType_TopLevel ) && 1123 if ( active && active->testWFlags( WType_TopLevel ) &&
1124 ( int ) active->winId() == ke->simpleData.window && 1124 ( int ) active->winId() == ke->simpleData.window &&
1125 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1125 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1126 if ( active->inherits( "QDialog" ) ) { 1126 if ( active->inherits( "QDialog" ) ) {
1127 qDebug("dialog hack");
1128 HackDialog * d = ( HackDialog * ) active; 1127 HackDialog * d = ( HackDialog * ) active;
1129 d->rejectIt(); 1128 d->rejectIt();
1130 return TRUE; 1129 return TRUE;
1130 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1131 active->close();
1131 } 1132 }
1132 } 1133 }
1134
1133 } 1135 }
1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1136 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1137 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1136 // but we cannot access libopie function within libqpe :( 1138 // but we cannot access libopie function within libqpe :(
1137 1139
1138 QWidget * active = activeWindow ( ); 1140 QWidget * active = activeWindow ( );
1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1141 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1142 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1141 QChar ch ( ke-> simpleData.unicode ); 1143 QChar ch ( ke-> simpleData.unicode );
1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1144 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1143 ke-> simpleData.keycode, 1145 ke-> simpleData.keycode,
1144 ch. latin1 ( ), 1146 ch. latin1 ( ),
1145 ke-> simpleData.modifiers, 1147 ke-> simpleData.modifiers,
1146 QString ( ch ), 1148 QString ( ch ),
1147 ke-> simpleData.is_auto_repeat, 1 ); 1149 ke-> simpleData.is_auto_repeat, 1 );
1148 1150
1149 QObject *which = QWidget::keyboardGrabber ( ); 1151 QObject *which = QWidget::keyboardGrabber ( );
1150 if ( !which ) 1152 if ( !which )
1151 which = QApplication::focusWidget ( ); 1153 which = QApplication::focusWidget ( );
1152 if ( !which ) 1154 if ( !which )
1153 which = QApplication::activeWindow ( ); 1155 which = QApplication::activeWindow ( );
1154 if ( !which ) 1156 if ( !which )
1155 which = qApp; 1157 which = qApp;
1156 1158
1157 QApplication::sendEvent ( which, &qke ); 1159 QApplication::sendEvent ( which, &qke );
1158 } 1160 }
1159 else { // we didn't grab the keyboard, so send the event to the launcher 1161 else { // we didn't grab the keyboard, so send the event to the launcher
1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1162 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1161 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1163 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1162 } 1164 }
1163 } 1165 }
1164 return true; 1166 return true;
1165 } 1167 }
1166 } 1168 }
1167 if ( e->type == QWSEvent::Focus ) { 1169 if ( e->type == QWSEvent::Focus ) {
1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1170 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1169 if ( !fe->simpleData.get_focus ) { 1171 if ( !fe->simpleData.get_focus ) {
1170 QWidget * active = activeWindow(); 1172 QWidget * active = activeWindow();
1171 while ( active && active->isPopup() ) { 1173 while ( active && active->isPopup() ) {
1172 active->close(); 1174 active->close();
1173 active = activeWindow(); 1175 active = activeWindow();
1174 } 1176 }
1175 } 1177 }
1176 else { 1178 else {
1177 // make sure our modal widget is ALWAYS on top 1179 // make sure our modal widget is ALWAYS on top
1178 QWidget *topm = activeModalWidget(); 1180 QWidget *topm = activeModalWidget();
1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1181 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1180 topm->raise(); 1182 topm->raise();
1181 } 1183 }
1182 } 1184 }
1183 if ( fe->simpleData.get_focus && inputMethodDict ) { 1185 if ( fe->simpleData.get_focus && inputMethodDict ) {
1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1186 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1185 if ( m == AlwaysOff ) 1187 if ( m == AlwaysOff )
1186 Global::hideInputMethod(); 1188 Global::hideInputMethod();
1187 if ( m == AlwaysOn ) 1189 if ( m == AlwaysOn )
1188 Global::showInputMethod(); 1190 Global::showInputMethod();
1189 } 1191 }
1190 } 1192 }
1191 1193
1192 1194
1193 return QApplication::qwsEventFilter( e ); 1195 return QApplication::qwsEventFilter( e );
1194} 1196}
1195#endif 1197#endif
1196 1198
1197/*! 1199/*!
1198 Destroys the QPEApplication. 1200 Destroys the QPEApplication.
1199*/ 1201*/
1200QPEApplication::~QPEApplication() 1202QPEApplication::~QPEApplication()
1201{ 1203{
1202 ungrabKeyboard(); 1204 ungrabKeyboard();
1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1205#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1204 // Need to delete QCopChannels early, since the display will 1206 // Need to delete QCopChannels early, since the display will
1205 // be gone by the time we get to ~QObject(). 1207 // be gone by the time we get to ~QObject().
1206 delete sysChannel; 1208 delete sysChannel;
1207 delete pidChannel; 1209 delete pidChannel;
1208#endif 1210#endif
1209 1211
1210 delete d; 1212 delete d;
1211} 1213}
1212 1214
1213/*! 1215/*!
1214 Returns <tt>$OPIEDIR/</tt>. 1216 Returns <tt>$OPIEDIR/</tt>.
1215*/ 1217*/
1216QString QPEApplication::qpeDir() 1218QString QPEApplication::qpeDir()
1217{ 1219{
1218 const char * base = getenv( "OPIEDIR" ); 1220 const char * base = getenv( "OPIEDIR" );
1219 if ( base ) 1221 if ( base )
1220 return QString( base ) + "/"; 1222 return QString( base ) + "/";
1221 1223
1222 return QString( "../" ); 1224 return QString( "../" );
1223} 1225}
1224 1226
1225/*! 1227/*!
1226 Returns the user's current Document directory. There is a trailing "/". 1228 Returns the user's current Document directory. There is a trailing "/".
1227 .. well, it does now,, and there's no trailing '/' 1229 .. well, it does now,, and there's no trailing '/'
1228*/ 1230*/
1229QString QPEApplication::documentDir() 1231QString QPEApplication::documentDir()
1230{ 1232{
1231 const char* base = getenv( "HOME"); 1233 const char* base = getenv( "HOME");
1232 if ( base ) 1234 if ( base )
1233 return QString( base ) + "/Documents"; 1235 return QString( base ) + "/Documents";
1234 1236
1235 return QString( "../Documents" ); 1237 return QString( "../Documents" );
1236} 1238}
1237 1239
1238static int deforient = -1; 1240static int deforient = -1;
1239 1241
1240/*! 1242/*!
1241 \internal 1243 \internal
1242*/ 1244*/
1243int QPEApplication::defaultRotation() 1245int QPEApplication::defaultRotation()
1244{ 1246{
1245 if ( deforient < 0 ) { 1247 if ( deforient < 0 ) {
1246 QString d = getenv( "QWS_DISPLAY" ); 1248 QString d = getenv( "QWS_DISPLAY" );
1247 if ( d.contains( "Rot90" ) ) { 1249 if ( d.contains( "Rot90" ) ) {
1248 deforient = 90; 1250 deforient = 90;
1249 } 1251 }
1250 else if ( d.contains( "Rot180" ) ) { 1252 else if ( d.contains( "Rot180" ) ) {
1251 deforient = 180; 1253 deforient = 180;
1252 } 1254 }
1253 else if ( d.contains( "Rot270" ) ) { 1255 else if ( d.contains( "Rot270" ) ) {
1254 deforient = 270; 1256 deforient = 270;
1255 } 1257 }
1256 else { 1258 else {
1257 deforient = 0; 1259 deforient = 0;
1258 } 1260 }
1259 } 1261 }
1260 return deforient; 1262 return deforient;
1261} 1263}
1262 1264
1263/*! 1265/*!
1264 \internal 1266 \internal
1265*/ 1267*/
1266void QPEApplication::setDefaultRotation( int r ) 1268void QPEApplication::setDefaultRotation( int r )
1267{ 1269{
1268 if ( qApp->type() == GuiServer ) { 1270 if ( qApp->type() == GuiServer ) {
1269 deforient = r; 1271 deforient = r;
1270 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1272 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1271 Config config("qpe"); 1273 Config config("qpe");
1272 config.setGroup( "Rotation" ); 1274 config.setGroup( "Rotation" );
1273 config.writeEntry( "Rot", r ); 1275 config.writeEntry( "Rot", r );
1274 } 1276 }
1275 else { 1277 else {
1276#ifndef QT_NO_COP 1278#ifndef QT_NO_COP
1277 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1279 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1278 e << r; 1280 e << r;
1279 } 1281 }
1280#endif 1282#endif
1281 1283
1282 } 1284 }
1283} 1285}
1284 1286
1285#include <qgfx_qws.h> 1287#include <qgfx_qws.h>
1286#include <qwindowsystem_qws.h> 1288#include <qwindowsystem_qws.h>
1287 1289
1288extern void qws_clearLoadedFonts(); 1290extern void qws_clearLoadedFonts();
1289 1291
1290void QPEApplication::setCurrentMode( int x, int y, int depth ) 1292void QPEApplication::setCurrentMode( int x, int y, int depth )
1291{ 1293{
1292 // Reset the caches 1294 // Reset the caches
1293 qws_clearLoadedFonts(); 1295 qws_clearLoadedFonts();
1294 QPixmapCache::clear(); 1296 QPixmapCache::clear();
1295 1297
1296 // Change the screen mode 1298 // Change the screen mode
1297 qt_screen->setMode(x, y, depth); 1299 qt_screen->setMode(x, y, depth);
1298 1300
1299 if ( qApp->type() == GuiServer ) { 1301 if ( qApp->type() == GuiServer ) {
1300 // Reconfigure the GuiServer 1302 // Reconfigure the GuiServer
1301 qwsServer->beginDisplayReconfigure(); 1303 qwsServer->beginDisplayReconfigure();
1302 qwsServer->endDisplayReconfigure(); 1304 qwsServer->endDisplayReconfigure();
1303 1305
1304 // Get all the running apps to reset 1306 // Get all the running apps to reset
1305 QCopEnvelope env( "QPE/System", "reset()" ); 1307 QCopEnvelope env( "QPE/System", "reset()" );
1306 } 1308 }
1307} 1309}
1308 1310
1309void QPEApplication::reset() { 1311void QPEApplication::reset() {
1310 // Reconnect to the screen 1312 // Reconnect to the screen
1311 qt_screen->disconnect(); 1313 qt_screen->disconnect();
1312 qt_screen->connect( QString::null ); 1314 qt_screen->connect( QString::null );
1313 1315
1314 // Redraw everything 1316 // Redraw everything
1315 applyStyle(); 1317 applyStyle();
1316} 1318}
1317 1319
1318/*! 1320/*!
1319 \internal 1321 \internal
1320*/ 1322*/
1321void QPEApplication::applyStyle() 1323void QPEApplication::applyStyle()
1322{ 1324{
1323 Config config( "qpe" ); 1325 Config config( "qpe" );
1324 config.setGroup( "Appearance" ); 1326 config.setGroup( "Appearance" );
1325 1327
1326#if QT_VERSION > 233 1328#if QT_VERSION > 233
1327#if !defined(OPIE_NO_OVERRIDE_QT) 1329#if !defined(OPIE_NO_OVERRIDE_QT)
1328 // don't block ourselves ... 1330 // don't block ourselves ...
1329 Opie::force_appearance = 0; 1331 Opie::force_appearance = 0;
1330 1332
1331 static QString appname = Opie::binaryName ( ); 1333 static QString appname = Opie::binaryName ( );
1332 1334
1333 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1335 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1334 int nostyle = 0; 1336 int nostyle = 0;
1335 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1337 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1336 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1338 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1337 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1339 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1338 break; 1340 break;
1339 } 1341 }
1340 } 1342 }
1341#else 1343#else
1342 int nostyle = 0; 1344 int nostyle = 0;
1343#endif 1345#endif
1344 1346
1345 // Widget style 1347 // Widget style
1346 QString style = config.readEntry( "Style", "FlatStyle" ); 1348 QString style = config.readEntry( "Style", "FlatStyle" );
1347 1349
1348 // don't set a custom style 1350 // don't set a custom style
1349 if ( nostyle & Opie::Force_Style ) 1351 if ( nostyle & Opie::Force_Style )
1350 style = "FlatStyle"; 1352 style = "FlatStyle";
1351 1353
1352 internalSetStyle ( style ); 1354 internalSetStyle ( style );
1353 1355
1354 // Colors - from /etc/colors/Liquid.scheme 1356 // Colors - from /etc/colors/Liquid.scheme
1355 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1357 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1356 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1358 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1357 QPalette pal( btncolor, bgcolor ); 1359 QPalette pal( btncolor, bgcolor );
1358 QString color = config.readEntry( "Highlight", "#73adef" ); 1360 QString color = config.readEntry( "Highlight", "#73adef" );
1359 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1361 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1360 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1362 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1361 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1363 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1362 color = config.readEntry( "Text", "#000000" ); 1364 color = config.readEntry( "Text", "#000000" );
1363 pal.setColor( QColorGroup::Text, QColor( color ) ); 1365 pal.setColor( QColorGroup::Text, QColor( color ) );
1364 color = config.readEntry( "ButtonText", "#000000" ); 1366 color = config.readEntry( "ButtonText", "#000000" );
1365 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1367 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1366 color = config.readEntry( "Base", "#FFFFFF" ); 1368 color = config.readEntry( "Base", "#FFFFFF" );
1367 pal.setColor( QColorGroup::Base, QColor( color ) ); 1369 pal.setColor( QColorGroup::Base, QColor( color ) );
1368 1370
1369 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1371 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1370 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1372 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1371 1373
1372 setPalette( pal, TRUE ); 1374 setPalette( pal, TRUE );
1373 1375
1374 // Window Decoration 1376 // Window Decoration
1375 QString dec = config.readEntry( "Decoration", "Flat" ); 1377 QString dec = config.readEntry( "Decoration", "Flat" );
1376 1378
1377 // don't set a custom deco 1379 // don't set a custom deco
1378 if ( nostyle & Opie::Force_Decoration ) 1380 if ( nostyle & Opie::Force_Decoration )
1379 dec = ""; 1381 dec = "";
1380 1382
1381 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1383 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1382 1384
1383 if ( dec != d->decorationName ) { 1385 if ( dec != d->decorationName ) {
1384 qwsSetDecoration( new QPEDecoration( dec ) ); 1386 qwsSetDecoration( new QPEDecoration( dec ) );
1385 d->decorationName = dec; 1387 d->decorationName = dec;
1386 } 1388 }
1387 1389
1388 // Font 1390 // Font