summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp144
-rw-r--r--library/qpeapplication.h3
2 files changed, 66 insertions, 81 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index bf353d4..86aa53d 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -130,7 +130,7 @@ public:
130 QByteArray data; 130 QByteArray data;
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;
136 QString decorationName; 136 QString decorationName;
@@ -151,7 +151,7 @@ public:
151 151
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
157 // ugly hack, remove that later after finding a sane solution 157 // ugly hack, remove that later after finding a sane solution
@@ -704,6 +704,7 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
704#ifdef QTOPIA_INTERNAL_INITAPP 704#ifdef QTOPIA_INTERNAL_INITAPP
705void QPEApplication::initApp( int argc, char **argv ) 705void 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;
709 d->preloaded = FALSE; 710 d->preloaded = FALSE;
@@ -723,8 +724,10 @@ void QPEApplication::initApp( int argc, char **argv )
723 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 724 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
724 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 725 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
725 726
727 if (!initial) {
726 processQCopFile(); 728 processQCopFile();
727 d->keep_running = d->qcopq.isEmpty(); 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++) {
730 if ( qstrcmp(argv[a],"-preload")==0 ) { 733 if ( qstrcmp(argv[a],"-preload")==0 ) {
@@ -1362,97 +1365,82 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1362#endif 1365#endif
1363} 1366}
1364 1367
1365#include <qmetaobject.h>
1366 1368
1367QWidget *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 1369
1392 delete list; 1370
1393 return next; 1371
1394}
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 */
1410bool QPEApplication::raiseAppropriateWindow() 1375bool 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
1383 if ( top && d->keep_running ) {
1384 if ( top->isVisible() )
1418 r = TRUE; 1385 r = TRUE;
1419 /*wid will be valid and topLevelWidgets will be deleted properly.. */ 1386 else if (d->preloaded) {
1420 QWidget *wid = nextWidget( topLevelWidgets(), 1387 // We are preloaded and not visible.. pretend we just started..
1421 d->lastWidget ? (QWidget*)d->lastWidget : top ); 1388#ifndef QT_NO_COP
1422 /* keep the size window got but not for root*/ 1389 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1423 if ( top == wid ) 1390 e << d->appName;
1424 d->show_mx(top, d->nomaximize ); 1391#endif
1425 else 1392 }
1426 wid->show(); 1393
1427 1394 d->show_mx(top,d->nomaximize, d->appName);
1428 wid->raise();
1429 wid->setActiveWindow();
1430 d->lastWidget = wid;
1431 }else if ( activeModalWidget() ) {
1432 QWidget* mod = activeModalWidget();
1433 /* get the parent of the modal and its topLevelWidget as background widget */
1434 QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0;
1435 if (par ) {
1436 if (par == top )
1437 d->show_mx(par, d->nomaximize );
1438 else
1439 par->show();
1440 par->raise();
1441 par->setActiveWindow();
1442 }
1443 mod->show();
1444 mod->raise();
1445 mod->setActiveWindow();
1446 }else if (top){
1447 d->show_mx(top, d->nomaximize );
1448 top->raise(); 1395 top->raise();
1449 top->setActiveWindow();
1450 d->lastWidget = top;
1451 } 1396 }
1452 1397
1453 if (!r && d->preloaded ) { 1398 QWidget *topm = activeModalWidget();
1399
1400 // 2. Raise any parentless widgets (except top and topm, as they
1401 // are raised before and after this loop). Order from most
1402 // recently raised as deepest to least recently as top, so
1403 // that repeated calls cycle through widgets.
1404 QWidgetList *list = topLevelWidgets();
1405 if ( list ) {
1406 bool foundlast = FALSE;
1407 QWidget* topsub = 0;
1408 if ( d->lastraised ) {
1409 for (QWidget* w = list->first(); w; w = list->next()) {
1410 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1411 if ( w == d->lastraised )
1412 foundlast = TRUE;
1413 if ( foundlast ) {
1414 w->raise();
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;
1430 }
1431
1432 // 3. Raise the active modal widget.
1433 if ( topm && topm != top ) {
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
1454 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1439 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1455 e << d->appName; 1440 e << d->appName;
1441#endif
1442 }
1443 r = FALSE;
1456 } 1444 }
1457 1445
1458 return r; 1446 return r;
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 69e0058..729cf2b 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -115,9 +115,6 @@ private slots:
115 void removeSenderFromStylusDict(); 115 void removeSenderFromStylusDict();
116 void hideOrQuit(); 116 void hideOrQuit();
117 117
118private:
119 QWidget *nextWidget( QWidgetList*, QWidget* );
120
121protected: 118protected:
122 bool qwsEventFilter( QWSEvent * ); 119 bool qwsEventFilter( QWSEvent * );
123 void internalSetStyle( const QString &style ); 120 void internalSetStyle( const QString &style );