author | sandman <sandman> | 2002-07-01 09:45:51 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-01 09:45:51 (UTC) |
commit | 346ea8fa0d904e940659bc35fad0fc0da8cc7f80 (patch) (unidiff) | |
tree | 26e3865ba996ff5154132ed9020cab897cb9ad94 | |
parent | 05d74acac3af056bfd784c6f2b7f72d313ea64bc (diff) | |
download | opie-346ea8fa0d904e940659bc35fad0fc0da8cc7f80.zip opie-346ea8fa0d904e940659bc35fad0fc0da8cc7f80.tar.gz opie-346ea8fa0d904e940659bc35fad0fc0da8cc7f80.tar.bz2 |
Made loading of custom styles much faster, since symbols are now resolved
"on-the-fly" (This only makes it harder for new styles to be debugged)
-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 6e2db7c..dff8235 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -968,749 +968,749 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) | |||
968 | stream >> bright; | 968 | stream >> bright; |
969 | setBacklight(bright); | 969 | setBacklight(bright); |
970 | } | 970 | } |
971 | } else if ( msg == "setDefaultRotation(int)" ) { | 971 | } else if ( msg == "setDefaultRotation(int)" ) { |
972 | if ( type() == GuiServer ) { | 972 | if ( type() == GuiServer ) { |
973 | int r; | 973 | int r; |
974 | stream >> r; | 974 | stream >> r; |
975 | setDefaultRotation(r); | 975 | setDefaultRotation(r); |
976 | } | 976 | } |
977 | } else if ( msg == "shutdown()" ) { | 977 | } else if ( msg == "shutdown()" ) { |
978 | if ( type() == GuiServer ) | 978 | if ( type() == GuiServer ) |
979 | shutdown(); | 979 | shutdown(); |
980 | } else if ( msg == "quit()" ) { | 980 | } else if ( msg == "quit()" ) { |
981 | if ( type() != GuiServer ) | 981 | if ( type() != GuiServer ) |
982 | tryQuit(); | 982 | tryQuit(); |
983 | } else if ( msg == "forceQuit()" ) { | 983 | } else if ( msg == "forceQuit()" ) { |
984 | if ( type() != GuiServer ) | 984 | if ( type() != GuiServer ) |
985 | quit(); | 985 | quit(); |
986 | } else if ( msg == "restart()" ) { | 986 | } else if ( msg == "restart()" ) { |
987 | if ( type() == GuiServer ) | 987 | if ( type() == GuiServer ) |
988 | restart(); | 988 | restart(); |
989 | } else if ( msg == "grabKeyboard(QString)" ) { | 989 | } else if ( msg == "grabKeyboard(QString)" ) { |
990 | QString who; | 990 | QString who; |
991 | stream >> who; | 991 | stream >> who; |
992 | if ( who.isEmpty() ) | 992 | if ( who.isEmpty() ) |
993 | d->kbgrabber = 0; | 993 | d->kbgrabber = 0; |
994 | else if ( who != d->appName ) | 994 | else if ( who != d->appName ) |
995 | d->kbgrabber = 1; | 995 | d->kbgrabber = 1; |
996 | else | 996 | else |
997 | d->kbgrabber = 2; | 997 | d->kbgrabber = 2; |
998 | } else if ( msg == "language(QString)" ) { | 998 | } else if ( msg == "language(QString)" ) { |
999 | if ( type() == GuiServer ) { | 999 | if ( type() == GuiServer ) { |
1000 | QString l; | 1000 | QString l; |
1001 | stream >> l; | 1001 | stream >> l; |
1002 | QString cl = getenv("LANG"); | 1002 | QString cl = getenv("LANG"); |
1003 | if ( cl != l ) { | 1003 | if ( cl != l ) { |
1004 | if ( l.isNull() ) | 1004 | if ( l.isNull() ) |
1005 | unsetenv( "LANG" ); | 1005 | unsetenv( "LANG" ); |
1006 | else | 1006 | else |
1007 | setenv( "LANG", l.latin1(), 1 ); | 1007 | setenv( "LANG", l.latin1(), 1 ); |
1008 | restart(); | 1008 | restart(); |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | } else if ( msg == "timeChange(QString)" ) { | 1011 | } else if ( msg == "timeChange(QString)" ) { |
1012 | QString t; | 1012 | QString t; |
1013 | stream >> t; | 1013 | stream >> t; |
1014 | if ( t.isNull() ) | 1014 | if ( t.isNull() ) |
1015 | unsetenv( "TZ" ); | 1015 | unsetenv( "TZ" ); |
1016 | else | 1016 | else |
1017 | setenv( "TZ", t.latin1(), 1 ); | 1017 | setenv( "TZ", t.latin1(), 1 ); |
1018 | // emit the signal so everyone else knows... | 1018 | // emit the signal so everyone else knows... |
1019 | emit timeChanged(); | 1019 | emit timeChanged(); |
1020 | } else if ( msg == "execute(QString)" ) { | 1020 | } else if ( msg == "execute(QString)" ) { |
1021 | if ( type() == GuiServer ) { | 1021 | if ( type() == GuiServer ) { |
1022 | QString t; | 1022 | QString t; |
1023 | stream >> t; | 1023 | stream >> t; |
1024 | Global::execute( t ); | 1024 | Global::execute( t ); |
1025 | } | 1025 | } |
1026 | } else if ( msg == "execute(QString,QString)" ) { | 1026 | } else if ( msg == "execute(QString,QString)" ) { |
1027 | if ( type() == GuiServer ) { | 1027 | if ( type() == GuiServer ) { |
1028 | QString t,d; | 1028 | QString t,d; |
1029 | stream >> t >> d; | 1029 | stream >> t >> d; |
1030 | Global::execute( t, d ); | 1030 | Global::execute( t, d ); |
1031 | } | 1031 | } |
1032 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1032 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1033 | if ( type() == GuiServer ) { | 1033 | if ( type() == GuiServer ) { |
1034 | QDateTime when; | 1034 | QDateTime when; |
1035 | QCString channel, message; | 1035 | QCString channel, message; |
1036 | int data; | 1036 | int data; |
1037 | stream >> when >> channel >> message >> data; | 1037 | stream >> when >> channel >> message >> data; |
1038 | AlarmServer::addAlarm( when, channel, message, data ); | 1038 | AlarmServer::addAlarm( when, channel, message, data ); |
1039 | } | 1039 | } |
1040 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1040 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1041 | if ( type() == GuiServer ) { | 1041 | if ( type() == GuiServer ) { |
1042 | QDateTime when; | 1042 | QDateTime when; |
1043 | QCString channel, message; | 1043 | QCString channel, message; |
1044 | int data; | 1044 | int data; |
1045 | stream >> when >> channel >> message >> data; | 1045 | stream >> when >> channel >> message >> data; |
1046 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1046 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1047 | } | 1047 | } |
1048 | } else if ( msg == "clockChange(bool)" ) { | 1048 | } else if ( msg == "clockChange(bool)" ) { |
1049 | int tmp; | 1049 | int tmp; |
1050 | stream >> tmp; | 1050 | stream >> tmp; |
1051 | emit clockChanged( tmp ); | 1051 | emit clockChanged( tmp ); |
1052 | } else if ( msg == "weekChange(bool)" ) { | 1052 | } else if ( msg == "weekChange(bool)" ) { |
1053 | int tmp; | 1053 | int tmp; |
1054 | stream >> tmp; | 1054 | stream >> tmp; |
1055 | emit weekChanged( tmp ); | 1055 | emit weekChanged( tmp ); |
1056 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 1056 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
1057 | DateFormat tmp; | 1057 | DateFormat tmp; |
1058 | stream >> tmp; | 1058 | stream >> tmp; |
1059 | emit dateFormatChanged( tmp ); | 1059 | emit dateFormatChanged( tmp ); |
1060 | } else if ( msg == "setVolume(int,int)" ) { | 1060 | } else if ( msg == "setVolume(int,int)" ) { |
1061 | int t,v; | 1061 | int t,v; |
1062 | stream >> t >> v; | 1062 | stream >> t >> v; |
1063 | setVolume(t,v); | 1063 | setVolume(t,v); |
1064 | emit volumeChanged( muted ); | 1064 | emit volumeChanged( muted ); |
1065 | } else if ( msg == "volumeChange(bool)" ) { | 1065 | } else if ( msg == "volumeChange(bool)" ) { |
1066 | stream >> muted; | 1066 | stream >> muted; |
1067 | setVolume(); | 1067 | setVolume(); |
1068 | emit volumeChanged( muted ); | 1068 | emit volumeChanged( muted ); |
1069 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1069 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1070 | int t,v; | 1070 | int t,v; |
1071 | stream >> t >> v; | 1071 | stream >> t >> v; |
1072 | setMic(t,v); | 1072 | setMic(t,v); |
1073 | emit micChanged( micMuted ); | 1073 | emit micChanged( micMuted ); |
1074 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1074 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1075 | stream >> micMuted; | 1075 | stream >> micMuted; |
1076 | setMic(); | 1076 | setMic(); |
1077 | emit micChanged( micMuted ); | 1077 | emit micChanged( micMuted ); |
1078 | } else if ( msg == "setScreenSaverMode(int)" ) { | 1078 | } else if ( msg == "setScreenSaverMode(int)" ) { |
1079 | if ( type() == GuiServer ) { | 1079 | if ( type() == GuiServer ) { |
1080 | int old = disable_suspend; | 1080 | int old = disable_suspend; |
1081 | stream >> disable_suspend; | 1081 | stream >> disable_suspend; |
1082 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); | 1082 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); |
1083 | if ( disable_suspend > old ) | 1083 | if ( disable_suspend > old ) |
1084 | setScreenSaverInterval( -1 ); | 1084 | setScreenSaverInterval( -1 ); |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | #endif | 1087 | #endif |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | /*! | 1090 | /*! |
1091 | \internal | 1091 | \internal |
1092 | */ | 1092 | */ |
1093 | bool QPEApplication::raiseAppropriateWindow() | 1093 | bool QPEApplication::raiseAppropriateWindow() |
1094 | { | 1094 | { |
1095 | bool r=FALSE; | 1095 | bool r=FALSE; |
1096 | // ########## raise()ing main window should raise and set active | 1096 | // ########## raise()ing main window should raise and set active |
1097 | // ########## it and then all childen. This belongs in Qt/Embedded | 1097 | // ########## it and then all childen. This belongs in Qt/Embedded |
1098 | QWidget *top = d->qpe_main_widget; | 1098 | QWidget *top = d->qpe_main_widget; |
1099 | if ( !top ) top =mainWidget(); | 1099 | if ( !top ) top =mainWidget(); |
1100 | if ( top && d->keep_running ) { | 1100 | if ( top && d->keep_running ) { |
1101 | if ( top->isVisible() ) | 1101 | if ( top->isVisible() ) |
1102 | r = TRUE; | 1102 | r = TRUE; |
1103 | #ifdef Q_WS_QWS | 1103 | #ifdef Q_WS_QWS |
1104 | if ( !d->nomaximize ) | 1104 | if ( !d->nomaximize ) |
1105 | top->showMaximized(); | 1105 | top->showMaximized(); |
1106 | else | 1106 | else |
1107 | #endif | 1107 | #endif |
1108 | top->show(); | 1108 | top->show(); |
1109 | top->raise(); | 1109 | top->raise(); |
1110 | top->setActiveWindow(); | 1110 | top->setActiveWindow(); |
1111 | } | 1111 | } |
1112 | QWidget *topm = activeModalWidget(); | 1112 | QWidget *topm = activeModalWidget(); |
1113 | if ( topm && topm != top ) { | 1113 | if ( topm && topm != top ) { |
1114 | topm->show(); | 1114 | topm->show(); |
1115 | topm->raise(); | 1115 | topm->raise(); |
1116 | topm->setActiveWindow(); | 1116 | topm->setActiveWindow(); |
1117 | r = FALSE; | 1117 | r = FALSE; |
1118 | } | 1118 | } |
1119 | return r; | 1119 | return r; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) | 1122 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) |
1123 | { | 1123 | { |
1124 | #ifdef Q_WS_QWS | 1124 | #ifdef Q_WS_QWS |
1125 | 1125 | ||
1126 | if ( msg == "quit()" ) { | 1126 | if ( msg == "quit()" ) { |
1127 | tryQuit(); | 1127 | tryQuit(); |
1128 | } else if ( msg == "quitIfInvisible()" ) { | 1128 | } else if ( msg == "quitIfInvisible()" ) { |
1129 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1129 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1130 | quit(); | 1130 | quit(); |
1131 | } else if ( msg == "close()" ) { | 1131 | } else if ( msg == "close()" ) { |
1132 | hideOrQuit(); | 1132 | hideOrQuit(); |
1133 | } else if ( msg == "disablePreload()" ) { | 1133 | } else if ( msg == "disablePreload()" ) { |
1134 | d->preloaded = FALSE; | 1134 | d->preloaded = FALSE; |
1135 | d->keep_running = TRUE; | 1135 | d->keep_running = TRUE; |
1136 | /* so that quit will quit */ | 1136 | /* so that quit will quit */ |
1137 | } else if ( msg == "enablePreload()" ) { | 1137 | } else if ( msg == "enablePreload()" ) { |
1138 | d->preloaded = TRUE; | 1138 | d->preloaded = TRUE; |
1139 | d->keep_running = TRUE; | 1139 | d->keep_running = TRUE; |
1140 | /* so next quit won't quit */ | 1140 | /* so next quit won't quit */ |
1141 | } else if ( msg == "raise()" ) { | 1141 | } else if ( msg == "raise()" ) { |
1142 | d->keep_running = TRUE; | 1142 | d->keep_running = TRUE; |
1143 | d->notbusysent = FALSE; | 1143 | d->notbusysent = FALSE; |
1144 | raiseAppropriateWindow(); | 1144 | raiseAppropriateWindow(); |
1145 | } else if ( msg == "flush()" ) { | 1145 | } else if ( msg == "flush()" ) { |
1146 | emit flush(); | 1146 | emit flush(); |
1147 | // we need to tell the desktop | 1147 | // we need to tell the desktop |
1148 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1148 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1149 | e << d->appName; | 1149 | e << d->appName; |
1150 | } else if ( msg == "reload()" ) { | 1150 | } else if ( msg == "reload()" ) { |
1151 | emit reload(); | 1151 | emit reload(); |
1152 | } else if ( msg == "setDocument(QString)" ) { | 1152 | } else if ( msg == "setDocument(QString)" ) { |
1153 | d->keep_running = TRUE; | 1153 | d->keep_running = TRUE; |
1154 | QDataStream stream( data, IO_ReadOnly ); | 1154 | QDataStream stream( data, IO_ReadOnly ); |
1155 | QString doc; | 1155 | QString doc; |
1156 | stream >> doc; | 1156 | stream >> doc; |
1157 | QWidget *mw = mainWidget(); | 1157 | QWidget *mw = mainWidget(); |
1158 | if ( !mw ) | 1158 | if ( !mw ) |
1159 | mw = d->qpe_main_widget; | 1159 | mw = d->qpe_main_widget; |
1160 | if ( mw ) | 1160 | if ( mw ) |
1161 | Global::setDocument( mw, doc ); | 1161 | Global::setDocument( mw, doc ); |
1162 | } else if ( msg == "nextView()" ) { | 1162 | } else if ( msg == "nextView()" ) { |
1163 | if ( raiseAppropriateWindow() ) | 1163 | if ( raiseAppropriateWindow() ) |
1164 | emit appMessage( msg, data); | 1164 | emit appMessage( msg, data); |
1165 | } else { | 1165 | } else { |
1166 | emit appMessage( msg, data); | 1166 | emit appMessage( msg, data); |
1167 | } | 1167 | } |
1168 | #endif | 1168 | #endif |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | 1171 | ||
1172 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 1172 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
1173 | { | 1173 | { |
1174 | /* | 1174 | /* |
1175 | // This works but disable it for now until it is safe to apply | 1175 | // This works but disable it for now until it is safe to apply |
1176 | // What is does is scan the .desktop files of all the apps for | 1176 | // What is does is scan the .desktop files of all the apps for |
1177 | // the applnk that has the corresponding argv[0] as this program | 1177 | // the applnk that has the corresponding argv[0] as this program |
1178 | // then it uses the name stored in the .desktop file as the caption | 1178 | // then it uses the name stored in the .desktop file as the caption |
1179 | // for the main widget. This saves duplicating translations for | 1179 | // for the main widget. This saves duplicating translations for |
1180 | // the app name in the program and in the .desktop files. | 1180 | // the app name in the program and in the .desktop files. |
1181 | 1181 | ||
1182 | AppLnkSet apps( appsPath ); | 1182 | AppLnkSet apps( appsPath ); |
1183 | 1183 | ||
1184 | QList<AppLnk> appsList = apps.children(); | 1184 | QList<AppLnk> appsList = apps.children(); |
1185 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 1185 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
1186 | if ( (*it)->exec() == appName ) { | 1186 | if ( (*it)->exec() == appName ) { |
1187 | mw->setCaption( (*it)->name() ); | 1187 | mw->setCaption( (*it)->name() ); |
1188 | return TRUE; | 1188 | return TRUE; |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | */ | 1191 | */ |
1192 | return FALSE; | 1192 | return FALSE; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | 1195 | ||
1196 | /*! | 1196 | /*! |
1197 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1197 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1198 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1198 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1199 | 1199 | ||
1200 | \sa showMainDocumentWidget() | 1200 | \sa showMainDocumentWidget() |
1201 | */ | 1201 | */ |
1202 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1202 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1203 | { | 1203 | { |
1204 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1204 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1205 | 1205 | ||
1206 | d->nomaximize = nomaximize; | 1206 | d->nomaximize = nomaximize; |
1207 | d->qpe_main_widget = mw; | 1207 | d->qpe_main_widget = mw; |
1208 | d->sendQCopQ(); | 1208 | d->sendQCopQ(); |
1209 | if ( d->preloaded ) { | 1209 | if ( d->preloaded ) { |
1210 | if(d->forceshow) { | 1210 | if(d->forceshow) { |
1211 | #ifdef Q_WS_QWS | 1211 | #ifdef Q_WS_QWS |
1212 | if ( !nomaximize ) | 1212 | if ( !nomaximize ) |
1213 | mw->showMaximized(); | 1213 | mw->showMaximized(); |
1214 | else | 1214 | else |
1215 | #endif | 1215 | #endif |
1216 | mw->show(); | 1216 | mw->show(); |
1217 | } | 1217 | } |
1218 | } else if ( d->keep_running ) { | 1218 | } else if ( d->keep_running ) { |
1219 | #ifdef Q_WS_QWS | 1219 | #ifdef Q_WS_QWS |
1220 | if ( !nomaximize ) | 1220 | if ( !nomaximize ) |
1221 | mw->showMaximized(); | 1221 | mw->showMaximized(); |
1222 | else | 1222 | else |
1223 | #endif | 1223 | #endif |
1224 | mw->show(); | 1224 | mw->show(); |
1225 | } | 1225 | } |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | /*! | 1228 | /*! |
1229 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1229 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1230 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1230 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1231 | 1231 | ||
1232 | This calls designates the application as | 1232 | This calls designates the application as |
1233 | a \link docwidget.html document-oriented\endlink application. | 1233 | a \link docwidget.html document-oriented\endlink application. |
1234 | 1234 | ||
1235 | The \a mw widget must have a slot: setDocument(const QString&). | 1235 | The \a mw widget must have a slot: setDocument(const QString&). |
1236 | 1236 | ||
1237 | \sa showMainWidget() | 1237 | \sa showMainWidget() |
1238 | */ | 1238 | */ |
1239 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1239 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1240 | { | 1240 | { |
1241 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1241 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1242 | 1242 | ||
1243 | if ( mw && argc() == 2 ) | 1243 | if ( mw && argc() == 2 ) |
1244 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1244 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1245 | d->nomaximize = nomaximize; | 1245 | d->nomaximize = nomaximize; |
1246 | d->qpe_main_widget = mw; | 1246 | d->qpe_main_widget = mw; |
1247 | d->sendQCopQ(); | 1247 | d->sendQCopQ(); |
1248 | if ( d->preloaded ) { | 1248 | if ( d->preloaded ) { |
1249 | if(d->forceshow) { | 1249 | if(d->forceshow) { |
1250 | #ifdef Q_WS_QWS | 1250 | #ifdef Q_WS_QWS |
1251 | if ( !nomaximize ) | 1251 | if ( !nomaximize ) |
1252 | mw->showMaximized(); | 1252 | mw->showMaximized(); |
1253 | else | 1253 | else |
1254 | #endif | 1254 | #endif |
1255 | mw->show(); | 1255 | mw->show(); |
1256 | } | 1256 | } |
1257 | } else if ( d->keep_running ) { | 1257 | } else if ( d->keep_running ) { |
1258 | #ifdef Q_WS_QWS | 1258 | #ifdef Q_WS_QWS |
1259 | if ( !nomaximize ) | 1259 | if ( !nomaximize ) |
1260 | mw->showMaximized(); | 1260 | mw->showMaximized(); |
1261 | else | 1261 | else |
1262 | #endif | 1262 | #endif |
1263 | mw->show(); | 1263 | mw->show(); |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | 1267 | ||
1268 | /*! | 1268 | /*! |
1269 | Sets that the application should continue running after processing | 1269 | Sets that the application should continue running after processing |
1270 | qcop messages. Normally if an application is started via a qcop message, | 1270 | qcop messages. Normally if an application is started via a qcop message, |
1271 | the application will process the qcop message and then quit. If while | 1271 | the application will process the qcop message and then quit. If while |
1272 | processing the qcop message it calls this function, then the application | 1272 | processing the qcop message it calls this function, then the application |
1273 | will show and start proper once it has finished processing qcop messages. | 1273 | will show and start proper once it has finished processing qcop messages. |
1274 | 1274 | ||
1275 | \sa keepRunning() | 1275 | \sa keepRunning() |
1276 | */ | 1276 | */ |
1277 | void QPEApplication::setKeepRunning() | 1277 | void QPEApplication::setKeepRunning() |
1278 | { | 1278 | { |
1279 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1279 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1280 | QPEApplication *qpeApp = (QPEApplication*)qApp; | 1280 | QPEApplication *qpeApp = (QPEApplication*)qApp; |
1281 | qpeApp->d->keep_running = TRUE; | 1281 | qpeApp->d->keep_running = TRUE; |
1282 | } | 1282 | } |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | /*! | 1285 | /*! |
1286 | Returns whether the application will quit after processing the current | 1286 | Returns whether the application will quit after processing the current |
1287 | list of qcop messages. | 1287 | list of qcop messages. |
1288 | 1288 | ||
1289 | \sa setKeepRunning() | 1289 | \sa setKeepRunning() |
1290 | */ | 1290 | */ |
1291 | bool QPEApplication::keepRunning() const | 1291 | bool QPEApplication::keepRunning() const |
1292 | { | 1292 | { |
1293 | return d->keep_running; | 1293 | return d->keep_running; |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | /*! | 1296 | /*! |
1297 | \internal | 1297 | \internal |
1298 | */ | 1298 | */ |
1299 | void QPEApplication::internalSetStyle( const QString &style ) | 1299 | void QPEApplication::internalSetStyle( const QString &style ) |
1300 | { | 1300 | { |
1301 | #if QT_VERSION >= 300 | 1301 | #if QT_VERSION >= 300 |
1302 | if ( style == "QPE" ) { | 1302 | if ( style == "QPE" ) { |
1303 | setStyle( new QPEStyle ); | 1303 | setStyle( new QPEStyle ); |
1304 | } else { | 1304 | } else { |
1305 | QStyle *s = QStyleFactory::create(style); | 1305 | QStyle *s = QStyleFactory::create(style); |
1306 | if ( s ) setStyle(s); | 1306 | if ( s ) setStyle(s); |
1307 | } | 1307 | } |
1308 | #else | 1308 | #else |
1309 | if ( style == "Windows" ) { | 1309 | if ( style == "Windows" ) { |
1310 | setStyle( new QWindowsStyle ); | 1310 | setStyle( new QWindowsStyle ); |
1311 | } else if ( style == "QPE" ) { | 1311 | } else if ( style == "QPE" ) { |
1312 | setStyle( new QPEStyle ); | 1312 | setStyle( new QPEStyle ); |
1313 | } else if ( style == "Light" ) { | 1313 | } else if ( style == "Light" ) { |
1314 | setStyle( new LightStyle ); | 1314 | setStyle( new LightStyle ); |
1315 | } | 1315 | } |
1316 | #ifndef QT_NO_STYLE_PLATINUM | 1316 | #ifndef QT_NO_STYLE_PLATINUM |
1317 | else if ( style == "Platinum" ) { | 1317 | else if ( style == "Platinum" ) { |
1318 | setStyle( new QPlatinumStyle ); | 1318 | setStyle( new QPlatinumStyle ); |
1319 | } | 1319 | } |
1320 | #endif | 1320 | #endif |
1321 | #ifndef QT_NO_STYLE_MOTIF | 1321 | #ifndef QT_NO_STYLE_MOTIF |
1322 | else if ( style == "Motif" ) { | 1322 | else if ( style == "Motif" ) { |
1323 | setStyle( new QMotifStyle ); | 1323 | setStyle( new QMotifStyle ); |
1324 | } | 1324 | } |
1325 | #endif | 1325 | #endif |
1326 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1326 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1327 | else if ( style == "MotifPlus" ) { | 1327 | else if ( style == "MotifPlus" ) { |
1328 | setStyle( new QMotifPlusStyle ); | 1328 | setStyle( new QMotifPlusStyle ); |
1329 | } | 1329 | } |
1330 | #endif | 1330 | #endif |
1331 | 1331 | ||
1332 | // HACK for Qt2 only | 1332 | // HACK for Qt2 only |
1333 | else { | 1333 | else { |
1334 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" | 1334 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" |
1335 | 1335 | ||
1336 | int p2 = style. findRev ( ']' ); | 1336 | int p2 = style. findRev ( ']' ); |
1337 | int p1 = style. findRev ( '[' ); | 1337 | int p1 = style. findRev ( '[' ); |
1338 | QString style2; | 1338 | QString style2; |
1339 | 1339 | ||
1340 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) | 1340 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) |
1341 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; | 1341 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; |
1342 | else | 1342 | else |
1343 | style2 = "lib" + style. lower ( ) + ".so"; | 1343 | style2 = "lib" + style. lower ( ) + ".so"; |
1344 | 1344 | ||
1345 | // static QLibrary *currentlib = 0; | 1345 | // static QLibrary *currentlib = 0; |
1346 | static void *currentlib = 0; | 1346 | static void *currentlib = 0; |
1347 | 1347 | ||
1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; | 1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; |
1349 | 1349 | ||
1350 | do { // try/catch simulation | 1350 | do { // try/catch simulation |
1351 | // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); | 1351 | // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); |
1352 | void *lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | 1352 | void *lib = ::dlopen ( path. local8Bit ( ), RTLD_LAZY | RTLD_GLOBAL ); |
1353 | 1353 | ||
1354 | if ( lib ) { | 1354 | if ( lib ) { |
1355 | //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); | 1355 | //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); |
1356 | QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); | 1356 | QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); |
1357 | 1357 | ||
1358 | if ( fpa ) { | 1358 | if ( fpa ) { |
1359 | QStyle *sty = ( *fpa ) ( ); | 1359 | QStyle *sty = ( *fpa ) ( ); |
1360 | 1360 | ||
1361 | if ( sty ) { | 1361 | if ( sty ) { |
1362 | setStyle ( sty ); | 1362 | setStyle ( sty ); |
1363 | 1363 | ||
1364 | if ( currentlib ) { | 1364 | if ( currentlib ) { |
1365 | //delete currentlib; | 1365 | //delete currentlib; |
1366 | ::dlclose ( currentlib ); | 1366 | ::dlclose ( currentlib ); |
1367 | } | 1367 | } |
1368 | currentlib = lib; | 1368 | currentlib = lib; |
1369 | 1369 | ||
1370 | break; | 1370 | break; |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | //delete lib; | 1373 | //delete lib; |
1374 | ::dlclose ( lib ); | 1374 | ::dlclose ( lib ); |
1375 | } | 1375 | } |
1376 | } while ( false ); | 1376 | } while ( false ); |
1377 | } | 1377 | } |
1378 | // HACK for Qt2 only | 1378 | // HACK for Qt2 only |
1379 | #endif | 1379 | #endif |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | /*! | 1382 | /*! |
1383 | \internal | 1383 | \internal |
1384 | */ | 1384 | */ |
1385 | void QPEApplication::prepareForTermination(bool willrestart) | 1385 | void QPEApplication::prepareForTermination(bool willrestart) |
1386 | { | 1386 | { |
1387 | if ( willrestart ) { | 1387 | if ( willrestart ) { |
1388 | // Draw a big wait icon, the image can be altered in later revisions | 1388 | // Draw a big wait icon, the image can be altered in later revisions |
1389 | // QWidget *d = QApplication::desktop(); | 1389 | // QWidget *d = QApplication::desktop(); |
1390 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1390 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1391 | QPixmap pix; | 1391 | QPixmap pix; |
1392 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); | 1392 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); |
1393 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | | 1393 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | |
1394 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1394 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1395 | lblWait->setPixmap( pix ); | 1395 | lblWait->setPixmap( pix ); |
1396 | lblWait->setAlignment( QWidget::AlignCenter ); | 1396 | lblWait->setAlignment( QWidget::AlignCenter ); |
1397 | lblWait->show(); | 1397 | lblWait->show(); |
1398 | lblWait->showMaximized(); | 1398 | lblWait->showMaximized(); |
1399 | } | 1399 | } |
1400 | #ifndef SINGLE_APP | 1400 | #ifndef SINGLE_APP |
1401 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } | 1401 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } |
1402 | processEvents(); // ensure the message goes out. | 1402 | processEvents(); // ensure the message goes out. |
1403 | sleep(1); // You have 1 second to comply. | 1403 | sleep(1); // You have 1 second to comply. |
1404 | #endif | 1404 | #endif |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | /*! | 1407 | /*! |
1408 | \internal | 1408 | \internal |
1409 | */ | 1409 | */ |
1410 | void QPEApplication::shutdown() | 1410 | void QPEApplication::shutdown() |
1411 | { | 1411 | { |
1412 | // Implement in server's QPEApplication subclass | 1412 | // Implement in server's QPEApplication subclass |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | /*! | 1415 | /*! |
1416 | \internal | 1416 | \internal |
1417 | */ | 1417 | */ |
1418 | void QPEApplication::restart() | 1418 | void QPEApplication::restart() |
1419 | { | 1419 | { |
1420 | // Implement in server's QPEApplication subclass | 1420 | // Implement in server's QPEApplication subclass |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | static QPtrDict<void>* stylusDict=0; | 1423 | static QPtrDict<void>* stylusDict=0; |
1424 | static void createDict() | 1424 | static void createDict() |
1425 | { | 1425 | { |
1426 | if ( !stylusDict ) | 1426 | if ( !stylusDict ) |
1427 | stylusDict = new QPtrDict<void>; | 1427 | stylusDict = new QPtrDict<void>; |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | /*! | 1430 | /*! |
1431 | Returns the current StylusMode for \a w. | 1431 | Returns the current StylusMode for \a w. |
1432 | 1432 | ||
1433 | \sa setStylusOperation() | 1433 | \sa setStylusOperation() |
1434 | */ | 1434 | */ |
1435 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1435 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1436 | { | 1436 | { |
1437 | if ( stylusDict ) | 1437 | if ( stylusDict ) |
1438 | return (StylusMode)(int)stylusDict->find(w); | 1438 | return (StylusMode)(int)stylusDict->find(w); |
1439 | return LeftOnly; | 1439 | return LeftOnly; |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | /*! | 1442 | /*! |
1443 | \enum QPEApplication::StylusMode | 1443 | \enum QPEApplication::StylusMode |
1444 | 1444 | ||
1445 | \value LeftOnly the stylus only generates LeftButton | 1445 | \value LeftOnly the stylus only generates LeftButton |
1446 | events (the default). | 1446 | events (the default). |
1447 | \value RightOnHold the stylus generates RightButton events | 1447 | \value RightOnHold the stylus generates RightButton events |
1448 | if the user uses the press-and-hold gesture. | 1448 | if the user uses the press-and-hold gesture. |
1449 | 1449 | ||
1450 | See setStylusOperation(). | 1450 | See setStylusOperation(). |
1451 | */ | 1451 | */ |
1452 | 1452 | ||
1453 | /*! | 1453 | /*! |
1454 | Causes \a w to receive mouse events according to \a mode. | 1454 | Causes \a w to receive mouse events according to \a mode. |
1455 | 1455 | ||
1456 | \sa stylusOperation() | 1456 | \sa stylusOperation() |
1457 | */ | 1457 | */ |
1458 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) | 1458 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) |
1459 | { | 1459 | { |
1460 | createDict(); | 1460 | createDict(); |
1461 | if ( mode == LeftOnly ) { | 1461 | if ( mode == LeftOnly ) { |
1462 | stylusDict->remove(w); | 1462 | stylusDict->remove(w); |
1463 | w->removeEventFilter(qApp); | 1463 | w->removeEventFilter(qApp); |
1464 | } else { | 1464 | } else { |
1465 | stylusDict->insert(w,(void*)mode); | 1465 | stylusDict->insert(w,(void*)mode); |
1466 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); | 1466 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); |
1467 | w->installEventFilter(qApp); | 1467 | w->installEventFilter(qApp); |
1468 | } | 1468 | } |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | 1471 | ||
1472 | /*! | 1472 | /*! |
1473 | \reimp | 1473 | \reimp |
1474 | */ | 1474 | */ |
1475 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1475 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1476 | { | 1476 | { |
1477 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1477 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1478 | QMouseEvent* me = (QMouseEvent*)e; | 1478 | QMouseEvent* me = (QMouseEvent*)e; |
1479 | if ( me->button() == LeftButton ) { | 1479 | if ( me->button() == LeftButton ) { |
1480 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1480 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1481 | switch (mode) { | 1481 | switch (mode) { |
1482 | case RightOnHold: | 1482 | case RightOnHold: |
1483 | switch ( me->type() ) { | 1483 | switch ( me->type() ) { |
1484 | case QEvent::MouseButtonPress: | 1484 | case QEvent::MouseButtonPress: |
1485 | d->presstimer = startTimer(500); // #### pref. | 1485 | d->presstimer = startTimer(500); // #### pref. |
1486 | d->presswidget = (QWidget*)o; | 1486 | d->presswidget = (QWidget*)o; |
1487 | d->presspos = me->pos(); | 1487 | d->presspos = me->pos(); |
1488 | d->rightpressed = FALSE; | 1488 | d->rightpressed = FALSE; |
1489 | break; | 1489 | break; |
1490 | case QEvent::MouseButtonRelease: | 1490 | case QEvent::MouseButtonRelease: |
1491 | if ( d->presstimer ) { | 1491 | if ( d->presstimer ) { |
1492 | killTimer(d->presstimer); | 1492 | killTimer(d->presstimer); |
1493 | d->presstimer = 0; | 1493 | d->presstimer = 0; |
1494 | } | 1494 | } |
1495 | if ( d->rightpressed && d->presswidget ) { | 1495 | if ( d->rightpressed && d->presswidget ) { |
1496 | // Right released | 1496 | // Right released |
1497 | postEvent( d->presswidget, | 1497 | postEvent( d->presswidget, |
1498 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1498 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1499 | RightButton, LeftButton+RightButton ) ); | 1499 | RightButton, LeftButton+RightButton ) ); |
1500 | // Left released, off-widget | 1500 | // Left released, off-widget |
1501 | postEvent( d->presswidget, | 1501 | postEvent( d->presswidget, |
1502 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1502 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1503 | LeftButton, LeftButton ) ); | 1503 | LeftButton, LeftButton ) ); |
1504 | postEvent( d->presswidget, | 1504 | postEvent( d->presswidget, |
1505 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1505 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1506 | LeftButton, LeftButton ) ); | 1506 | LeftButton, LeftButton ) ); |
1507 | d->rightpressed = FALSE; | 1507 | d->rightpressed = FALSE; |
1508 | return TRUE; // don't send the real Left release | 1508 | return TRUE; // don't send the real Left release |
1509 | } | 1509 | } |
1510 | break; | 1510 | break; |
1511 | default: | 1511 | default: |
1512 | break; | 1512 | break; |
1513 | } | 1513 | } |
1514 | break; | 1514 | break; |
1515 | default: | 1515 | default: |
1516 | ; | 1516 | ; |
1517 | } | 1517 | } |
1518 | } | 1518 | } |
1519 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1519 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1520 | QKeyEvent *ke = (QKeyEvent *)e; | 1520 | QKeyEvent *ke = (QKeyEvent *)e; |
1521 | if ( ke->key() == Key_Enter ) { | 1521 | if ( ke->key() == Key_Enter ) { |
1522 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1522 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1523 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1523 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1524 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1524 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1525 | return TRUE; | 1525 | return TRUE; |
1526 | } | 1526 | } |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | return FALSE; | 1530 | return FALSE; |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | /*! | 1533 | /*! |
1534 | \reimp | 1534 | \reimp |
1535 | */ | 1535 | */ |
1536 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1536 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1537 | { | 1537 | { |
1538 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1538 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1539 | // Right pressed | 1539 | // Right pressed |
1540 | postEvent( d->presswidget, | 1540 | postEvent( d->presswidget, |
1541 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1541 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1542 | RightButton, LeftButton ) ); | 1542 | RightButton, LeftButton ) ); |
1543 | killTimer( d->presstimer ); | 1543 | killTimer( d->presstimer ); |
1544 | d->presstimer = 0; | 1544 | d->presstimer = 0; |
1545 | d->rightpressed = TRUE; | 1545 | d->rightpressed = TRUE; |
1546 | } | 1546 | } |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | void QPEApplication::removeSenderFromStylusDict() | 1549 | void QPEApplication::removeSenderFromStylusDict() |
1550 | { | 1550 | { |
1551 | stylusDict->remove((void*)sender()); | 1551 | stylusDict->remove((void*)sender()); |
1552 | if ( d->presswidget == sender() ) | 1552 | if ( d->presswidget == sender() ) |
1553 | d->presswidget = 0; | 1553 | d->presswidget = 0; |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | /*! | 1556 | /*! |
1557 | \internal | 1557 | \internal |
1558 | */ | 1558 | */ |
1559 | bool QPEApplication::keyboardGrabbed() const | 1559 | bool QPEApplication::keyboardGrabbed() const |
1560 | { | 1560 | { |
1561 | return d->kbgrabber; | 1561 | return d->kbgrabber; |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | 1564 | ||
1565 | /*! | 1565 | /*! |
1566 | Reverses the effect of grabKeyboard(). This is called automatically | 1566 | Reverses the effect of grabKeyboard(). This is called automatically |
1567 | on program exit. | 1567 | on program exit. |
1568 | */ | 1568 | */ |
1569 | void QPEApplication::ungrabKeyboard() | 1569 | void QPEApplication::ungrabKeyboard() |
1570 | { | 1570 | { |
1571 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; | 1571 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; |
1572 | if ( d->kbgrabber == 2 ) { | 1572 | if ( d->kbgrabber == 2 ) { |
1573 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 1573 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
1574 | e << QString::null; | 1574 | e << QString::null; |
1575 | d->kbregrab = FALSE; | 1575 | d->kbregrab = FALSE; |
1576 | d->kbgrabber = 0; | 1576 | d->kbgrabber = 0; |
1577 | } | 1577 | } |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | /*! | 1580 | /*! |
1581 | Grabs the keyboard such that the system's application launching | 1581 | Grabs the keyboard such that the system's application launching |
1582 | keys no longer work, and instead they are receivable by this | 1582 | keys no longer work, and instead they are receivable by this |
1583 | application. | 1583 | application. |
1584 | 1584 | ||
1585 | \sa ungrabKeyboard() | 1585 | \sa ungrabKeyboard() |
1586 | */ | 1586 | */ |
1587 | void QPEApplication::grabKeyboard() | 1587 | void QPEApplication::grabKeyboard() |
1588 | { | 1588 | { |
1589 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; | 1589 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; |
1590 | if ( qApp->type() == QApplication::GuiServer ) | 1590 | if ( qApp->type() == QApplication::GuiServer ) |
1591 | d->kbgrabber = 0; | 1591 | d->kbgrabber = 0; |
1592 | else { | 1592 | else { |
1593 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 1593 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
1594 | e << d->appName; | 1594 | e << d->appName; |
1595 | d->kbgrabber = 2; // me | 1595 | d->kbgrabber = 2; // me |
1596 | } | 1596 | } |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | /*! | 1599 | /*! |
1600 | \reimp | 1600 | \reimp |
1601 | */ | 1601 | */ |
1602 | int QPEApplication::exec() | 1602 | int QPEApplication::exec() |
1603 | { | 1603 | { |
1604 | d->sendQCopQ(); | 1604 | d->sendQCopQ(); |
1605 | if ( d->keep_running) | 1605 | if ( d->keep_running) |
1606 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1606 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1607 | return QApplication::exec(); | 1607 | return QApplication::exec(); |
1608 | 1608 | ||
1609 | { | 1609 | { |
1610 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1610 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1611 | e << d->appName; | 1611 | e << d->appName; |
1612 | } | 1612 | } |
1613 | processEvents(); | 1613 | processEvents(); |
1614 | return 0; | 1614 | return 0; |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | /*! | 1617 | /*! |
1618 | \internal | 1618 | \internal |
1619 | External request for application to quit. Quits if possible without | 1619 | External request for application to quit. Quits if possible without |
1620 | loosing state. | 1620 | loosing state. |
1621 | */ | 1621 | */ |
1622 | void QPEApplication::tryQuit() | 1622 | void QPEApplication::tryQuit() |
1623 | { | 1623 | { |
1624 | if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) | 1624 | if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) |
1625 | return; // Inside modal loop or konsole. Too hard to save state. | 1625 | return; // Inside modal loop or konsole. Too hard to save state. |
1626 | { | 1626 | { |
1627 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1627 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1628 | e << d->appName; | 1628 | e << d->appName; |
1629 | } | 1629 | } |
1630 | processEvents(); | 1630 | processEvents(); |
1631 | 1631 | ||
1632 | quit(); | 1632 | quit(); |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | /*! | 1635 | /*! |
1636 | \internal | 1636 | \internal |
1637 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1637 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1638 | hiding the window. If not it means quitting the application. | 1638 | hiding the window. If not it means quitting the application. |
1639 | As this is user initiated we don't need to check state. | 1639 | As this is user initiated we don't need to check state. |
1640 | */ | 1640 | */ |
1641 | void QPEApplication::hideOrQuit() | 1641 | void QPEApplication::hideOrQuit() |
1642 | { | 1642 | { |
1643 | // notify of our demise :) | 1643 | // notify of our demise :) |
1644 | { | 1644 | { |
1645 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1645 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1646 | e << d->appName; | 1646 | e << d->appName; |
1647 | } | 1647 | } |
1648 | processEvents(); | 1648 | processEvents(); |
1649 | if ( d->preloaded && d->qpe_main_widget ) | 1649 | if ( d->preloaded && d->qpe_main_widget ) |
1650 | d->qpe_main_widget->hide(); | 1650 | d->qpe_main_widget->hide(); |
1651 | else | 1651 | else |
1652 | quit(); | 1652 | quit(); |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1655 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1656 | 1656 | ||
1657 | // The libraries with the skiff package (and possibly others) have | 1657 | // The libraries with the skiff package (and possibly others) have |
1658 | // completely useless implementations of builtin new and delete that | 1658 | // completely useless implementations of builtin new and delete that |
1659 | // use about 50% of your CPU. Here we revert to the simple libc | 1659 | // use about 50% of your CPU. Here we revert to the simple libc |
1660 | // functions. | 1660 | // functions. |
1661 | 1661 | ||
1662 | void* operator new[](size_t size) | 1662 | void* operator new[](size_t size) |
1663 | { | 1663 | { |
1664 | return malloc(size); | 1664 | return malloc(size); |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | void* operator new(size_t size) | 1667 | void* operator new(size_t size) |
1668 | { | 1668 | { |
1669 | return malloc(size); | 1669 | return malloc(size); |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | void operator delete[](void* p) | 1672 | void operator delete[](void* p) |
1673 | { | 1673 | { |
1674 | free(p); | 1674 | free(p); |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | void operator delete[](void* p, size_t /*size*/) | 1677 | void operator delete[](void* p, size_t /*size*/) |
1678 | { | 1678 | { |
1679 | free(p); | 1679 | free(p); |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void operator delete(void* p) | 1682 | void operator delete(void* p) |
1683 | { | 1683 | { |
1684 | free(p); | 1684 | free(p); |
1685 | } | 1685 | } |
1686 | 1686 | ||
1687 | void operator delete(void* p, size_t /*size*/) | 1687 | void operator delete(void* p, size_t /*size*/) |
1688 | { | 1688 | { |
1689 | free(p); | 1689 | free(p); |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | #endif | 1692 | #endif |
1693 | 1693 | ||
1694 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1694 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1695 | #include <qwidgetlist.h> | 1695 | #include <qwidgetlist.h> |
1696 | #include <qgfx_qws.h> | 1696 | #include <qgfx_qws.h> |
1697 | extern QRect qt_maxWindowRect; | 1697 | extern QRect qt_maxWindowRect; |
1698 | void qt_setMaxWindowRect(const QRect& r) | 1698 | void qt_setMaxWindowRect(const QRect& r) |
1699 | { | 1699 | { |
1700 | qt_maxWindowRect = qt_screen->mapFromDevice(r, | 1700 | qt_maxWindowRect = qt_screen->mapFromDevice(r, |
1701 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); | 1701 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); |
1702 | // Re-resize any maximized windows | 1702 | // Re-resize any maximized windows |
1703 | QWidgetList* l = QApplication::topLevelWidgets(); | 1703 | QWidgetList* l = QApplication::topLevelWidgets(); |
1704 | if ( l ) { | 1704 | if ( l ) { |
1705 | QWidget *w = l->first(); | 1705 | QWidget *w = l->first(); |
1706 | while ( w ) { | 1706 | while ( w ) { |
1707 | if ( w->isVisible() && w->isMaximized() ) | 1707 | if ( w->isVisible() && w->isMaximized() ) |
1708 | { | 1708 | { |
1709 | w->showMaximized(); | 1709 | w->showMaximized(); |
1710 | } | 1710 | } |
1711 | w = l->next(); | 1711 | w = l->next(); |
1712 | } | 1712 | } |
1713 | delete l; | 1713 | delete l; |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | #endif | 1716 | #endif |