summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp162
-rw-r--r--library/qpeapplication.h3
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
@@ -127,13 +127,13 @@ public:
127 127
128 QCString channel; 128 QCString channel;
129 QCString message; 129 QCString message;
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;
137 137
138 void enqueueQCop( const QCString &ch, const QCString &msg, 138 void enqueueQCop( const QCString &ch, const QCString &msg,
139 const QByteArray &data ) 139 const QByteArray &data )
@@ -148,13 +148,13 @@ public:
148 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 148 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
149 QCopChannel::sendLocally( r->channel, r->message, r->data ); 149 QCopChannel::sendLocally( r->channel, r->message, r->data );
150#endif 150#endif
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
158 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 158 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
159 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 159 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
160 // a (physically) large enough display to use the small icons 160 // a (physically) large enough display to use the small icons
@@ -701,12 +701,13 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
701} 701}
702 702
703 703
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;
710 d->forceshow = FALSE; 711 d->forceshow = FALSE;
711 712
712 QCString channel = QCString(argv[0]); 713 QCString channel = QCString(argv[0]);
@@ -720,14 +721,16 @@ void QPEApplication::initApp( int argc, char **argv )
720 721
721 channel = "QPE/Application/" + channel; 722 channel = "QPE/Application/" + channel;
722 pidChannel = new QCopChannel( channel, this); 723 pidChannel = new QCopChannel( channel, this);
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
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++) {
730 if ( qstrcmp(argv[a],"-preload")==0 ) { 733 if ( qstrcmp(argv[a],"-preload")==0 ) {
731 argv[a] = argv[a+1]; 734 argv[a] = argv[a+1];
732 a++; 735 a++;
733 d->preloaded = TRUE; 736 d->preloaded = TRUE;
@@ -1359,103 +1362,88 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1359 } 1362 }
1360 1363
1361 1364
1362#endif 1365#endif
1363} 1366}
1364 1367
1365#include <qmetaobject.h>
1366
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 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 */
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
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
1458 return r; 1446 return r;
1459} 1447}
1460 1448
1461 1449
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 69e0058..729cf2b 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -112,15 +112,12 @@ signals:
112private slots: 112private slots:
113 void systemMessage( const QCString &msg, const QByteArray &data ); 113 void systemMessage( const QCString &msg, const QByteArray &data );
114 void pidMessage( const QCString &msg, const QByteArray &data ); 114 void pidMessage( const QCString &msg, const QByteArray &data );
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 );
124 void prepareForTermination(bool willrestart); 121 void prepareForTermination(bool willrestart);
125 virtual void restart(); 122 virtual void restart();
126 virtual void shutdown(); 123 virtual void shutdown();