summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2003-08-29 06:52:04 (UTC)
committer zecke <zecke>2003-08-29 06:52:04 (UTC)
commitd8fadaf4f510803983d0b8b99994fd70e770ccab (patch) (unidiff)
tree3921c576b3dbd0dc4fd3ccfe4d39204522bf57a6 /library
parentb9861471966f8bb0e3bea2db58a0d1289add1d4f (diff)
downloadopie-d8fadaf4f510803983d0b8b99994fd70e770ccab.zip
opie-d8fadaf4f510803983d0b8b99994fd70e770ccab.tar.gz
opie-d8fadaf4f510803983d0b8b99994fd70e770ccab.tar.bz2
-IF the app is visible and has more than once topLevel widget
iterate over the list and activate the next one. -Install translation in .qm -Add an else again ( was lost in a merge )
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp142
-rw-r--r--library/qpeapplication.h11
2 files changed, 110 insertions, 43 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 9286f9f..149e6bb 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -16,9 +16,7 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19*/
20**
21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 21#include <stdlib.h>
24#include <unistd.h> 22#include <unistd.h>
@@ -51,6 +49,7 @@
51#include <qtooltip.h> 49#include <qtooltip.h>
52#include <qsignal.h> 50#include <qsignal.h>
53#include <qmainwindow.h> 51#include <qmainwindow.h>
52#include <qwidgetlist.h>
54 53
55#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 54#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
56#define QTOPIA_INTERNAL_INITAPP 55#define QTOPIA_INTERNAL_INITAPP
@@ -117,6 +116,7 @@ public:
117 bool nomaximize : 1; 116 bool nomaximize : 1;
118 bool keep_running : 1; 117 bool keep_running : 1;
119 118
119 QStringList langs;
120 QString appName; 120 QString appName;
121 struct QCopRec 121 struct QCopRec
122 { 122 {
@@ -130,7 +130,10 @@ public:
130 QByteArray data; 130 QByteArray data;
131 }; 131 };
132 QWidget* qpe_main_widget; 132 QWidget* qpe_main_widget;
133 QGuardedPtr<QWidget> lastWidget;
133 QList<QCopRec> qcopq; 134 QList<QCopRec> qcopq;
135 QString styleName;
136 QString decorationName;
134 137
135 void enqueueQCop( const QCString &ch, const QCString &msg, 138 void enqueueQCop( const QCString &ch, const QCString &msg,
136 const QByteArray &data ) 139 const QByteArray &data )
@@ -266,8 +269,6 @@ public:
266 } 269 }
267 } 270 }
268 } 271 }
269 QString styleName;
270 QString decorationName;
271}; 272};
272 273
273class ResourceMimeFactory : public QMimeSourceFactory 274class ResourceMimeFactory : public QMimeSourceFactory
@@ -663,8 +664,8 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
663 664
664#ifndef QT_NO_TRANSLATION 665#ifndef QT_NO_TRANSLATION
665 666
666 QStringList langs = Global::languageList(); 667 d->langs = Global::languageList();
667 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 668 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
668 QString lang = *it; 669 QString lang = *it;
669 670
670 installTranslation( lang + "/libopie.qm"); 671 installTranslation( lang + "/libopie.qm");
@@ -742,6 +743,10 @@ void QPEApplication::initApp( int argc, char **argv )
742 743
743 /* overide stored arguments */ 744 /* overide stored arguments */
744 setArgs(argc, argv); 745 setArgs(argc, argv);
746
747 /* install translation here */
748 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
749 installTranslation( (*it) + "/" + d->appName + ".qm" );
745} 750}
746#endif 751#endif
747 752
@@ -1311,45 +1316,103 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1311#endif 1316#endif
1312} 1317}
1313 1318
1319#include <qmetaobject.h>
1320
1321QWidget *QPEApplication::nextWidget(QWidgetList* list, QWidget* _wid) {
1322 QWidget *next = 0;
1323 if ( list->isEmpty() || list->count() == 1 )
1324 next = _wid;
1325 else{
1326 QWidget* wid;
1327 uint idx = list->findRef( _wid );
1328 uint count = list->count();
1329
1330 /* one time through the list hacky we may not start with idx but end with it*/
1331 for (uint i = (idx + 1)%count; true; i=(i+1)%count ) {
1332 wid = list->at(i);
1333 if ( wid == _wid ) {
1334 next = _wid;
1335 break;
1336 }else if ((( wid->inherits("QMainWindow") ||
1337 wid->inherits("QDialog") ) &&
1338 wid != qApp->desktop() && !wid->isHidden() ) ||
1339 ( wid == mainWidget() || wid == d->qpe_main_widget ) ){
1340 next = wid;
1341 break;
1342 }
1343 }
1344 }
1345
1346 delete list;
1347 return next;
1348}
1314/*! 1349/*!
1315 \internal 1350 \internal
1316*/ 1351*/
1352// ########## raise()ing main window should raise and set active
1353// ########## it and then all childen. This belongs in Qt/Embedded
1354/*
1355 * slightly change in behaviour to kill the need of modality in Opie
1356 * If any of the topLevelWidgets !isFullyObscured we highlight the next
1357 * top level window
1358 * 1)If visible and not modal we iterate over the list of top level widgets
1359 * 2)If modal we we make the modal and its parent toplevel widget visible if available
1360 * 3)else make topLevel visible
1361 *
1362 * send qcop if necessary and save current visible widget if not modal
1363 */
1317bool QPEApplication::raiseAppropriateWindow() 1364bool QPEApplication::raiseAppropriateWindow()
1318{ 1365{
1319 bool r = FALSE; 1366 bool r = FALSE;
1320 // ########## raise()ing main window should raise and set active 1367
1321 // ########## it and then all childen. This belongs in Qt/Embedded 1368 QWidget *top = d->qpe_main_widget ? d->qpe_main_widget : mainWidget();
1322 QWidget *top = d->qpe_main_widget; 1369 /* 1. */
1323 if ( !top ) 1370 if ( ( top && (top->isVisible() ) || ( d->lastWidget && d->lastWidget->isVisible() ) ) &&
1324 top = mainWidget(); 1371 !activeModalWidget() ) {
1325 if ( top && d->keep_running ) { 1372 r = TRUE;
1326 if ( top->isVisible() ) 1373 /*wid will be valid and topLevelWidgets will be deleted properly.. */
1327 r = TRUE; 1374 QWidget *wid = nextWidget( topLevelWidgets(),
1328 else if (d->preloaded) { 1375 d->lastWidget ? (QWidget*)d->lastWidget : top );
1329 // We are preloaded and not visible.. pretend we just started.. 1376 /* keep the size window got but not for root*/
1330 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1377 if ( top == wid )
1331 e << d->appName; 1378 d->show_mx(top, d->nomaximize );
1332 } 1379 else
1380 wid->show();
1381
1382 wid->raise();
1383 wid->setActiveWindow();
1384 d->lastWidget = wid;
1385 }else if ( activeModalWidget() ) {
1386 QWidget* mod = activeModalWidget();
1387 /* get the parent of the modal and its topLevelWidget as background widget */
1388 QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0;
1389 if (par ) {
1390 if (par == top )
1391 d->show_mx(par, d->nomaximize );
1392 else
1393 par->show();
1394 par->raise();
1395 par->setActiveWindow();
1396 }
1397 mod->show();
1398 mod->raise();
1399 mod->setActiveWindow();
1400 }else if (top){
1401 d->show_mx(top, d->nomaximize );
1402 top->raise();
1403 top->setActiveWindow();
1404 d->lastWidget = top;
1405 }
1333 1406
1334 d->show_mx(top, d->nomaximize); 1407 if (!r && d->preloaded ) {
1335 top->raise(); 1408 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1336 top->setActiveWindow(); 1409 e << d->appName;
1337 } 1410 }
1338 QWidget *topm = activeModalWidget(); 1411
1339 if ( topm && topm != top ) { 1412 return r;
1340 topm->show();
1341 topm->raise();
1342 topm->setActiveWindow();
1343 // If we haven't already handled the fastAppShowing message
1344 if (!top && d->preloaded) {
1345 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1346 e << d->appName;
1347 }
1348 r = FALSE;
1349 }
1350 return r;
1351} 1413}
1352 1414
1415
1353void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1416void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1354{ 1417{
1355#ifdef Q_WS_QWS 1418#ifdef Q_WS_QWS
@@ -1402,10 +1465,11 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1402 mw = d->qpe_main_widget; 1465 mw = d->qpe_main_widget;
1403 if ( mw ) 1466 if ( mw )
1404 Global::setDocument( mw, doc ); 1467 Global::setDocument( mw, doc );
1468
1405 } else if ( msg == "QPEProcessQCop()" ) { 1469 } else if ( msg == "QPEProcessQCop()" ) {
1406 processQCopFile(); 1470 processQCopFile();
1407 d->sendQCopQ(); 1471 d->sendQCopQ();
1408 } 1472 }else
1409 { 1473 {
1410 bool p = d->keep_running; 1474 bool p = d->keep_running;
1411 d->keep_running = FALSE; 1475 d->keep_running = FALSE;
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 770ea23..343e0b9 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -113,6 +113,9 @@ private slots:
113 void removeSenderFromStylusDict(); 113 void removeSenderFromStylusDict();
114 void hideOrQuit(); 114 void hideOrQuit();
115 115
116private:
117 inline QWidget *nextWidget( QWidgetList*, QWidget* );
118
116protected: 119protected:
117 bool qwsEventFilter( QWSEvent * ); 120 bool qwsEventFilter( QWSEvent * );
118 void internalSetStyle( const QString &style ); 121 void internalSetStyle( const QString &style );
@@ -191,13 +194,13 @@ inline void QPEApplication::setCurrentRotation( int r )
191{ 194{
192 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots 195 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
193 // for compatibility with the SharpROM use fallback to setDefaultTransformation() 196 // for compatibility with the SharpROM use fallback to setDefaultTransformation()
194 #if QT_VERSION > 233 197#if QT_VERSION > 233
195 Transformation e = DegToTrans( r ); 198 Transformation e = DegToTrans( r );
196 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 199 ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
197 qApp->desktop()->qwsDisplay()->setTransformation( e ); 200 qApp->desktop()->qwsDisplay()->setTransformation( e );
198 #else 201#else
199 setDefaultRotation( r ); 202 setDefaultRotation( r );
200 #endif 203#endif
201} 204}
202 205
203 206