-rw-r--r-- | library/qpeapplication.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 040b2fe..26e310a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -936,832 +936,838 @@ void QPEApplication::initApp( int argc, char **argv ) | |||
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 | ||
979 | static QPtrDict<void>* inputMethodDict = 0; | 979 | static QPtrDict<void>* inputMethodDict = 0; |
980 | static void createInputMethodDict() | 980 | static 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 | */ |
993 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 993 | QPEApplication::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 | */ |
1014 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1014 | void 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 | ||
1026 | class HackDialog : public QDialog | 1026 | class HackDialog : public QDialog |
1027 | { | 1027 | { |
1028 | public: | 1028 | public: |
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 | ||
1040 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1040 | void 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 |
1064 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1064 | bool 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 | HackDialog * d = ( HackDialog * ) active; | 1127 | HackDialog * d = ( HackDialog * ) active; |
1128 | d->rejectIt(); | 1128 | d->rejectIt(); |
1129 | return TRUE; | 1129 | return TRUE; |
1130 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1130 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1131 | active->close(); | 1131 | active->close(); |
1132 | } | 1132 | } |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | } | 1135 | } |
1136 | 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 ) { |
1137 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1137 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1138 | // but we cannot access libopie function within libqpe :( | 1138 | // but we cannot access libopie function within libqpe :( |
1139 | 1139 | ||
1140 | QWidget * active = activeWindow ( ); | 1140 | QWidget * active = activeWindow ( ); |
1141 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1141 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1142 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1142 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1143 | QChar ch ( ke-> simpleData.unicode ); | 1143 | QChar ch ( ke-> simpleData.unicode ); |
1144 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1144 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1145 | ke-> simpleData.keycode, | 1145 | ke-> simpleData.keycode, |
1146 | ch. latin1 ( ), | 1146 | ch. latin1 ( ), |
1147 | ke-> simpleData.modifiers, | 1147 | ke-> simpleData.modifiers, |
1148 | QString ( ch ), | 1148 | QString ( ch ), |
1149 | ke-> simpleData.is_auto_repeat, 1 ); | 1149 | ke-> simpleData.is_auto_repeat, 1 ); |
1150 | 1150 | ||
1151 | QObject *which = QWidget::keyboardGrabber ( ); | 1151 | QObject *which = QWidget::keyboardGrabber ( ); |
1152 | if ( !which ) | 1152 | if ( !which ) |
1153 | which = QApplication::focusWidget ( ); | 1153 | which = QApplication::focusWidget ( ); |
1154 | if ( !which ) | 1154 | if ( !which ) |
1155 | which = QApplication::activeWindow ( ); | 1155 | which = QApplication::activeWindow ( ); |
1156 | if ( !which ) | 1156 | if ( !which ) |
1157 | which = qApp; | 1157 | which = qApp; |
1158 | 1158 | ||
1159 | QApplication::sendEvent ( which, &qke ); | 1159 | QApplication::sendEvent ( which, &qke ); |
1160 | } | 1160 | } |
1161 | 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 |
1162 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1162 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1163 | 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 ); |
1164 | } | 1164 | } |
1165 | } | 1165 | } |
1166 | return true; | 1166 | return true; |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | if ( e->type == QWSEvent::Focus ) { | 1169 | if ( e->type == QWSEvent::Focus ) { |
1170 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1170 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1171 | if ( !fe->simpleData.get_focus ) { | 1171 | if ( !fe->simpleData.get_focus ) { |
1172 | QWidget * active = activeWindow(); | 1172 | QWidget * active = activeWindow(); |
1173 | while ( active && active->isPopup() ) { | 1173 | while ( active && active->isPopup() ) { |
1174 | active->close(); | 1174 | active->close(); |
1175 | active = activeWindow(); | 1175 | active = activeWindow(); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | else { | 1178 | else { |
1179 | // make sure our modal widget is ALWAYS on top | 1179 | // make sure our modal widget is ALWAYS on top |
1180 | QWidget *topm = activeModalWidget(); | 1180 | QWidget *topm = activeModalWidget(); |
1181 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1181 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1182 | topm->raise(); | 1182 | topm->raise(); |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1185 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1186 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1186 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1187 | if ( m == AlwaysOff ) | 1187 | if ( m == AlwaysOff ) |
1188 | Global::hideInputMethod(); | 1188 | Global::hideInputMethod(); |
1189 | if ( m == AlwaysOn ) | 1189 | if ( m == AlwaysOn ) |
1190 | Global::showInputMethod(); | 1190 | Global::showInputMethod(); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | return QApplication::qwsEventFilter( e ); | 1195 | return QApplication::qwsEventFilter( e ); |
1196 | } | 1196 | } |
1197 | #endif | 1197 | #endif |
1198 | 1198 | ||
1199 | /*! | 1199 | /*! |
1200 | Destroys the QPEApplication. | 1200 | Destroys the QPEApplication. |
1201 | */ | 1201 | */ |
1202 | QPEApplication::~QPEApplication() | 1202 | QPEApplication::~QPEApplication() |
1203 | { | 1203 | { |
1204 | ungrabKeyboard(); | 1204 | ungrabKeyboard(); |
1205 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1205 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1206 | // Need to delete QCopChannels early, since the display will | 1206 | // Need to delete QCopChannels early, since the display will |
1207 | // be gone by the time we get to ~QObject(). | 1207 | // be gone by the time we get to ~QObject(). |
1208 | delete sysChannel; | 1208 | delete sysChannel; |
1209 | delete pidChannel; | 1209 | delete pidChannel; |
1210 | #endif | 1210 | #endif |
1211 | 1211 | ||
1212 | delete d; | 1212 | delete d; |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | /*! | 1215 | /*! |
1216 | Returns <tt>$OPIEDIR/</tt>. | 1216 | Returns <tt>$OPIEDIR/</tt>. |
1217 | */ | 1217 | */ |
1218 | QString QPEApplication::qpeDir() | 1218 | QString QPEApplication::qpeDir() |
1219 | { | 1219 | { |
1220 | const char * base = getenv( "OPIEDIR" ); | 1220 | const char * base = getenv( "OPIEDIR" ); |
1221 | if ( base ) | 1221 | if ( base ) |
1222 | return QString( base ) + "/"; | 1222 | return QString( base ) + "/"; |
1223 | 1223 | ||
1224 | return QString( "../" ); | 1224 | return QString( "../" ); |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | /*! | 1227 | /*! |
1228 | Returns the user's current Document directory. There is a trailing "/". | 1228 | Returns the user's current Document directory. There is a trailing "/". |
1229 | .. well, it does now,, and there's no trailing '/' | 1229 | .. well, it does now,, and there's no trailing '/' |
1230 | */ | 1230 | */ |
1231 | QString QPEApplication::documentDir() | 1231 | QString QPEApplication::documentDir() |
1232 | { | 1232 | { |
1233 | const char* base = getenv( "HOME"); | 1233 | const char* base = getenv( "HOME"); |
1234 | if ( base ) | 1234 | if ( base ) |
1235 | return QString( base ) + "/Documents"; | 1235 | return QString( base ) + "/Documents"; |
1236 | 1236 | ||
1237 | return QString( "../Documents" ); | 1237 | return QString( "../Documents" ); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | static int deforient = -1; | 1240 | static int deforient = -1; |
1241 | 1241 | ||
1242 | /*! | 1242 | /*! |
1243 | \internal | 1243 | \internal |
1244 | */ | 1244 | */ |
1245 | int QPEApplication::defaultRotation() | 1245 | int QPEApplication::defaultRotation() |
1246 | { | 1246 | { |
1247 | if ( deforient < 0 ) { | 1247 | if ( deforient < 0 ) { |
1248 | QString d = getenv( "QWS_DISPLAY" ); | 1248 | QString d = getenv( "QWS_DISPLAY" ); |
1249 | if ( d.contains( "Rot90" ) ) { | 1249 | if ( d.contains( "Rot90" ) ) { |
1250 | deforient = 90; | 1250 | deforient = 90; |
1251 | } | 1251 | } |
1252 | else if ( d.contains( "Rot180" ) ) { | 1252 | else if ( d.contains( "Rot180" ) ) { |
1253 | deforient = 180; | 1253 | deforient = 180; |
1254 | } | 1254 | } |
1255 | else if ( d.contains( "Rot270" ) ) { | 1255 | else if ( d.contains( "Rot270" ) ) { |
1256 | deforient = 270; | 1256 | deforient = 270; |
1257 | } | 1257 | } |
1258 | else { | 1258 | else { |
1259 | deforient = 0; | 1259 | deforient = 0; |
1260 | } | 1260 | } |
1261 | } | 1261 | } |
1262 | return deforient; | 1262 | return deforient; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | /*! | 1265 | /*! |
1266 | \internal | 1266 | \internal |
1267 | */ | 1267 | */ |
1268 | void QPEApplication::setDefaultRotation( int r ) | 1268 | void QPEApplication::setDefaultRotation( int r ) |
1269 | { | 1269 | { |
1270 | if ( qApp->type() == GuiServer ) { | 1270 | if ( qApp->type() == GuiServer ) { |
1271 | deforient = r; | 1271 | deforient = r; |
1272 | 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 ); |
1273 | Config config("qpe"); | 1273 | Config config("qpe"); |
1274 | config.setGroup( "Rotation" ); | 1274 | config.setGroup( "Rotation" ); |
1275 | config.writeEntry( "Rot", r ); | 1275 | config.writeEntry( "Rot", r ); |
1276 | } | 1276 | } |
1277 | else { | 1277 | else { |
1278 | #ifndef QT_NO_COP | 1278 | #ifndef QT_NO_COP |
1279 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1279 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1280 | e << r; | 1280 | e << r; |
1281 | } | 1281 | } |
1282 | #endif | 1282 | #endif |
1283 | 1283 | ||
1284 | } | 1284 | } |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | #include <qgfx_qws.h> | 1287 | #include <qgfx_qws.h> |
1288 | #include <qwindowsystem_qws.h> | 1288 | #include <qwindowsystem_qws.h> |
1289 | 1289 | ||
1290 | extern void qws_clearLoadedFonts(); | 1290 | extern void qws_clearLoadedFonts(); |
1291 | 1291 | ||
1292 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1292 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1293 | { | 1293 | { |
1294 | // Reset the caches | 1294 | // Reset the caches |
1295 | qws_clearLoadedFonts(); | 1295 | qws_clearLoadedFonts(); |
1296 | QPixmapCache::clear(); | 1296 | QPixmapCache::clear(); |
1297 | 1297 | ||
1298 | // Change the screen mode | 1298 | // Change the screen mode |
1299 | qt_screen->setMode(x, y, depth); | 1299 | qt_screen->setMode(x, y, depth); |
1300 | 1300 | ||
1301 | if ( qApp->type() == GuiServer ) { | 1301 | if ( qApp->type() == GuiServer ) { |
1302 | // Reconfigure the GuiServer | 1302 | // Reconfigure the GuiServer |
1303 | qwsServer->beginDisplayReconfigure(); | 1303 | qwsServer->beginDisplayReconfigure(); |
1304 | qwsServer->endDisplayReconfigure(); | 1304 | qwsServer->endDisplayReconfigure(); |
1305 | 1305 | ||
1306 | // Get all the running apps to reset | 1306 | // Get all the running apps to reset |
1307 | QCopEnvelope env( "QPE/System", "reset()" ); | 1307 | QCopEnvelope env( "QPE/System", "reset()" ); |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | void QPEApplication::reset() { | 1311 | void QPEApplication::reset() { |
1312 | // Reconnect to the screen | 1312 | // Reconnect to the screen |
1313 | qt_screen->disconnect(); | 1313 | qt_screen->disconnect(); |
1314 | qt_screen->connect( QString::null ); | 1314 | qt_screen->connect( QString::null ); |
1315 | 1315 | ||
1316 | // Redraw everything | 1316 | // Redraw everything |
1317 | applyStyle(); | 1317 | applyStyle(); |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | |||
1321 | extern bool qt_left_hand_scrollbars __attribute__(( weak )); | ||
1320 | /*! | 1322 | /*! |
1321 | \internal | 1323 | \internal |
1322 | */ | 1324 | */ |
1323 | void QPEApplication::applyStyle() | 1325 | void QPEApplication::applyStyle() |
1324 | { | 1326 | { |
1325 | Config config( "qpe" ); | 1327 | Config config( "qpe" ); |
1326 | config.setGroup( "Appearance" ); | 1328 | config.setGroup( "Appearance" ); |
1327 | 1329 | ||
1328 | #if QT_VERSION > 233 | 1330 | #if QT_VERSION > 233 |
1329 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1331 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1330 | // don't block ourselves ... | 1332 | // don't block ourselves ... |
1331 | Opie::force_appearance = 0; | 1333 | Opie::force_appearance = 0; |
1332 | 1334 | ||
1333 | static QString appname = Opie::binaryName ( ); | 1335 | static QString appname = Opie::binaryName ( ); |
1334 | 1336 | ||
1335 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1337 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1336 | int nostyle = 0; | 1338 | int nostyle = 0; |
1337 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1339 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1338 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1340 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1339 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1341 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1340 | break; | 1342 | break; |
1341 | } | 1343 | } |
1342 | } | 1344 | } |
1343 | #else | 1345 | #else |
1344 | int nostyle = 0; | 1346 | int nostyle = 0; |
1345 | #endif | 1347 | #endif |
1346 | 1348 | ||
1347 | // Widget style | 1349 | // Widget style |
1348 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1350 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1349 | 1351 | ||
1350 | // don't set a custom style | 1352 | // don't set a custom style |
1351 | if ( nostyle & Opie::Force_Style ) | 1353 | if ( nostyle & Opie::Force_Style ) |
1352 | style = "FlatStyle"; | 1354 | style = "FlatStyle"; |
1353 | 1355 | ||
1354 | internalSetStyle ( style ); | 1356 | internalSetStyle ( style ); |
1355 | 1357 | ||
1356 | // Colors - from /etc/colors/Liquid.scheme | 1358 | // Colors - from /etc/colors/Liquid.scheme |
1357 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1359 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1358 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1360 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1359 | QPalette pal( btncolor, bgcolor ); | 1361 | QPalette pal( btncolor, bgcolor ); |
1360 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1362 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1361 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1363 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1362 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1364 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1363 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1365 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1364 | color = config.readEntry( "Text", "#000000" ); | 1366 | color = config.readEntry( "Text", "#000000" ); |
1365 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1367 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1366 | color = config.readEntry( "ButtonText", "#000000" ); | 1368 | color = config.readEntry( "ButtonText", "#000000" ); |
1367 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1369 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1368 | color = config.readEntry( "Base", "#FFFFFF" ); | 1370 | color = config.readEntry( "Base", "#FFFFFF" ); |
1369 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1371 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1370 | 1372 | ||
1371 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1373 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1372 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1374 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1373 | 1375 | ||
1374 | setPalette( pal, TRUE ); | 1376 | setPalette( pal, TRUE ); |
1375 | 1377 | ||
1378 | |||
1379 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | ||
1380 | if (&qt_left_hand_scrollbars ) | ||
1381 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | ||
1382 | |||
1376 | // Window Decoration | 1383 | // Window Decoration |
1377 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1384 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1378 | 1385 | ||
1379 | // don't set a custom deco | 1386 | // don't set a custom deco |
1380 | if ( nostyle & Opie::Force_Decoration ) | 1387 | if ( nostyle & Opie::Force_Decoration ) |
1381 | dec = ""; | 1388 | dec = ""; |
1382 | 1389 | ||
1383 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | ||
1384 | 1390 | ||
1385 | if ( dec != d->decorationName ) { | 1391 | if ( dec != d->decorationName ) { |
1386 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1392 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1387 | d->decorationName = dec; | 1393 | d->decorationName = dec; |
1388 | } | 1394 | } |
1389 | 1395 | ||
1390 | // Font | 1396 | // Font |
1391 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1397 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1392 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1398 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1393 | 1399 | ||
1394 | // don't set a custom font | 1400 | // don't set a custom font |
1395 | if ( nostyle & Opie::Force_Font ) { | 1401 | if ( nostyle & Opie::Force_Font ) { |
1396 | ff = "Vera"; | 1402 | ff = "Vera"; |
1397 | fs = 10; | 1403 | fs = 10; |
1398 | } | 1404 | } |
1399 | 1405 | ||
1400 | setFont ( QFont ( ff, fs ), true ); | 1406 | setFont ( QFont ( ff, fs ), true ); |
1401 | 1407 | ||
1402 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1408 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1403 | // revert to global blocking policy ... | 1409 | // revert to global blocking policy ... |
1404 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1410 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1405 | Opie::force_appearance &= ~nostyle; | 1411 | Opie::force_appearance &= ~nostyle; |
1406 | #endif | 1412 | #endif |
1407 | #endif | 1413 | #endif |
1408 | } | 1414 | } |
1409 | 1415 | ||
1410 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1416 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1411 | { | 1417 | { |
1412 | #ifdef Q_WS_QWS | 1418 | #ifdef Q_WS_QWS |
1413 | QDataStream stream( data, IO_ReadOnly ); | 1419 | QDataStream stream( data, IO_ReadOnly ); |
1414 | if ( msg == "applyStyle()" ) { | 1420 | if ( msg == "applyStyle()" ) { |
1415 | applyStyle(); | 1421 | applyStyle(); |
1416 | } | 1422 | } |
1417 | else if ( msg == "toggleApplicationMenu()" ) { | 1423 | else if ( msg == "toggleApplicationMenu()" ) { |
1418 | QWidget *active = activeWindow ( ); | 1424 | QWidget *active = activeWindow ( ); |
1419 | 1425 | ||
1420 | if ( active ) { | 1426 | if ( active ) { |
1421 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1427 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1422 | bool oldactive = man-> isActive ( ); | 1428 | bool oldactive = man-> isActive ( ); |
1423 | 1429 | ||
1424 | man-> setActive( !man-> isActive() ); | 1430 | man-> setActive( !man-> isActive() ); |
1425 | 1431 | ||
1426 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1432 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1427 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1433 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1428 | } | 1434 | } |
1429 | } | 1435 | } |
1430 | } | 1436 | } |
1431 | else if ( msg == "setDefaultRotation(int)" ) { | 1437 | else if ( msg == "setDefaultRotation(int)" ) { |
1432 | if ( type() == GuiServer ) { | 1438 | if ( type() == GuiServer ) { |
1433 | int r; | 1439 | int r; |
1434 | stream >> r; | 1440 | stream >> r; |
1435 | setDefaultRotation( r ); | 1441 | setDefaultRotation( r ); |
1436 | } | 1442 | } |
1437 | } | 1443 | } |
1438 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1444 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1439 | if ( type() == GuiServer ) { | 1445 | if ( type() == GuiServer ) { |
1440 | int x, y, depth; | 1446 | int x, y, depth; |
1441 | stream >> x; | 1447 | stream >> x; |
1442 | stream >> y; | 1448 | stream >> y; |
1443 | stream >> depth; | 1449 | stream >> depth; |
1444 | setCurrentMode( x, y, depth ); | 1450 | setCurrentMode( x, y, depth ); |
1445 | } | 1451 | } |
1446 | } | 1452 | } |
1447 | else if ( msg == "reset()" ) { | 1453 | else if ( msg == "reset()" ) { |
1448 | if ( type() != GuiServer ) | 1454 | if ( type() != GuiServer ) |
1449 | reset(); | 1455 | reset(); |
1450 | } | 1456 | } |
1451 | else if ( msg == "setCurrentRotation(int)" ) { | 1457 | else if ( msg == "setCurrentRotation(int)" ) { |
1452 | int r; | 1458 | int r; |
1453 | stream >> r; | 1459 | stream >> r; |
1454 | setCurrentRotation( r ); | 1460 | setCurrentRotation( r ); |
1455 | } | 1461 | } |
1456 | else if ( msg == "shutdown()" ) { | 1462 | else if ( msg == "shutdown()" ) { |
1457 | if ( type() == GuiServer ) | 1463 | if ( type() == GuiServer ) |
1458 | shutdown(); | 1464 | shutdown(); |
1459 | } | 1465 | } |
1460 | else if ( msg == "quit()" ) { | 1466 | else if ( msg == "quit()" ) { |
1461 | if ( type() != GuiServer ) | 1467 | if ( type() != GuiServer ) |
1462 | tryQuit(); | 1468 | tryQuit(); |
1463 | } | 1469 | } |
1464 | else if ( msg == "forceQuit()" ) { | 1470 | else if ( msg == "forceQuit()" ) { |
1465 | if ( type() != GuiServer ) | 1471 | if ( type() != GuiServer ) |
1466 | quit(); | 1472 | quit(); |
1467 | } | 1473 | } |
1468 | else if ( msg == "restart()" ) { | 1474 | else if ( msg == "restart()" ) { |
1469 | if ( type() == GuiServer ) | 1475 | if ( type() == GuiServer ) |
1470 | restart(); | 1476 | restart(); |
1471 | } | 1477 | } |
1472 | else if ( msg == "language(QString)" ) { | 1478 | else if ( msg == "language(QString)" ) { |
1473 | if ( type() == GuiServer ) { | 1479 | if ( type() == GuiServer ) { |
1474 | QString l; | 1480 | QString l; |
1475 | stream >> l; | 1481 | stream >> l; |
1476 | QString cl = getenv( "LANG" ); | 1482 | QString cl = getenv( "LANG" ); |
1477 | if ( cl != l ) { | 1483 | if ( cl != l ) { |
1478 | if ( l.isNull() ) | 1484 | if ( l.isNull() ) |
1479 | unsetenv( "LANG" ); | 1485 | unsetenv( "LANG" ); |
1480 | else | 1486 | else |
1481 | setenv( "LANG", l.latin1(), 1 ); | 1487 | setenv( "LANG", l.latin1(), 1 ); |
1482 | restart(); | 1488 | restart(); |
1483 | } | 1489 | } |
1484 | } | 1490 | } |
1485 | } | 1491 | } |
1486 | else if ( msg == "timeChange(QString)" ) { | 1492 | else if ( msg == "timeChange(QString)" ) { |
1487 | QString t; | 1493 | QString t; |
1488 | stream >> t; | 1494 | stream >> t; |
1489 | if ( t.isNull() ) | 1495 | if ( t.isNull() ) |
1490 | unsetenv( "TZ" ); | 1496 | unsetenv( "TZ" ); |
1491 | else | 1497 | else |
1492 | setenv( "TZ", t.latin1(), 1 ); | 1498 | setenv( "TZ", t.latin1(), 1 ); |
1493 | // emit the signal so everyone else knows... | 1499 | // emit the signal so everyone else knows... |
1494 | emit timeChanged(); | 1500 | emit timeChanged(); |
1495 | } | 1501 | } |
1496 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1502 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1497 | if ( type() == GuiServer ) { | 1503 | if ( type() == GuiServer ) { |
1498 | QDateTime when; | 1504 | QDateTime when; |
1499 | QCString channel, message; | 1505 | QCString channel, message; |
1500 | int data; | 1506 | int data; |
1501 | stream >> when >> channel >> message >> data; | 1507 | stream >> when >> channel >> message >> data; |
1502 | AlarmServer::addAlarm( when, channel, message, data ); | 1508 | AlarmServer::addAlarm( when, channel, message, data ); |
1503 | } | 1509 | } |
1504 | } | 1510 | } |
1505 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1511 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1506 | if ( type() == GuiServer ) { | 1512 | if ( type() == GuiServer ) { |
1507 | QDateTime when; | 1513 | QDateTime when; |
1508 | QCString channel, message; | 1514 | QCString channel, message; |
1509 | int data; | 1515 | int data; |
1510 | stream >> when >> channel >> message >> data; | 1516 | stream >> when >> channel >> message >> data; |
1511 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1517 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1512 | } | 1518 | } |
1513 | } | 1519 | } |
1514 | else if ( msg == "clockChange(bool)" ) { | 1520 | else if ( msg == "clockChange(bool)" ) { |
1515 | int tmp; | 1521 | int tmp; |
1516 | stream >> tmp; | 1522 | stream >> tmp; |
1517 | emit clockChanged( tmp ); | 1523 | emit clockChanged( tmp ); |
1518 | } | 1524 | } |
1519 | else if ( msg == "weekChange(bool)" ) { | 1525 | else if ( msg == "weekChange(bool)" ) { |
1520 | int tmp; | 1526 | int tmp; |
1521 | stream >> tmp; | 1527 | stream >> tmp; |
1522 | emit weekChanged( tmp ); | 1528 | emit weekChanged( tmp ); |
1523 | } | 1529 | } |
1524 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1530 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1525 | DateFormat tmp; | 1531 | DateFormat tmp; |
1526 | stream >> tmp; | 1532 | stream >> tmp; |
1527 | emit dateFormatChanged( tmp ); | 1533 | emit dateFormatChanged( tmp ); |
1528 | } | 1534 | } |
1529 | else if ( msg == "setVolume(int,int)" ) { | 1535 | else if ( msg == "setVolume(int,int)" ) { |
1530 | int t, v; | 1536 | int t, v; |
1531 | stream >> t >> v; | 1537 | stream >> t >> v; |
1532 | setVolume( t, v ); | 1538 | setVolume( t, v ); |
1533 | emit volumeChanged( muted ); | 1539 | emit volumeChanged( muted ); |
1534 | } | 1540 | } |
1535 | else if ( msg == "volumeChange(bool)" ) { | 1541 | else if ( msg == "volumeChange(bool)" ) { |
1536 | stream >> muted; | 1542 | stream >> muted; |
1537 | setVolume(); | 1543 | setVolume(); |
1538 | emit volumeChanged( muted ); | 1544 | emit volumeChanged( muted ); |
1539 | } | 1545 | } |
1540 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1546 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1541 | int t, v; | 1547 | int t, v; |
1542 | stream >> t >> v; | 1548 | stream >> t >> v; |
1543 | setMic( t, v ); | 1549 | setMic( t, v ); |
1544 | emit micChanged( micMuted ); | 1550 | emit micChanged( micMuted ); |
1545 | } | 1551 | } |
1546 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1552 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1547 | stream >> micMuted; | 1553 | stream >> micMuted; |
1548 | setMic(); | 1554 | setMic(); |
1549 | emit micChanged( micMuted ); | 1555 | emit micChanged( micMuted ); |
1550 | } | 1556 | } |
1551 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1557 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1552 | int t, v; | 1558 | int t, v; |
1553 | stream >> t >> v; | 1559 | stream >> t >> v; |
1554 | setBass( t, v ); | 1560 | setBass( t, v ); |
1555 | } | 1561 | } |
1556 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1562 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1557 | setBass(); | 1563 | setBass(); |
1558 | } | 1564 | } |
1559 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1565 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1560 | int t, v; | 1566 | int t, v; |
1561 | stream >> t >> v; | 1567 | stream >> t >> v; |
1562 | setTreble( t, v ); | 1568 | setTreble( t, v ); |
1563 | } | 1569 | } |
1564 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1570 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1565 | setTreble(); | 1571 | setTreble(); |
1566 | } else if ( msg == "getMarkedText()" ) { | 1572 | } else if ( msg == "getMarkedText()" ) { |
1567 | if ( type() == GuiServer ) { | 1573 | if ( type() == GuiServer ) { |
1568 | const ushort unicode = 'C'-'@'; | 1574 | const ushort unicode = 'C'-'@'; |
1569 | const int scan = Key_C; | 1575 | const int scan = Key_C; |
1570 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1576 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1571 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1577 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1572 | } | 1578 | } |
1573 | } else if ( msg == "newChannel(QString)") { | 1579 | } else if ( msg == "newChannel(QString)") { |
1574 | QString myChannel = "QPE/Application/" + d->appName; | 1580 | QString myChannel = "QPE/Application/" + d->appName; |
1575 | QString channel; | 1581 | QString channel; |
1576 | stream >> channel; | 1582 | stream >> channel; |
1577 | if (channel == myChannel) { | 1583 | if (channel == myChannel) { |
1578 | processQCopFile(); | 1584 | processQCopFile(); |
1579 | d->sendQCopQ(); | 1585 | d->sendQCopQ(); |
1580 | } | 1586 | } |
1581 | } | 1587 | } |
1582 | 1588 | ||
1583 | 1589 | ||
1584 | #endif | 1590 | #endif |
1585 | } | 1591 | } |
1586 | 1592 | ||
1587 | 1593 | ||
1588 | 1594 | ||
1589 | 1595 | ||
1590 | 1596 | ||
1591 | /*! | 1597 | /*! |
1592 | \internal | 1598 | \internal |
1593 | */ | 1599 | */ |
1594 | bool QPEApplication::raiseAppropriateWindow() | 1600 | bool QPEApplication::raiseAppropriateWindow() |
1595 | { | 1601 | { |
1596 | bool r=FALSE; | 1602 | bool r=FALSE; |
1597 | 1603 | ||
1598 | // 1. Raise the main widget | 1604 | // 1. Raise the main widget |
1599 | QWidget *top = d->qpe_main_widget; | 1605 | QWidget *top = d->qpe_main_widget; |
1600 | if ( !top ) top = mainWidget(); | 1606 | if ( !top ) top = mainWidget(); |
1601 | 1607 | ||
1602 | if ( top && d->keep_running ) { | 1608 | if ( top && d->keep_running ) { |
1603 | if ( top->isVisible() ) | 1609 | if ( top->isVisible() ) |
1604 | r = TRUE; | 1610 | r = TRUE; |
1605 | else if (d->preloaded) { | 1611 | else if (d->preloaded) { |
1606 | // We are preloaded and not visible.. pretend we just started.. | 1612 | // We are preloaded and not visible.. pretend we just started.. |
1607 | #ifndef QT_NO_COP | 1613 | #ifndef QT_NO_COP |
1608 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1614 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1609 | e << d->appName; | 1615 | e << d->appName; |
1610 | #endif | 1616 | #endif |
1611 | } | 1617 | } |
1612 | 1618 | ||
1613 | d->show_mx(top,d->nomaximize, d->appName); | 1619 | d->show_mx(top,d->nomaximize, d->appName); |
1614 | top->raise(); | 1620 | top->raise(); |
1615 | } | 1621 | } |
1616 | 1622 | ||
1617 | QWidget *topm = activeModalWidget(); | 1623 | QWidget *topm = activeModalWidget(); |
1618 | 1624 | ||
1619 | // 2. Raise any parentless widgets (except top and topm, as they | 1625 | // 2. Raise any parentless widgets (except top and topm, as they |
1620 | // are raised before and after this loop). Order from most | 1626 | // are raised before and after this loop). Order from most |
1621 | // recently raised as deepest to least recently as top, so | 1627 | // recently raised as deepest to least recently as top, so |
1622 | // that repeated calls cycle through widgets. | 1628 | // that repeated calls cycle through widgets. |
1623 | QWidgetList *list = topLevelWidgets(); | 1629 | QWidgetList *list = topLevelWidgets(); |
1624 | if ( list ) { | 1630 | if ( list ) { |
1625 | bool foundlast = FALSE; | 1631 | bool foundlast = FALSE; |
1626 | QWidget* topsub = 0; | 1632 | QWidget* topsub = 0; |
1627 | if ( d->lastraised ) { | 1633 | if ( d->lastraised ) { |
1628 | for (QWidget* w = list->first(); w; w = list->next()) { | 1634 | for (QWidget* w = list->first(); w; w = list->next()) { |
1629 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1635 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1630 | if ( w == d->lastraised ) | 1636 | if ( w == d->lastraised ) |
1631 | foundlast = TRUE; | 1637 | foundlast = TRUE; |
1632 | if ( foundlast ) { | 1638 | if ( foundlast ) { |
1633 | w->raise(); | 1639 | w->raise(); |
1634 | topsub = w; | 1640 | topsub = w; |
1635 | } | 1641 | } |
1636 | } | 1642 | } |
1637 | } | 1643 | } |
1638 | } | 1644 | } |
1639 | for (QWidget* w = list->first(); w; w = list->next()) { | 1645 | for (QWidget* w = list->first(); w; w = list->next()) { |
1640 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1646 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1641 | if ( w == d->lastraised ) | 1647 | if ( w == d->lastraised ) |
1642 | break; | 1648 | break; |
1643 | w->raise(); | 1649 | w->raise(); |
1644 | topsub = w; | 1650 | topsub = w; |
1645 | } | 1651 | } |
1646 | } | 1652 | } |
1647 | d->lastraised = topsub; | 1653 | d->lastraised = topsub; |
1648 | delete list; | 1654 | delete list; |
1649 | } | 1655 | } |
1650 | 1656 | ||
1651 | // 3. Raise the active modal widget. | 1657 | // 3. Raise the active modal widget. |
1652 | if ( topm ) { | 1658 | if ( topm ) { |
1653 | topm->show(); | 1659 | topm->show(); |
1654 | topm->raise(); | 1660 | topm->raise(); |
1655 | // If we haven't already handled the fastAppShowing message | 1661 | // If we haven't already handled the fastAppShowing message |
1656 | if (!top && d->preloaded) { | 1662 | if (!top && d->preloaded) { |
1657 | #ifndef QT_NO_COP | 1663 | #ifndef QT_NO_COP |
1658 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1664 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1659 | e << d->appName; | 1665 | e << d->appName; |
1660 | #endif | 1666 | #endif |
1661 | } | 1667 | } |
1662 | r = FALSE; | 1668 | r = FALSE; |
1663 | } | 1669 | } |
1664 | 1670 | ||
1665 | return r; | 1671 | return r; |
1666 | } | 1672 | } |
1667 | 1673 | ||
1668 | 1674 | ||
1669 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1675 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1670 | { | 1676 | { |
1671 | #ifdef Q_WS_QWS | 1677 | #ifdef Q_WS_QWS |
1672 | 1678 | ||
1673 | if ( msg == "quit()" ) { | 1679 | if ( msg == "quit()" ) { |
1674 | tryQuit(); | 1680 | tryQuit(); |
1675 | } | 1681 | } |
1676 | else if ( msg == "quitIfInvisible()" ) { | 1682 | else if ( msg == "quitIfInvisible()" ) { |
1677 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1683 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1678 | quit(); | 1684 | quit(); |
1679 | } | 1685 | } |
1680 | else if ( msg == "close()" ) { | 1686 | else if ( msg == "close()" ) { |
1681 | hideOrQuit(); | 1687 | hideOrQuit(); |
1682 | } | 1688 | } |
1683 | else if ( msg == "disablePreload()" ) { | 1689 | else if ( msg == "disablePreload()" ) { |
1684 | d->preloaded = FALSE; | 1690 | d->preloaded = FALSE; |
1685 | d->keep_running = TRUE; | 1691 | d->keep_running = TRUE; |
1686 | /* so that quit will quit */ | 1692 | /* so that quit will quit */ |
1687 | } | 1693 | } |
1688 | else if ( msg == "enablePreload()" ) { | 1694 | else if ( msg == "enablePreload()" ) { |
1689 | if (d->qpe_main_widget) | 1695 | if (d->qpe_main_widget) |
1690 | d->preloaded = TRUE; | 1696 | d->preloaded = TRUE; |
1691 | d->keep_running = TRUE; | 1697 | d->keep_running = TRUE; |
1692 | /* so next quit won't quit */ | 1698 | /* so next quit won't quit */ |
1693 | } | 1699 | } |
1694 | else if ( msg == "raise()" ) { | 1700 | else if ( msg == "raise()" ) { |
1695 | d->keep_running = TRUE; | 1701 | d->keep_running = TRUE; |
1696 | d->notbusysent = FALSE; | 1702 | d->notbusysent = FALSE; |
1697 | raiseAppropriateWindow(); | 1703 | raiseAppropriateWindow(); |
1698 | // Tell the system we're still chugging along... | 1704 | // Tell the system we're still chugging along... |
1699 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1705 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1700 | e << d->appName; | 1706 | e << d->appName; |
1701 | } | 1707 | } |
1702 | else if ( msg == "flush()" ) { | 1708 | else if ( msg == "flush()" ) { |
1703 | emit flush(); | 1709 | emit flush(); |
1704 | // we need to tell the desktop | 1710 | // we need to tell the desktop |
1705 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1711 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1706 | e << d->appName; | 1712 | e << d->appName; |
1707 | } | 1713 | } |
1708 | else if ( msg == "reload()" ) { | 1714 | else if ( msg == "reload()" ) { |
1709 | emit reload(); | 1715 | emit reload(); |
1710 | } | 1716 | } |
1711 | else if ( msg == "setDocument(QString)" ) { | 1717 | else if ( msg == "setDocument(QString)" ) { |
1712 | d->keep_running = TRUE; | 1718 | d->keep_running = TRUE; |
1713 | QDataStream stream( data, IO_ReadOnly ); | 1719 | QDataStream stream( data, IO_ReadOnly ); |
1714 | QString doc; | 1720 | QString doc; |
1715 | stream >> doc; | 1721 | stream >> doc; |
1716 | QWidget *mw = mainWidget(); | 1722 | QWidget *mw = mainWidget(); |
1717 | if ( !mw ) | 1723 | if ( !mw ) |
1718 | mw = d->qpe_main_widget; | 1724 | mw = d->qpe_main_widget; |
1719 | if ( mw ) | 1725 | if ( mw ) |
1720 | Global::setDocument( mw, doc ); | 1726 | Global::setDocument( mw, doc ); |
1721 | 1727 | ||
1722 | } else if ( msg == "QPEProcessQCop()" ) { | 1728 | } else if ( msg == "QPEProcessQCop()" ) { |
1723 | processQCopFile(); | 1729 | processQCopFile(); |
1724 | d->sendQCopQ(); | 1730 | d->sendQCopQ(); |
1725 | }else | 1731 | }else |
1726 | { | 1732 | { |
1727 | bool p = d->keep_running; | 1733 | bool p = d->keep_running; |
1728 | d->keep_running = FALSE; | 1734 | d->keep_running = FALSE; |
1729 | emit appMessage( msg, data); | 1735 | emit appMessage( msg, data); |
1730 | if ( d->keep_running ) { | 1736 | if ( d->keep_running ) { |
1731 | d->notbusysent = FALSE; | 1737 | d->notbusysent = FALSE; |
1732 | raiseAppropriateWindow(); | 1738 | raiseAppropriateWindow(); |
1733 | if ( !p ) { | 1739 | if ( !p ) { |
1734 | // Tell the system we're still chugging along... | 1740 | // Tell the system we're still chugging along... |
1735 | #ifndef QT_NO_COP | 1741 | #ifndef QT_NO_COP |
1736 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1742 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1737 | e << d->appName; | 1743 | e << d->appName; |
1738 | #endif | 1744 | #endif |
1739 | } | 1745 | } |
1740 | } | 1746 | } |
1741 | if ( p ) | 1747 | if ( p ) |
1742 | d->keep_running = p; | 1748 | d->keep_running = p; |
1743 | } | 1749 | } |
1744 | #endif | 1750 | #endif |
1745 | } | 1751 | } |
1746 | 1752 | ||
1747 | 1753 | ||
1748 | /*! | 1754 | /*! |
1749 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1755 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1750 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1756 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1751 | 1757 | ||
1752 | \sa showMainDocumentWidget() | 1758 | \sa showMainDocumentWidget() |
1753 | */ | 1759 | */ |
1754 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1760 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1755 | { | 1761 | { |
1756 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1762 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1757 | d->show(mw, nomaximize ); | 1763 | d->show(mw, nomaximize ); |
1758 | } | 1764 | } |
1759 | 1765 | ||
1760 | /*! | 1766 | /*! |
1761 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1767 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1762 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1768 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1763 | 1769 | ||
1764 | This calls designates the application as | 1770 | This calls designates the application as |
1765 | a \link docwidget.html document-oriented\endlink application. | 1771 | a \link docwidget.html document-oriented\endlink application. |
1766 | 1772 | ||
1767 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1773 | The \a mw widget \e must have this slot: setDocument(const QString&). |