summaryrefslogtreecommitdiff
authorzecke <zecke>2003-08-29 06:52:04 (UTC)
committer zecke <zecke>2003-08-29 06:52:04 (UTC)
commitd8fadaf4f510803983d0b8b99994fd70e770ccab (patch) (unidiff)
tree3921c576b3dbd0dc4fd3ccfe4d39204522bf57a6
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 (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
@@ -1,77 +1,76 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
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>
25#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 23#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
26#include <qfile.h> 24#include <qfile.h>
27#ifdef Q_WS_QWS 25#ifdef Q_WS_QWS
28#ifndef QT_NO_COP 26#ifndef QT_NO_COP
29#if QT_VERSION <= 231 27#if QT_VERSION <= 231
30#define private public 28#define private public
31#define sendLocally processEvent 29#define sendLocally processEvent
32#include "qcopenvelope_qws.h" 30#include "qcopenvelope_qws.h"
33#undef private 31#undef private
34#else 32#else
35#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
36#endif 34#endif
37#endif 35#endif
38#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
39#endif 37#endif
40#include <qtextstream.h> 38#include <qtextstream.h>
41#include <qpalette.h> 39#include <qpalette.h>
42#include <qbuffer.h> 40#include <qbuffer.h>
43#include <qptrdict.h> 41#include <qptrdict.h>
44#include <qregexp.h> 42#include <qregexp.h>
45#include <qdir.h> 43#include <qdir.h>
46#include <qlabel.h> 44#include <qlabel.h>
47#include <qdialog.h> 45#include <qdialog.h>
48#include <qdragobject.h> 46#include <qdragobject.h>
49#include <qtextcodec.h> 47#include <qtextcodec.h>
50#include <qevent.h> 48#include <qevent.h>
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
57#include "qpeapplication.h" 56#include "qpeapplication.h"
58#include "qpestyle.h" 57#include "qpestyle.h"
59#include "styleinterface.h" 58#include "styleinterface.h"
60#if QT_VERSION >= 300 59#if QT_VERSION >= 300
61#include <qstylefactory.h> 60#include <qstylefactory.h>
62#else 61#else
63#include <qplatinumstyle.h> 62#include <qplatinumstyle.h>
64#include <qwindowsstyle.h> 63#include <qwindowsstyle.h>
65#include <qmotifstyle.h> 64#include <qmotifstyle.h>
66#include <qmotifplusstyle.h> 65#include <qmotifplusstyle.h>
67#include "lightstyle.h" 66#include "lightstyle.h"
68 67
69#include <qpe/qlibrary.h> 68#include <qpe/qlibrary.h>
70#endif 69#endif
71#include "global.h" 70#include "global.h"
72#include "resource.h" 71#include "resource.h"
73#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 72#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
74#include "qutfcodec.h" 73#include "qutfcodec.h"
75#endif 74#endif
76#include "config.h" 75#include "config.h"
77#include "network.h" 76#include "network.h"
@@ -96,62 +95,66 @@
96class QPEApplicationData 95class QPEApplicationData
97{ 96{
98public: 97public:
99 QPEApplicationData ( ) 98 QPEApplicationData ( )
100 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 99 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
101 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 100 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
102 keep_running( true ), qpe_main_widget( 0 ) 101 keep_running( true ), qpe_main_widget( 0 )
103 102
104 { 103 {
105 qcopq.setAutoDelete( TRUE ); 104 qcopq.setAutoDelete( TRUE );
106 } 105 }
107 106
108 int presstimer; 107 int presstimer;
109 QWidget* presswidget; 108 QWidget* presswidget;
110 QPoint presspos; 109 QPoint presspos;
111 110
112 bool rightpressed : 1; 111 bool rightpressed : 1;
113 bool kbgrabbed : 1; 112 bool kbgrabbed : 1;
114 bool notbusysent : 1; 113 bool notbusysent : 1;
115 bool preloaded : 1; 114 bool preloaded : 1;
116 bool forceshow : 1; 115 bool forceshow : 1;
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 {
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 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 )
137 { 140 {
138 qcopq.append( new QCopRec( ch, msg, data ) ); 141 qcopq.append( new QCopRec( ch, msg, data ) );
139 } 142 }
140 void sendQCopQ() 143 void sendQCopQ()
141 { 144 {
142 QCopRec * r; 145 QCopRec * r;
143#ifndef QT_NO_COP 146#ifndef QT_NO_COP
144 147
145 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 148 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
146 QCopChannel::sendLocally( r->channel, r->message, r->data ); 149 QCopChannel::sendLocally( r->channel, r->message, r->data );
147#endif 150#endif
148 151
149 qcopq.clear(); 152 qcopq.clear();
150 } 153 }
151 static void show_mx(QWidget* mw, bool nomaximize) 154 static void show_mx(QWidget* mw, bool nomaximize)
152 { 155 {
153 156
154 // ugly hack, remove that later after finding a sane solution 157 // ugly hack, remove that later after finding a sane solution
155 // 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,
156 // 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
157 // a (physically) large enough display to use the small icons 160 // a (physically) large enough display to use the small icons
@@ -245,50 +248,48 @@ public:
245 void loadImageCodecs() 248 void loadImageCodecs()
246 { 249 {
247 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 250 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
248 QDir dir( path, "lib*.so" ); 251 QDir dir( path, "lib*.so" );
249 QStringList list; 252 QStringList list;
250 if ( dir. exists ( )) 253 if ( dir. exists ( ))
251 list = dir.entryList(); 254 list = dir.entryList();
252 QStringList::Iterator it; 255 QStringList::Iterator it;
253 for ( it = list.begin(); it != list.end(); ++it ) { 256 for ( it = list.begin(); it != list.end(); ++it ) {
254 ImageCodecInterface *iface = 0; 257 ImageCodecInterface *iface = 0;
255 QLibrary *lib = new QLibrary( path + "/" + *it ); 258 QLibrary *lib = new QLibrary( path + "/" + *it );
256 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 259 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
257 QStringList formats = iface->keys(); 260 QStringList formats = iface->keys();
258 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 261 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
259 (void)iface->installIOHandler(*i); 262 (void)iface->installIOHandler(*i);
260 // ### it exists now; need to remember if we can delete it 263 // ### it exists now; need to remember if we can delete it
261 } 264 }
262 } 265 }
263 else { 266 else {
264 lib->unload(); 267 lib->unload();
265 delete lib; 268 delete lib;
266 } 269 }
267 } 270 }
268 } 271 }
269 QString styleName;
270 QString decorationName;
271}; 272};
272 273
273class ResourceMimeFactory : public QMimeSourceFactory 274class ResourceMimeFactory : public QMimeSourceFactory
274{ 275{
275public: 276public:
276 ResourceMimeFactory() : resImage( 0 ) 277 ResourceMimeFactory() : resImage( 0 )
277 { 278 {
278 setFilePath( Global::helpPath() ); 279 setFilePath( Global::helpPath() );
279 setExtensionType( "html", "text/html;charset=UTF-8" ); 280 setExtensionType( "html", "text/html;charset=UTF-8" );
280 } 281 }
281 ~ResourceMimeFactory() { 282 ~ResourceMimeFactory() {
282 delete resImage; 283 delete resImage;
283 } 284 }
284 285
285 const QMimeSource* data( const QString& abs_name ) const 286 const QMimeSource* data( const QString& abs_name ) const
286 { 287 {
287 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 288 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
288 if ( !r ) { 289 if ( !r ) {
289 int sl = abs_name.length(); 290 int sl = abs_name.length();
290 do { 291 do {
291 sl = abs_name.findRev( '/', sl - 1 ); 292 sl = abs_name.findRev( '/', sl - 1 );
292 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 293 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
293 int dot = name.findRev( '.' ); 294 int dot = name.findRev( '.' );
294 if ( dot >= 0 ) 295 if ( dot >= 0 )
@@ -642,50 +643,50 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
642 a++; 643 a++;
643 d->preloaded = TRUE; 644 d->preloaded = TRUE;
644 argc -= 1; 645 argc -= 1;
645 } 646 }
646 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 647 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
647 argv[ a ] = argv[ a + 1 ]; 648 argv[ a ] = argv[ a + 1 ];
648 a++; 649 a++;
649 d->preloaded = TRUE; 650 d->preloaded = TRUE;
650 d->forceshow = TRUE; 651 d->forceshow = TRUE;
651 argc -= 1; 652 argc -= 1;
652 } 653 }
653 } 654 }
654 655
655 /* overide stored arguments */ 656 /* overide stored arguments */
656 setArgs( argc, argv ); 657 setArgs( argc, argv );
657 658
658#endif 659#endif
659#else 660#else
660 initApp( argc, argv ); 661 initApp( argc, argv );
661#endif 662#endif
662 // qwsSetDecoration( new QPEDecoration() ); 663 // qwsSetDecoration( new QPEDecoration() );
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");
671 installTranslation( lang + "/libqpe.qm" ); 672 installTranslation( lang + "/libqpe.qm" );
672 installTranslation( lang + "/" + d->appName + ".qm" ); 673 installTranslation( lang + "/" + d->appName + ".qm" );
673 674
674 675
675 //###language/font hack; should look it up somewhere 676 //###language/font hack; should look it up somewhere
676#ifdef QWS 677#ifdef QWS
677 678
678 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 679 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
679 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 680 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
680 setFont( fn ); 681 setFont( fn );
681 } 682 }
682#endif 683#endif
683 } 684 }
684#endif 685#endif
685 686
686 applyStyle(); 687 applyStyle();
687 688
688 if ( type() == GuiServer ) { 689 if ( type() == GuiServer ) {
689 setVolume(); 690 setVolume();
690 } 691 }
691 692
@@ -721,48 +722,52 @@ void QPEApplication::initApp( int argc, char **argv )
721 pidChannel = new QCopChannel( channel, this); 722 pidChannel = new QCopChannel( channel, this);
722 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 723 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
723 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 724 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
724 725
725 processQCopFile(); 726 processQCopFile();
726 d->keep_running = d->qcopq.isEmpty(); 727 d->keep_running = d->qcopq.isEmpty();
727 728
728 for (int a=0; a<argc; a++) { 729 for (int a=0; a<argc; a++) {
729 if ( qstrcmp(argv[a],"-preload")==0 ) { 730 if ( qstrcmp(argv[a],"-preload")==0 ) {
730 argv[a] = argv[a+1]; 731 argv[a] = argv[a+1];
731 a++; 732 a++;
732 d->preloaded = TRUE; 733 d->preloaded = TRUE;
733 argc-=1; 734 argc-=1;
734 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 735 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
735 argv[a] = argv[a+1]; 736 argv[a] = argv[a+1];
736 a++; 737 a++;
737 d->preloaded = TRUE; 738 d->preloaded = TRUE;
738 d->forceshow = TRUE; 739 d->forceshow = TRUE;
739 argc-=1; 740 argc-=1;
740 } 741 }
741 } 742 }
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
748 753
749static QPtrDict<void>* inputMethodDict = 0; 754static QPtrDict<void>* inputMethodDict = 0;
750static void createInputMethodDict() 755static void createInputMethodDict()
751{ 756{
752 if ( !inputMethodDict ) 757 if ( !inputMethodDict )
753 inputMethodDict = new QPtrDict<void>; 758 inputMethodDict = new QPtrDict<void>;
754} 759}
755 760
756/*! 761/*!
757 Returns the currently set hint to the system as to whether 762 Returns the currently set hint to the system as to whether
758 widget \a w has any use for text input methods. 763 widget \a w has any use for text input methods.
759 764
760 765
761 \sa setInputMethodHint() InputMethodHint 766 \sa setInputMethodHint() InputMethodHint
762*/ 767*/
763QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 768QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
764{ 769{
765 if ( inputMethodDict && w ) 770 if ( inputMethodDict && w )
766 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 771 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
767 return Normal; 772 return Normal;
768} 773}
@@ -1290,87 +1295,145 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1290 } 1295 }
1291 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1296 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1292 setTreble(); 1297 setTreble();
1293 } else if ( msg == "getMarkedText()" ) { 1298 } else if ( msg == "getMarkedText()" ) {
1294 if ( type() == GuiServer ) { 1299 if ( type() == GuiServer ) {
1295 const ushort unicode = 'C'-'@'; 1300 const ushort unicode = 'C'-'@';
1296 const int scan = Key_C; 1301 const int scan = Key_C;
1297 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1302 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1298 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1303 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1299 } 1304 }
1300 } else if ( msg == "newChannel(QString)") { 1305 } else if ( msg == "newChannel(QString)") {
1301 QString myChannel = "QPE/Application/" + d->appName; 1306 QString myChannel = "QPE/Application/" + d->appName;
1302 QString channel; 1307 QString channel;
1303 stream >> channel; 1308 stream >> channel;
1304 if (channel == myChannel) { 1309 if (channel == myChannel) {
1305 processQCopFile(); 1310 processQCopFile();
1306 d->sendQCopQ(); 1311 d->sendQCopQ();
1307 } 1312 }
1308 } 1313 }
1309 1314
1310 1315
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
1356 1419
1357 if ( msg == "quit()" ) { 1420 if ( msg == "quit()" ) {
1358 tryQuit(); 1421 tryQuit();
1359 } 1422 }
1360 else if ( msg == "quitIfInvisible()" ) { 1423 else if ( msg == "quitIfInvisible()" ) {
1361 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1424 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1362 quit(); 1425 quit();
1363 } 1426 }
1364 else if ( msg == "close()" ) { 1427 else if ( msg == "close()" ) {
1365 hideOrQuit(); 1428 hideOrQuit();
1366 } 1429 }
1367 else if ( msg == "disablePreload()" ) { 1430 else if ( msg == "disablePreload()" ) {
1368 d->preloaded = FALSE; 1431 d->preloaded = FALSE;
1369 d->keep_running = TRUE; 1432 d->keep_running = TRUE;
1370 /* so that quit will quit */ 1433 /* so that quit will quit */
1371 } 1434 }
1372 else if ( msg == "enablePreload()" ) { 1435 else if ( msg == "enablePreload()" ) {
1373 if (d->qpe_main_widget) 1436 if (d->qpe_main_widget)
1374 d->preloaded = TRUE; 1437 d->preloaded = TRUE;
1375 d->keep_running = TRUE; 1438 d->keep_running = TRUE;
1376 /* so next quit won't quit */ 1439 /* so next quit won't quit */
@@ -1381,52 +1444,53 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1381 raiseAppropriateWindow(); 1444 raiseAppropriateWindow();
1382 // Tell the system we're still chugging along... 1445 // Tell the system we're still chugging along...
1383 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1446 QCopEnvelope e("QPE/System", "appRaised(QString)");
1384 e << d->appName; 1447 e << d->appName;
1385 } 1448 }
1386 else if ( msg == "flush()" ) { 1449 else if ( msg == "flush()" ) {
1387 emit flush(); 1450 emit flush();
1388 // we need to tell the desktop 1451 // we need to tell the desktop
1389 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1452 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1390 e << d->appName; 1453 e << d->appName;
1391 } 1454 }
1392 else if ( msg == "reload()" ) { 1455 else if ( msg == "reload()" ) {
1393 emit reload(); 1456 emit reload();
1394 } 1457 }
1395 else if ( msg == "setDocument(QString)" ) { 1458 else if ( msg == "setDocument(QString)" ) {
1396 d->keep_running = TRUE; 1459 d->keep_running = TRUE;
1397 QDataStream stream( data, IO_ReadOnly ); 1460 QDataStream stream( data, IO_ReadOnly );
1398 QString doc; 1461 QString doc;
1399 stream >> doc; 1462 stream >> doc;
1400 QWidget *mw = mainWidget(); 1463 QWidget *mw = mainWidget();
1401 if ( !mw ) 1464 if ( !mw )
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;
1412 emit appMessage( msg, data); 1476 emit appMessage( msg, data);
1413 if ( d->keep_running ) { 1477 if ( d->keep_running ) {
1414 d->notbusysent = FALSE; 1478 d->notbusysent = FALSE;
1415 raiseAppropriateWindow(); 1479 raiseAppropriateWindow();
1416 if ( !p ) { 1480 if ( !p ) {
1417 // Tell the system we're still chugging along... 1481 // Tell the system we're still chugging along...
1418#ifndef QT_NO_COP 1482#ifndef QT_NO_COP
1419 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1483 QCopEnvelope e("QPE/System", "appRaised(QString)");
1420 e << d->appName; 1484 e << d->appName;
1421#endif 1485#endif
1422 } 1486 }
1423 } 1487 }
1424 if ( p ) 1488 if ( p )
1425 d->keep_running = p; 1489 d->keep_running = p;
1426 } 1490 }
1427#endif 1491#endif
1428} 1492}
1429 1493
1430 1494
1431/*! 1495/*!
1432 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1496 Sets widget \a mw as the mainWidget() and shows it. For small windows,
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 770ea23..343e0b9 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -92,48 +92,51 @@ public:
92 92
93 bool keyboardGrabbed() const; 93 bool keyboardGrabbed() const;
94 94
95 int exec(); 95 int exec();
96 96
97signals: 97signals:
98 void clientMoused(); 98 void clientMoused();
99 void timeChanged(); 99 void timeChanged();
100 void clockChanged( bool pm ); 100 void clockChanged( bool pm );
101 void micChanged( bool muted ); 101 void micChanged( bool muted );
102 void volumeChanged( bool muted ); 102 void volumeChanged( bool muted );
103 void appMessage( const QCString& msg, const QByteArray& data); 103 void appMessage( const QCString& msg, const QByteArray& data);
104 void weekChanged( bool startOnMonday ); 104 void weekChanged( bool startOnMonday );
105 void dateFormatChanged( DateFormat ); 105 void dateFormatChanged( DateFormat );
106 void flush(); 106 void flush();
107 void reload(); 107 void reload();
108 /* linkChanged signal */ 108 /* linkChanged signal */
109 109
110private slots: 110private slots:
111 void systemMessage( const QCString &msg, const QByteArray &data ); 111 void systemMessage( const QCString &msg, const QByteArray &data );
112 void pidMessage( const QCString &msg, const QByteArray &data ); 112 void pidMessage( const QCString &msg, const QByteArray &data );
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 );
119 void prepareForTermination(bool willrestart); 122 void prepareForTermination(bool willrestart);
120 virtual void restart(); 123 virtual void restart();
121 virtual void shutdown(); 124 virtual void shutdown();
122 bool eventFilter( QObject *, QEvent * ); 125 bool eventFilter( QObject *, QEvent * );
123 void timerEvent( QTimerEvent * ); 126 void timerEvent( QTimerEvent * );
124 bool raiseAppropriateWindow(); 127 bool raiseAppropriateWindow();
125 virtual void tryQuit(); 128 virtual void tryQuit();
126#if QT_VERSION > 233 129#if QT_VERSION > 233
127 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) 130 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
128#endif 131#endif
129private: 132private:
130#ifndef QT_NO_TRANSLATION 133#ifndef QT_NO_TRANSLATION
131 void installTranslation( const QString& baseName ); 134 void installTranslation( const QString& baseName );
132#endif 135#endif
133 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 136 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
134 void processQCopFile(); 137 void processQCopFile();
135 138
136#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 139#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
137 QCopChannel *sysChannel; 140 QCopChannel *sysChannel;
138 QCopChannel *pidChannel; 141 QCopChannel *pidChannel;
139#endif 142#endif
@@ -170,35 +173,35 @@ inline int QPEApplication::execDialog( QDialog* d, bool nomax )
170enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ 173enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
171 174
172inline int TransToDeg ( Transformation t ) 175inline int TransToDeg ( Transformation t )
173{ 176{
174 int d = static_cast<int>( t ); 177 int d = static_cast<int>( t );
175 return d * 90; 178 return d * 90;
176} 179}
177 180
178inline Transformation DegToTrans ( int d ) 181inline Transformation DegToTrans ( int d )
179{ 182{
180 Transformation t = static_cast<Transformation>( d / 90 ); 183 Transformation t = static_cast<Transformation>( d / 90 );
181 return t; 184 return t;
182} 185}
183 186
184/* 187/*
185 * Set current rotation of Opie, and rotation for newly started apps. 188 * Set current rotation of Opie, and rotation for newly started apps.
186 * Differs from setDefaultRotation in that 1) it rotates currently running apps, 189 * Differs from setDefaultRotation in that 1) it rotates currently running apps,
187 * and 2) does not set deforient or save orientation to qpe.conf. 190 * and 2) does not set deforient or save orientation to qpe.conf.
188 */ 191 */
189 192
190inline void QPEApplication::setCurrentRotation( int r ) 193inline 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
204#endif 207#endif