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 | |||
@@ -1096,513 +1096,513 @@ bool QPEApplication::raiseAppropriateWindow() | |||
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 | ||