-rw-r--r-- | library/qpeapplication.cpp | 162 | ||||
-rw-r--r-- | library/qpeapplication.h | 3 |
2 files changed, 75 insertions, 90 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index bf353d4..86aa53d 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -131,5 +131,5 @@ public: | |||
131 | }; | 131 | }; |
132 | QWidget* qpe_main_widget; | 132 | QWidget* qpe_main_widget; |
133 | QGuardedPtr<QWidget> lastWidget; | 133 | QGuardedPtr<QWidget> lastraised; |
134 | QList<QCopRec> qcopq; | 134 | QList<QCopRec> qcopq; |
135 | QString styleName; | 135 | QString styleName; |
@@ -152,5 +152,5 @@ public: | |||
152 | qcopq.clear(); | 152 | qcopq.clear(); |
153 | } | 153 | } |
154 | static void show_mx(QWidget* mw, bool nomaximize) | 154 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
155 | { | 155 | { |
156 | 156 | ||
@@ -705,4 +705,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
705 | void QPEApplication::initApp( int argc, char **argv ) | 705 | void QPEApplication::initApp( int argc, char **argv ) |
706 | { | 706 | { |
707 | bool initial = pidChannel; // was set to 0 in the initializer | ||
707 | delete pidChannel; | 708 | delete pidChannel; |
708 | d->keep_running = TRUE; | 709 | d->keep_running = TRUE; |
@@ -724,6 +725,8 @@ void QPEApplication::initApp( int argc, char **argv ) | |||
724 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 725 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
725 | 726 | ||
726 | processQCopFile(); | 727 | if (!initial) { |
727 | d->keep_running = d->qcopq.isEmpty(); | 728 | processQCopFile(); |
729 | d->keep_running = d->qcopq.isEmpty(); | ||
730 | } | ||
728 | 731 | ||
729 | for (int a=0; a<argc; a++) { | 732 | for (int a=0; a<argc; a++) { |
@@ -1363,95 +1366,80 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1363 | } | 1366 | } |
1364 | 1367 | ||
1365 | #include <qmetaobject.h> | ||
1366 | |||
1367 | QWidget *QPEApplication::nextWidget(QWidgetList* list, QWidget* _wid) { | ||
1368 | QWidget *next = 0; | ||
1369 | if ( list->isEmpty() || list->count() == 1 ) | ||
1370 | next = _wid; | ||
1371 | else{ | ||
1372 | QWidget* wid; | ||
1373 | uint idx = list->findRef( _wid ); | ||
1374 | uint count = list->count(); | ||
1375 | |||
1376 | /* one time through the list hacky we may not start with idx but end with it*/ | ||
1377 | for (uint i = (idx + 1)%count; true; i=(i+1)%count ) { | ||
1378 | wid = list->at(i); | ||
1379 | if ( wid == _wid ) { | ||
1380 | next = _wid; | ||
1381 | break; | ||
1382 | }else if ((( wid->inherits("QMainWindow") || | ||
1383 | wid->inherits("QDialog") ) && | ||
1384 | wid != qApp->desktop() && !wid->isHidden() ) || | ||
1385 | ( wid == mainWidget() || wid == d->qpe_main_widget ) ){ | ||
1386 | next = wid; | ||
1387 | break; | ||
1388 | } | ||
1389 | } | ||
1390 | } | ||
1391 | 1368 | ||
1392 | delete list; | 1369 | |
1393 | return next; | 1370 | |
1394 | } | 1371 | |
1395 | /*! | 1372 | /*! |
1396 | \internal | 1373 | \internal |
1397 | */ | 1374 | */ |
1398 | // ########## raise()ing main window should raise and set active | ||
1399 | // ########## it and then all childen. This belongs in Qt/Embedded | ||
1400 | /* | ||
1401 | * slightly change in behaviour to kill the need of modality in Opie | ||
1402 | * If any of the topLevelWidgets !isFullyObscured we highlight the next | ||
1403 | * top level window | ||
1404 | * 1)If visible and not modal we iterate over the list of top level widgets | ||
1405 | * 2)If modal we we make the modal and its parent toplevel widget visible if available | ||
1406 | * 3)else make topLevel visible | ||
1407 | * | ||
1408 | * send qcop if necessary and save current visible widget if not modal | ||
1409 | */ | ||
1410 | bool QPEApplication::raiseAppropriateWindow() | 1375 | bool QPEApplication::raiseAppropriateWindow() |
1411 | { | 1376 | { |
1412 | bool r = FALSE; | 1377 | bool r=FALSE; |
1413 | 1378 | ||
1414 | QWidget *top = d->qpe_main_widget ? d->qpe_main_widget : mainWidget(); | 1379 | // 1. Raise the main widget |
1415 | /* 1. */ | 1380 | QWidget *top = d->qpe_main_widget; |
1416 | if ( ( top && (top->isVisible() ) || ( d->lastWidget && d->lastWidget->isVisible() ) ) && | 1381 | if ( !top ) top = mainWidget(); |
1417 | !activeModalWidget() ) { | 1382 | |
1418 | r = TRUE; | 1383 | if ( top && d->keep_running ) { |
1419 | /*wid will be valid and topLevelWidgets will be deleted properly.. */ | 1384 | if ( top->isVisible() ) |
1420 | QWidget *wid = nextWidget( topLevelWidgets(), | 1385 | r = TRUE; |
1421 | d->lastWidget ? (QWidget*)d->lastWidget : top ); | 1386 | else if (d->preloaded) { |
1422 | /* keep the size window got but not for root*/ | 1387 | // We are preloaded and not visible.. pretend we just started.. |
1423 | if ( top == wid ) | 1388 | #ifndef QT_NO_COP |
1424 | d->show_mx(top, d->nomaximize ); | 1389 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1425 | else | 1390 | e << d->appName; |
1426 | wid->show(); | 1391 | #endif |
1427 | 1392 | } | |
1428 | wid->raise(); | 1393 | |
1429 | wid->setActiveWindow(); | 1394 | d->show_mx(top,d->nomaximize, d->appName); |
1430 | d->lastWidget = wid; | 1395 | top->raise(); |
1431 | }else if ( activeModalWidget() ) { | 1396 | } |
1432 | QWidget* mod = activeModalWidget(); | 1397 | |
1433 | /* get the parent of the modal and its topLevelWidget as background widget */ | 1398 | QWidget *topm = activeModalWidget(); |
1434 | QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0; | 1399 | |
1435 | if (par ) { | 1400 | // 2. Raise any parentless widgets (except top and topm, as they |
1436 | if (par == top ) | 1401 | // are raised before and after this loop). Order from most |
1437 | d->show_mx(par, d->nomaximize ); | 1402 | // recently raised as deepest to least recently as top, so |
1438 | else | 1403 | // that repeated calls cycle through widgets. |
1439 | par->show(); | 1404 | QWidgetList *list = topLevelWidgets(); |
1440 | par->raise(); | 1405 | if ( list ) { |
1441 | par->setActiveWindow(); | 1406 | bool foundlast = FALSE; |
1442 | } | 1407 | QWidget* topsub = 0; |
1443 | mod->show(); | 1408 | if ( d->lastraised ) { |
1444 | mod->raise(); | 1409 | for (QWidget* w = list->first(); w; w = list->next()) { |
1445 | mod->setActiveWindow(); | 1410 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1446 | }else if (top){ | 1411 | if ( w == d->lastraised ) |
1447 | d->show_mx(top, d->nomaximize ); | 1412 | foundlast = TRUE; |
1448 | top->raise(); | 1413 | if ( foundlast ) { |
1449 | top->setActiveWindow(); | 1414 | w->raise(); |
1450 | d->lastWidget = top; | 1415 | topsub = w; |
1416 | } | ||
1417 | } | ||
1418 | } | ||
1419 | } | ||
1420 | for (QWidget* w = list->first(); w; w = list->next()) { | ||
1421 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | ||
1422 | if ( w == d->lastraised ) | ||
1423 | break; | ||
1424 | w->raise(); | ||
1425 | topsub = w; | ||
1426 | } | ||
1427 | } | ||
1428 | d->lastraised = topsub; | ||
1429 | delete list; | ||
1451 | } | 1430 | } |
1452 | 1431 | ||
1453 | if (!r && d->preloaded ) { | 1432 | // 3. Raise the active modal widget. |
1454 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1433 | if ( topm && topm != top ) { |
1455 | e << d->appName; | 1434 | topm->show(); |
1435 | topm->raise(); | ||
1436 | // If we haven't already handled the fastAppShowing message | ||
1437 | if (!top && d->preloaded) { | ||
1438 | #ifndef QT_NO_COP | ||
1439 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | ||
1440 | e << d->appName; | ||
1441 | #endif | ||
1442 | } | ||
1443 | r = FALSE; | ||
1456 | } | 1444 | } |
1457 | 1445 | ||
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 69e0058..729cf2b 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -116,7 +116,4 @@ private slots: | |||
116 | void hideOrQuit(); | 116 | void hideOrQuit(); |
117 | 117 | ||
118 | private: | ||
119 | QWidget *nextWidget( QWidgetList*, QWidget* ); | ||
120 | |||
121 | protected: | 118 | protected: |
122 | bool qwsEventFilter( QWSEvent * ); | 119 | bool qwsEventFilter( QWSEvent * ); |