author | zecke <zecke> | 2004-10-15 21:04:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-15 21:04:08 (UTC) |
commit | 0bdebb46227ea403a07707cf0a967c8ea036e03f (patch) (unidiff) | |
tree | d6e724a055475f3938ee5a8955692209d490ba37 /library/qpeapplication.cpp | |
parent | ac36bfe2794741188da1d6d4b471f96fd15d47ee (diff) | |
download | opie-0bdebb46227ea403a07707cf0a967c8ea036e03f.zip opie-0bdebb46227ea403a07707cf0a967c8ea036e03f.tar.gz opie-0bdebb46227ea403a07707cf0a967c8ea036e03f.tar.bz2 |
Make sure that qpeDir() has a QDir::seperator() as last character. This code
comes from Qtopia1.7
Conversion to it is done by myself
-rw-r--r-- | library/qpeapplication.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 3efba20..0b6d56d 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -328,158 +328,158 @@ public: | |||
328 | // get the non-maximized version, so we have to do it the hard way ) | 328 | // get the non-maximized version, so we have to do it the hard way ) |
329 | int offsetX = w->x() - w->geometry().left(); | 329 | int offsetX = w->x() - w->geometry().left(); |
330 | int offsetY = w->y() - w->geometry().top(); | 330 | int offsetY = w->y() - w->geometry().top(); |
331 | 331 | ||
332 | QRect r; | 332 | QRect r; |
333 | if ( w->isMaximized() ) | 333 | if ( w->isMaximized() ) |
334 | r = ( (HackWidget *) w)->normalGeometry(); | 334 | r = ( (HackWidget *) w)->normalGeometry(); |
335 | else | 335 | else |
336 | r = w->geometry(); | 336 | r = w->geometry(); |
337 | 337 | ||
338 | // Stores the window placement as pos(), size() (due to the offset mapping) | 338 | // Stores the window placement as pos(), size() (due to the offset mapping) |
339 | Config cfg( "qpe" ); | 339 | Config cfg( "qpe" ); |
340 | cfg.setGroup("ApplicationPositions"); | 340 | cfg.setGroup("ApplicationPositions"); |
341 | QString s; | 341 | QString s; |
342 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 342 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
343 | cfg.writeEntry( app, s ); | 343 | cfg.writeEntry( app, s ); |
344 | } | 344 | } |
345 | 345 | ||
346 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 346 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
347 | { | 347 | { |
348 | /* | 348 | /* |
349 | // This works but disable it for now until it is safe to apply | 349 | // This works but disable it for now until it is safe to apply |
350 | // What is does is scan the .desktop files of all the apps for | 350 | // What is does is scan the .desktop files of all the apps for |
351 | // the applnk that has the corresponding argv[0] as this program | 351 | // the applnk that has the corresponding argv[0] as this program |
352 | // then it uses the name stored in the .desktop file as the caption | 352 | // then it uses the name stored in the .desktop file as the caption |
353 | // for the main widget. This saves duplicating translations for | 353 | // for the main widget. This saves duplicating translations for |
354 | // the app name in the program and in the .desktop files. | 354 | // the app name in the program and in the .desktop files. |
355 | 355 | ||
356 | AppLnkSet apps( appsPath ); | 356 | AppLnkSet apps( appsPath ); |
357 | 357 | ||
358 | QList<AppLnk> appsList = apps.children(); | 358 | QList<AppLnk> appsList = apps.children(); |
359 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 359 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
360 | if ( (*it)->exec() == appName ) { | 360 | if ( (*it)->exec() == appName ) { |
361 | mw->setCaption( (*it)->name() ); | 361 | mw->setCaption( (*it)->name() ); |
362 | return TRUE; | 362 | return TRUE; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | */ | 365 | */ |
366 | return FALSE; | 366 | return FALSE; |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void show(QWidget* mw, bool nomax) | 370 | void show(QWidget* mw, bool nomax) |
371 | { | 371 | { |
372 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 372 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
373 | nomaximize = nomax; | 373 | nomaximize = nomax; |
374 | qpe_main_widget = mw; | 374 | qpe_main_widget = mw; |
375 | qcopQok = TRUE; | 375 | qcopQok = TRUE; |
376 | #ifndef QT_NO_COP | 376 | #ifndef QT_NO_COP |
377 | 377 | ||
378 | sendQCopQ(); | 378 | sendQCopQ(); |
379 | #endif | 379 | #endif |
380 | 380 | ||
381 | if ( preloaded ) { | 381 | if ( preloaded ) { |
382 | if (forceshow) | 382 | if (forceshow) |
383 | show_mx(mw, nomax, appName); | 383 | show_mx(mw, nomax, appName); |
384 | } | 384 | } |
385 | else if ( keep_running ) { | 385 | else if ( keep_running ) { |
386 | show_mx(mw, nomax, appName); | 386 | show_mx(mw, nomax, appName); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
390 | void loadTextCodecs() | 390 | void loadTextCodecs() |
391 | { | 391 | { |
392 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 392 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; |
393 | #ifdef Q_OS_MACX | 393 | #ifdef Q_OS_MACX |
394 | QDir dir( path, "lib*.dylib" ); | 394 | QDir dir( path, "lib*.dylib" ); |
395 | #else | 395 | #else |
396 | QDir dir( path, "lib*.so" ); | 396 | QDir dir( path, "lib*.so" ); |
397 | #endif | 397 | #endif |
398 | QStringList list; | 398 | QStringList list; |
399 | if ( dir. exists ( )) | 399 | if ( dir. exists ( )) |
400 | list = dir.entryList(); | 400 | list = dir.entryList(); |
401 | QStringList::Iterator it; | 401 | QStringList::Iterator it; |
402 | for ( it = list.begin(); it != list.end(); ++it ) { | 402 | for ( it = list.begin(); it != list.end(); ++it ) { |
403 | TextCodecInterface *iface = 0; | 403 | TextCodecInterface *iface = 0; |
404 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 404 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
405 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 405 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
406 | QValueList<int> mibs = iface->mibEnums(); | 406 | QValueList<int> mibs = iface->mibEnums(); |
407 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 407 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
408 | (void)iface->createForMib(*i); | 408 | (void)iface->createForMib(*i); |
409 | // ### it exists now; need to remember if we can delete it | 409 | // ### it exists now; need to remember if we can delete it |
410 | } | 410 | } |
411 | } | 411 | } |
412 | else { | 412 | else { |
413 | lib->unload(); | 413 | lib->unload(); |
414 | delete lib; | 414 | delete lib; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | void loadImageCodecs() | 419 | void loadImageCodecs() |
420 | { | 420 | { |
421 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 421 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; |
422 | #ifdef Q_OS_MACX | 422 | #ifdef Q_OS_MACX |
423 | QDir dir( path, "lib*.dylib" ); | 423 | QDir dir( path, "lib*.dylib" ); |
424 | #else | 424 | #else |
425 | QDir dir( path, "lib*.so" ); | 425 | QDir dir( path, "lib*.so" ); |
426 | #endif | 426 | #endif |
427 | QStringList list; | 427 | QStringList list; |
428 | if ( dir. exists ( )) | 428 | if ( dir. exists ( )) |
429 | list = dir.entryList(); | 429 | list = dir.entryList(); |
430 | QStringList::Iterator it; | 430 | QStringList::Iterator it; |
431 | for ( it = list.begin(); it != list.end(); ++it ) { | 431 | for ( it = list.begin(); it != list.end(); ++it ) { |
432 | ImageCodecInterface *iface = 0; | 432 | ImageCodecInterface *iface = 0; |
433 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 433 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
434 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 434 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
435 | QStringList formats = iface->keys(); | 435 | QStringList formats = iface->keys(); |
436 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 436 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
437 | (void)iface->installIOHandler(*i); | 437 | (void)iface->installIOHandler(*i); |
438 | // ### it exists now; need to remember if we can delete it | 438 | // ### it exists now; need to remember if we can delete it |
439 | } | 439 | } |
440 | } | 440 | } |
441 | else { | 441 | else { |
442 | lib->unload(); | 442 | lib->unload(); |
443 | delete lib; | 443 | delete lib; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | }; | 448 | }; |
449 | 449 | ||
450 | class ResourceMimeFactory : public QMimeSourceFactory | 450 | class ResourceMimeFactory : public QMimeSourceFactory |
451 | { | 451 | { |
452 | public: | 452 | public: |
453 | ResourceMimeFactory() : resImage( 0 ) | 453 | ResourceMimeFactory() : resImage( 0 ) |
454 | { | 454 | { |
455 | setFilePath( Global::helpPath() ); | 455 | setFilePath( Global::helpPath() ); |
456 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 456 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
457 | } | 457 | } |
458 | ~ResourceMimeFactory() { | 458 | ~ResourceMimeFactory() { |
459 | delete resImage; | 459 | delete resImage; |
460 | } | 460 | } |
461 | 461 | ||
462 | const QMimeSource* data( const QString& abs_name ) const | 462 | const QMimeSource* data( const QString& abs_name ) const |
463 | { | 463 | { |
464 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 464 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
465 | if ( !r ) { | 465 | if ( !r ) { |
466 | int sl = abs_name.length(); | 466 | int sl = abs_name.length(); |
467 | do { | 467 | do { |
468 | sl = abs_name.findRev( '/', sl - 1 ); | 468 | sl = abs_name.findRev( '/', sl - 1 ); |
469 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 469 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
470 | int dot = name.findRev( '.' ); | 470 | int dot = name.findRev( '.' ); |
471 | if ( dot >= 0 ) | 471 | if ( dot >= 0 ) |
472 | name = name.left( dot ); | 472 | name = name.left( dot ); |
473 | QImage img = Resource::loadImage( name ); | 473 | QImage img = Resource::loadImage( name ); |
474 | if ( !img.isNull() ) { | 474 | if ( !img.isNull() ) { |
475 | delete resImage; | 475 | delete resImage; |
476 | resImage = new QImageDrag( img ); | 476 | resImage = new QImageDrag( img ); |
477 | r = resImage; | 477 | r = resImage; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | while ( !r && sl > 0 ); | 480 | while ( !r && sl > 0 ); |
481 | } | 481 | } |
482 | return r; | 482 | return r; |
483 | } | 483 | } |
484 | private: | 484 | private: |
485 | mutable QImageDrag *resImage; | 485 | mutable QImageDrag *resImage; |
@@ -1126,133 +1126,146 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
1126 | } | 1126 | } |
1127 | else { // we didn't grab the keyboard, so send the event to the launcher | 1127 | else { // we didn't grab the keyboard, so send the event to the launcher |
1128 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1128 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1129 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1129 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | return true; | 1132 | return true; |
1133 | } | 1133 | } |
1134 | } | 1134 | } |
1135 | if ( e->type == QWSEvent::Focus ) { | 1135 | if ( e->type == QWSEvent::Focus ) { |
1136 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1136 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1137 | if ( !fe->simpleData.get_focus ) { | 1137 | if ( !fe->simpleData.get_focus ) { |
1138 | QWidget * active = activeWindow(); | 1138 | QWidget * active = activeWindow(); |
1139 | while ( active && active->isPopup() ) { | 1139 | while ( active && active->isPopup() ) { |
1140 | active->close(); | 1140 | active->close(); |
1141 | active = activeWindow(); | 1141 | active = activeWindow(); |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | else { | 1144 | else { |
1145 | // make sure our modal widget is ALWAYS on top | 1145 | // make sure our modal widget is ALWAYS on top |
1146 | QWidget *topm = activeModalWidget(); | 1146 | QWidget *topm = activeModalWidget(); |
1147 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1147 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1148 | topm->raise(); | 1148 | topm->raise(); |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1151 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1152 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1152 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1153 | if ( m == AlwaysOff ) | 1153 | if ( m == AlwaysOff ) |
1154 | Global::hideInputMethod(); | 1154 | Global::hideInputMethod(); |
1155 | if ( m == AlwaysOn ) | 1155 | if ( m == AlwaysOn ) |
1156 | Global::showInputMethod(); | 1156 | Global::showInputMethod(); |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | 1160 | ||
1161 | return QApplication::qwsEventFilter( e ); | 1161 | return QApplication::qwsEventFilter( e ); |
1162 | } | 1162 | } |
1163 | #endif | 1163 | #endif |
1164 | 1164 | ||
1165 | /*! | 1165 | /*! |
1166 | Destroys the QPEApplication. | 1166 | Destroys the QPEApplication. |
1167 | */ | 1167 | */ |
1168 | QPEApplication::~QPEApplication() | 1168 | QPEApplication::~QPEApplication() |
1169 | { | 1169 | { |
1170 | ungrabKeyboard(); | 1170 | ungrabKeyboard(); |
1171 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1171 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1172 | // Need to delete QCopChannels early, since the display will | 1172 | // Need to delete QCopChannels early, since the display will |
1173 | // be gone by the time we get to ~QObject(). | 1173 | // be gone by the time we get to ~QObject(). |
1174 | delete sysChannel; | 1174 | delete sysChannel; |
1175 | delete pidChannel; | 1175 | delete pidChannel; |
1176 | #endif | 1176 | #endif |
1177 | 1177 | ||
1178 | #ifdef OPIE_WITHROHFEEDBACK | 1178 | #ifdef OPIE_WITHROHFEEDBACK |
1179 | if( d->RoH ) | 1179 | if( d->RoH ) |
1180 | delete d->RoH; | 1180 | delete d->RoH; |
1181 | #endif | 1181 | #endif |
1182 | delete d; | 1182 | delete d; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | /*! | 1185 | /*! |
1186 | Returns <tt>$OPIEDIR/</tt>. | 1186 | Returns <tt>$OPIEDIR/</tt>. |
1187 | */ | 1187 | */ |
1188 | QString QPEApplication::qpeDir() | 1188 | QString QPEApplication::qpeDir() |
1189 | { | 1189 | { |
1190 | const char * base = getenv( "OPIEDIR" ); | 1190 | QString base, dir; |
1191 | if ( base ) | 1191 | |
1192 | return QString( base ) + "/"; | 1192 | if (getenv( "OPIEDIR" )) |
1193 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); | ||
1194 | if ( !base.isNull() && (base.length() > 0 )){ | ||
1195 | #ifdef Q_OS_WIN32 | ||
1196 | QString temp(base); | ||
1197 | if (temp[(int)temp.length()-1] != QDir::separator()) | ||
1198 | temp.append(QDir::separator()); | ||
1199 | dir = temp; | ||
1200 | #else | ||
1201 | dir = QString( base ) + "/"; | ||
1202 | #endif | ||
1203 | }else{ | ||
1204 | dir = QString( ".." ) + QDir::separator(); | ||
1205 | } | ||
1193 | 1206 | ||
1194 | return QString( "../" ); | 1207 | return dir; |
1195 | } | 1208 | } |
1196 | 1209 | ||
1197 | /*! | 1210 | /*! |
1198 | Returns the user's current Document directory. There is a trailing "/". | 1211 | Returns the user's current Document directory. There is a trailing "/". |
1199 | .. well, it does now,, and there's no trailing '/' | 1212 | .. well, it does now,, and there's no trailing '/' |
1200 | */ | 1213 | */ |
1201 | QString QPEApplication::documentDir() | 1214 | QString QPEApplication::documentDir() |
1202 | { | 1215 | { |
1203 | const char* base = getenv( "HOME"); | 1216 | const char* base = getenv( "HOME"); |
1204 | if ( base ) | 1217 | if ( base ) |
1205 | return QString( base ) + "/Documents"; | 1218 | return QString( base ) + "/Documents"; |
1206 | 1219 | ||
1207 | return QString( "../Documents" ); | 1220 | return QString( "../Documents" ); |
1208 | } | 1221 | } |
1209 | 1222 | ||
1210 | static int deforient = -1; | 1223 | static int deforient = -1; |
1211 | 1224 | ||
1212 | /*! | 1225 | /*! |
1213 | \internal | 1226 | \internal |
1214 | */ | 1227 | */ |
1215 | int QPEApplication::defaultRotation() | 1228 | int QPEApplication::defaultRotation() |
1216 | { | 1229 | { |
1217 | if ( deforient < 0 ) { | 1230 | if ( deforient < 0 ) { |
1218 | QString d = getenv( "QWS_DISPLAY" ); | 1231 | QString d = getenv( "QWS_DISPLAY" ); |
1219 | if ( d.contains( "Rot90" ) ) { | 1232 | if ( d.contains( "Rot90" ) ) { |
1220 | deforient = 90; | 1233 | deforient = 90; |
1221 | } | 1234 | } |
1222 | else if ( d.contains( "Rot180" ) ) { | 1235 | else if ( d.contains( "Rot180" ) ) { |
1223 | deforient = 180; | 1236 | deforient = 180; |
1224 | } | 1237 | } |
1225 | else if ( d.contains( "Rot270" ) ) { | 1238 | else if ( d.contains( "Rot270" ) ) { |
1226 | deforient = 270; | 1239 | deforient = 270; |
1227 | } | 1240 | } |
1228 | else { | 1241 | else { |
1229 | deforient = 0; | 1242 | deforient = 0; |
1230 | } | 1243 | } |
1231 | } | 1244 | } |
1232 | return deforient; | 1245 | return deforient; |
1233 | } | 1246 | } |
1234 | 1247 | ||
1235 | /*! | 1248 | /*! |
1236 | \internal | 1249 | \internal |
1237 | */ | 1250 | */ |
1238 | void QPEApplication::setDefaultRotation( int r ) | 1251 | void QPEApplication::setDefaultRotation( int r ) |
1239 | { | 1252 | { |
1240 | if ( qApp->type() == GuiServer ) { | 1253 | if ( qApp->type() == GuiServer ) { |
1241 | deforient = r; | 1254 | deforient = r; |
1242 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1255 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1243 | Config config("qpe"); | 1256 | Config config("qpe"); |
1244 | config.setGroup( "Rotation" ); | 1257 | config.setGroup( "Rotation" ); |
1245 | config.writeEntry( "Rot", r ); | 1258 | config.writeEntry( "Rot", r ); |
1246 | } | 1259 | } |
1247 | else { | 1260 | else { |
1248 | #ifndef QT_NO_COP | 1261 | #ifndef QT_NO_COP |
1249 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1262 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1250 | e << r; | 1263 | e << r; |
1251 | } | 1264 | } |
1252 | #endif | 1265 | #endif |
1253 | 1266 | ||
1254 | } | 1267 | } |
1255 | } | 1268 | } |
1256 | 1269 | ||
1257 | #include <qgfx_qws.h> | 1270 | #include <qgfx_qws.h> |
1258 | #include <qwindowsystem_qws.h> | 1271 | #include <qwindowsystem_qws.h> |
@@ -1774,129 +1787,129 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | |||
1774 | 1787 | ||
1775 | \sa keepRunning() | 1788 | \sa keepRunning() |
1776 | */ | 1789 | */ |
1777 | void QPEApplication::setKeepRunning() | 1790 | void QPEApplication::setKeepRunning() |
1778 | { | 1791 | { |
1779 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1792 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1780 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1793 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1781 | qpeApp->d->keep_running = TRUE; | 1794 | qpeApp->d->keep_running = TRUE; |
1782 | } | 1795 | } |
1783 | } | 1796 | } |
1784 | 1797 | ||
1785 | /*! | 1798 | /*! |
1786 | Returns TRUE if the application will quit after processing the | 1799 | Returns TRUE if the application will quit after processing the |
1787 | current list of qcop messages; otherwise returns FALSE. | 1800 | current list of qcop messages; otherwise returns FALSE. |
1788 | 1801 | ||
1789 | \sa setKeepRunning() | 1802 | \sa setKeepRunning() |
1790 | */ | 1803 | */ |
1791 | bool QPEApplication::keepRunning() const | 1804 | bool QPEApplication::keepRunning() const |
1792 | { | 1805 | { |
1793 | return d->keep_running; | 1806 | return d->keep_running; |
1794 | } | 1807 | } |
1795 | 1808 | ||
1796 | /*! | 1809 | /*! |
1797 | \internal | 1810 | \internal |
1798 | */ | 1811 | */ |
1799 | void QPEApplication::internalSetStyle( const QString &style ) | 1812 | void QPEApplication::internalSetStyle( const QString &style ) |
1800 | { | 1813 | { |
1801 | #if QT_VERSION >= 300 | 1814 | #if QT_VERSION >= 300 |
1802 | if ( style == "QPE" ) { | 1815 | if ( style == "QPE" ) { |
1803 | setStyle( new QPEStyle ); | 1816 | setStyle( new QPEStyle ); |
1804 | } | 1817 | } |
1805 | else { | 1818 | else { |
1806 | QStyle *s = QStyleFactory::create( style ); | 1819 | QStyle *s = QStyleFactory::create( style ); |
1807 | if ( s ) | 1820 | if ( s ) |
1808 | setStyle( s ); | 1821 | setStyle( s ); |
1809 | } | 1822 | } |
1810 | #else | 1823 | #else |
1811 | if ( style == "Windows" ) { | 1824 | if ( style == "Windows" ) { |
1812 | setStyle( new QWindowsStyle ); | 1825 | setStyle( new QWindowsStyle ); |
1813 | } | 1826 | } |
1814 | else if ( style == "QPE" ) { | 1827 | else if ( style == "QPE" ) { |
1815 | setStyle( new QPEStyle ); | 1828 | setStyle( new QPEStyle ); |
1816 | } | 1829 | } |
1817 | else if ( style == "Light" ) { | 1830 | else if ( style == "Light" ) { |
1818 | setStyle( new LightStyle ); | 1831 | setStyle( new LightStyle ); |
1819 | } | 1832 | } |
1820 | #ifndef QT_NO_STYLE_PLATINUM | 1833 | #ifndef QT_NO_STYLE_PLATINUM |
1821 | else if ( style == "Platinum" ) { | 1834 | else if ( style == "Platinum" ) { |
1822 | setStyle( new QPlatinumStyle ); | 1835 | setStyle( new QPlatinumStyle ); |
1823 | } | 1836 | } |
1824 | #endif | 1837 | #endif |
1825 | #ifndef QT_NO_STYLE_MOTIF | 1838 | #ifndef QT_NO_STYLE_MOTIF |
1826 | else if ( style == "Motif" ) { | 1839 | else if ( style == "Motif" ) { |
1827 | setStyle( new QMotifStyle ); | 1840 | setStyle( new QMotifStyle ); |
1828 | } | 1841 | } |
1829 | #endif | 1842 | #endif |
1830 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1843 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1831 | else if ( style == "MotifPlus" ) { | 1844 | else if ( style == "MotifPlus" ) { |
1832 | setStyle( new QMotifPlusStyle ); | 1845 | setStyle( new QMotifPlusStyle ); |
1833 | } | 1846 | } |
1834 | #endif | 1847 | #endif |
1835 | 1848 | ||
1836 | else { | 1849 | else { |
1837 | QStyle *sty = 0; | 1850 | QStyle *sty = 0; |
1838 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1851 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
1839 | 1852 | ||
1840 | #ifdef Q_OS_MACX | 1853 | #ifdef Q_OS_MACX |
1841 | if ( style. find ( ".dylib" ) > 0 ) | 1854 | if ( style. find ( ".dylib" ) > 0 ) |
1842 | path += style; | 1855 | path += style; |
1843 | else | 1856 | else |
1844 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1857 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1845 | #else | 1858 | #else |
1846 | if ( style. find ( ".so" ) > 0 ) | 1859 | if ( style. find ( ".so" ) > 0 ) |
1847 | path += style; | 1860 | path += style; |
1848 | else | 1861 | else |
1849 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1862 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1850 | #endif | 1863 | #endif |
1851 | static QLibrary *lastlib = 0; | 1864 | static QLibrary *lastlib = 0; |
1852 | static StyleInterface *lastiface = 0; | 1865 | static StyleInterface *lastiface = 0; |
1853 | 1866 | ||
1854 | QLibrary *lib = new QLibrary ( path ); | 1867 | QLibrary *lib = new QLibrary ( path ); |
1855 | StyleInterface *iface = 0; | 1868 | StyleInterface *iface = 0; |
1856 | 1869 | ||
1857 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1870 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1858 | sty = iface-> style ( ); | 1871 | sty = iface-> style ( ); |
1859 | 1872 | ||
1860 | if ( sty ) { | 1873 | if ( sty ) { |
1861 | setStyle ( sty ); | 1874 | setStyle ( sty ); |
1862 | 1875 | ||
1863 | if ( lastiface ) | 1876 | if ( lastiface ) |
1864 | lastiface-> release ( ); | 1877 | lastiface-> release ( ); |
1865 | lastiface = iface; | 1878 | lastiface = iface; |
1866 | 1879 | ||
1867 | if ( lastlib ) { | 1880 | if ( lastlib ) { |
1868 | lastlib-> unload ( ); | 1881 | lastlib-> unload ( ); |
1869 | delete lastlib; | 1882 | delete lastlib; |
1870 | } | 1883 | } |
1871 | lastlib = lib; | 1884 | lastlib = lib; |
1872 | } | 1885 | } |
1873 | else { | 1886 | else { |
1874 | if ( iface ) | 1887 | if ( iface ) |
1875 | iface-> release ( ); | 1888 | iface-> release ( ); |
1876 | delete lib; | 1889 | delete lib; |
1877 | 1890 | ||
1878 | setStyle ( new LightStyle ( )); | 1891 | setStyle ( new LightStyle ( )); |
1879 | } | 1892 | } |
1880 | } | 1893 | } |
1881 | #endif | 1894 | #endif |
1882 | } | 1895 | } |
1883 | 1896 | ||
1884 | /*! | 1897 | /*! |
1885 | \internal | 1898 | \internal |
1886 | */ | 1899 | */ |
1887 | void QPEApplication::prepareForTermination( bool willrestart ) | 1900 | void QPEApplication::prepareForTermination( bool willrestart ) |
1888 | { | 1901 | { |
1889 | if ( willrestart ) { | 1902 | if ( willrestart ) { |
1890 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1903 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1891 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1904 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1892 | lblWait->setAlignment( QWidget::AlignCenter ); | 1905 | lblWait->setAlignment( QWidget::AlignCenter ); |
1893 | lblWait->show(); | 1906 | lblWait->show(); |
1894 | lblWait->showMaximized(); | 1907 | lblWait->showMaximized(); |
1895 | } | 1908 | } |
1896 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1909 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1897 | } | 1910 | } |
1898 | processEvents(); // ensure the message goes out. | 1911 | processEvents(); // ensure the message goes out. |
1899 | } | 1912 | } |
1900 | 1913 | ||
1901 | /*! | 1914 | /*! |
1902 | \internal | 1915 | \internal |