summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2003-09-30 07:59:50 (UTC)
committer zecke <zecke>2003-09-30 07:59:50 (UTC)
commitc638bdc2b6ff6a18ec851f4317629b9d3eed4d7b (patch) (unidiff)
treecb40a149213adf36df74e5b65111a08a7f43f023 /library
parent22635efede76151e728501f48ef6ae2c6a965aac (diff)
downloadopie-c638bdc2b6ff6a18ec851f4317629b9d3eed4d7b.zip
opie-c638bdc2b6ff6a18ec851f4317629b9d3eed4d7b.tar.gz
opie-c638bdc2b6ff6a18ec851f4317629b9d3eed4d7b.tar.bz2
Use the improved version to iterate over windows from Qtopia
and include the top level widgets in the to be iterated widgets
Diffstat (limited to 'library') (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
@@ -121,46 +121,46 @@ public:
121 struct QCopRec 121 struct QCopRec
122 { 122 {
123 QCopRec( const QCString &ch, const QCString &msg, 123 QCopRec( const QCString &ch, const QCString &msg,
124 const QByteArray &d ) : 124 const QByteArray &d ) :
125 channel( ch ), message( msg ), data( d ) 125 channel( ch ), message( msg ), data( d )
126 { } 126 { }
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 )
140 { 140 {
141 qcopq.append( new QCopRec( ch, msg, data ) ); 141 qcopq.append( new QCopRec( ch, msg, data ) );
142 } 142 }
143 void sendQCopQ() 143 void sendQCopQ()
144 { 144 {
145 QCopRec * r; 145 QCopRec * r;
146#ifndef QT_NO_COP 146#ifndef QT_NO_COP
147 147
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
161#ifndef QT_QWS_SIMPAD 161#ifndef QT_QWS_SIMPAD
162 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 162 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
163 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 163 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
164 } 164 }
165#endif 165#endif
166 166
@@ -695,45 +695,48 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
695 QPEMenuToolFocusManager::initialize(); 695 QPEMenuToolFocusManager::initialize();
696 696
697#ifdef QT_NO_QWS_CURSOR 697#ifdef QT_NO_QWS_CURSOR
698 // if we have no cursor, probably don't want tooltips 698 // if we have no cursor, probably don't want tooltips
699 QToolTip::setEnabled( FALSE ); 699 QToolTip::setEnabled( FALSE );
700#endif 700#endif
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]);
713 714
714 channel.replace(QRegExp(".*/"),""); 715 channel.replace(QRegExp(".*/"),"");
715 d->appName = channel; 716 d->appName = channel;
716 717
717 #if QT_VERSION > 235 718 #if QT_VERSION > 235
718 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 719 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
719 #endif 720 #endif
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;
734 argc-=1; 737 argc-=1;
735 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 738 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
736 argv[a] = argv[a+1]; 739 argv[a] = argv[a+1];
737 a++; 740 a++;
738 d->preloaded = TRUE; 741 d->preloaded = TRUE;
739 d->forceshow = TRUE; 742 d->forceshow = TRUE;
@@ -1353,115 +1356,100 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1353 QString channel; 1356 QString channel;
1354 stream >> channel; 1357 stream >> channel;
1355 if (channel == myChannel) { 1358 if (channel == myChannel) {
1356 processQCopFile(); 1359 processQCopFile();
1357 d->sendQCopQ(); 1360 d->sendQCopQ();
1358 } 1361 }
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
1462void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1450void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1463{ 1451{
1464#ifdef Q_WS_QWS 1452#ifdef Q_WS_QWS
1465 1453
1466 if ( msg == "quit()" ) { 1454 if ( msg == "quit()" ) {
1467 tryQuit(); 1455 tryQuit();
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 69e0058..729cf2b 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -106,27 +106,24 @@ signals:
106 void weekChanged( bool startOnMonday ); 106 void weekChanged( bool startOnMonday );
107 void dateFormatChanged( DateFormat ); 107 void dateFormatChanged( DateFormat );
108 void flush(); 108 void flush();
109 void reload(); 109 void reload();
110 /* linkChanged signal */ 110 /* linkChanged signal */
111 111
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();
127 bool eventFilter( QObject *, QEvent * ); 124 bool eventFilter( QObject *, QEvent * );
128 void timerEvent( QTimerEvent * ); 125 void timerEvent( QTimerEvent * );
129 bool raiseAppropriateWindow(); 126 bool raiseAppropriateWindow();
130 virtual void tryQuit(); 127 virtual void tryQuit();
131#if QT_VERSION > 233 128#if QT_VERSION > 233
132 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) 129 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)