summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp605
1 files changed, 357 insertions, 248 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 8aae786..3ca6d73 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -47,2 +47,3 @@
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qtextcodec.h>
48#include <qevent.h> 49#include <qevent.h>
@@ -66,5 +67,10 @@
66#include "resource.h" 67#include "resource.h"
68#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
69#include "qutfcodec.h"
70#endif
67#include "config.h" 71#include "config.h"
72#include "network.h"
73#ifdef QWS
68#include "fontmanager.h" 74#include "fontmanager.h"
69#include "fontdatabase.h" 75#endif
70 76
@@ -73,2 +79,4 @@
73#include "qpemenubar.h" 79#include "qpemenubar.h"
80#include "textcodecinterface.h"
81#include "imagecodecinterface.h"
74 82
@@ -80,4 +88,3 @@
80 88
81class QPEApplicationData 89class QPEApplicationData {
82{
83public: 90public:
@@ -94,13 +101,11 @@ public:
94 QPoint presspos; 101 QPoint presspos;
95 bool rightpressed; 102 bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke
96 int kbgrabber; 103 int kbgrabber;
97 bool kbregrab; 104 bool kbregrab : 1;
98 bool notbusysent; 105 bool notbusysent : 1;
99 QString appName; 106 QString appName;
100 struct QCopRec 107 struct QCopRec {
101 {
102 QCopRec( const QCString &ch, const QCString &msg, 108 QCopRec( const QCString &ch, const QCString &msg,
103 const QByteArray &d ) : 109 const QByteArray &d ) :
104 channel( ch ), message( msg ), data( d ) 110 channel( ch ), message( msg ), data( d ) { }
105 { }
106 111
@@ -110,7 +115,7 @@ public:
110 }; 115 };
111 bool preloaded; 116 bool preloaded : 1;
112 bool forceshow; 117 bool forceshow : 1;
113 bool nomaximize; 118 bool nomaximize : 1;
114 QWidget* qpe_main_widget; 119 QWidget* qpe_main_widget;
115 bool keep_running; 120 bool keep_running : 1;
116 QList<QCopRec> qcopq; 121 QList<QCopRec> qcopq;
@@ -122,13 +127,110 @@ public:
122 } 127 }
123 void sendQCopQ() 128 void sendQCopQ() {
124 {
125 QCopRec * r; 129 QCopRec * r;
130#ifndef QT_NO_COP
126 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 131 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
127 QCopChannel::sendLocally( r->channel, r->message, r->data ); 132 QCopChannel::sendLocally( r->channel, r->message, r->data );
133#endif
128 qcopq.clear(); 134 qcopq.clear();
129 } 135 }
130}; 136 static void show_mx(QWidget* mw, bool nomaximize) {
137 if ( mw->layout() && mw->inherits("QDialog") ) {
138 QPEApplication::showDialog((QDialog*)mw,nomaximize);
139 } else {
140#ifdef Q_WS_QWS
141 if ( !nomaximize )
142 mw->showMaximized();
143 else
144#endif
145 mw->show();
146 }
147 }
148 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
149 {
150 /*
151 // This works but disable it for now until it is safe to apply
152 // What is does is scan the .desktop files of all the apps for
153 // the applnk that has the corresponding argv[0] as this program
154 // then it uses the name stored in the .desktop file as the caption
155 // for the main widget. This saves duplicating translations for
156 // the app name in the program and in the .desktop files.
157
158 AppLnkSet apps( appsPath );
131 159
132class ResourceMimeFactory : public QMimeSourceFactory 160 QList<AppLnk> appsList = apps.children();
161 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
162 if ( (*it)->exec() == appName ) {
163 mw->setCaption( (*it)->name() );
164 return TRUE;
165 }
166 }
167 */
168 return FALSE;
169 }
170
171
172 void show(QWidget* mw, bool nomax)
173 {
174 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
175 nomaximize = nomax;
176 qpe_main_widget = mw;
177#ifndef QT_NO_COP
178 sendQCopQ();
179#endif
180 if ( preloaded ) {
181 if(forceshow)
182 show_mx(mw,nomax);
183 } else if ( keep_running ) {
184 show_mx(mw,nomax);
185 }
186 }
187
188 void loadTextCodecs()
133{ 189{
190 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
191 QDir dir( path, "lib*.so" );
192 QStringList list = dir.entryList();
193 QStringList::Iterator it;
194 for ( it = list.begin(); it != list.end(); ++it ) {
195 TextCodecInterface *iface = 0;
196 QLibrary *lib = new QLibrary( path + "/" + *it );
197 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
198 QValueList<int> mibs = iface->mibEnums();
199 for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) {
200 (void)iface->createForMib(*i);
201 // ### it exists now; need to remember if we can delete it
202 }
203 } else {
204 lib->unload();
205 delete lib;
206 }
207 }
208 }
209
210 void loadImageCodecs()
211 {
212 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
213 QDir dir( path, "lib*.so" );
214 QStringList list = dir.entryList();
215 QStringList::Iterator it;
216 for ( it = list.begin(); it != list.end(); ++it ) {
217 ImageCodecInterface *iface = 0;
218 QLibrary *lib = new QLibrary( path + "/" + *it );
219 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
220 QStringList formats = iface->keys();
221 for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) {
222 (void)iface->installIOHandler(*i);
223 // ### it exists now; need to remember if we can delete it
224 }
225 } else {
226 lib->unload();
227 delete lib;
228 }
229 }
230 }
231 QString styleName;
232 QString decorationName;
233};
234
235class ResourceMimeFactory : public QMimeSourceFactory {
134public: 236public:
@@ -211,3 +313,3 @@ static void setMic( int t = 0, int percent = -1 )
211 313
212 Simply by using QPEApplication instead of QApplication, a plain Qt 314 Simply by using QPEApplication instead of QApplication, a standard Qt
213 application becomes a Qtopia application. It automatically follows 315 application becomes a Qtopia application. It automatically follows
@@ -215,3 +317,32 @@ static void setMic( int t = 0, int percent = -1 )
215 case of \link docwidget.html document-oriented\endlink applications, 317 case of \link docwidget.html document-oriented\endlink applications,
216 changes the current displayed document in response to the environment. 318 changes the currently displayed document in response to the environment.
319
320 To create a \link docwidget.html document-oriented\endlink
321 application use showMainDocumentWidget(); to create a
322 non-document-oriented application use showMainWidget(). The
323 keepRunning() function indicates whether the application will
324 continue running after it's processed the last \link qcop.html
325 QCop\endlink message. This can be changed using setKeepRunning().
326
327 A variety of signals are emitted when certain events occur, for
328 example, timeChanged(), clockChanged(), weekChanged(),
329 dateFormatChanged() and volumeChanged(). If the application receives
330 a \link qcop.html QCop\endlink message on the application's
331 QPE/Application/\e{appname} channel, the appMessage() signal is
332 emitted. There are also flush() and reload() signals, which
333 are emitted when synching begins and ends respectively - upon these
334 signals, the application should save and reload any data
335 files that are involved in synching. Most of these signals will initially
336 be received and unfiltered through the appMessage() signal.
337
338 This class also provides a set of useful static functions. The
339 qpeDir() and documentDir() functions return the respective paths.
340 The grabKeyboard() and ungrabKeyboard() functions are used to
341 control whether the application takes control of the device's
342 physical buttons (e.g. application launch keys). The stylus' mode of
343 operation is set with setStylusOperation() and retrieved with
344 stylusOperation(). There are also setInputMethodHint() and
345 inputMethodHint() functions.
346
347 \ingroup qtopiaemb
217*/ 348*/
@@ -226,5 +357,4 @@ static void setMic( int t = 0, int percent = -1 )
226 \fn void QPEApplication::timeChanged(); 357 \fn void QPEApplication::timeChanged();
227 358 This signal is emitted when the time changes outside the normal
228 This signal is emitted when the time jumps forward or backwards 359 passage of time, i.e. if the time is set backwards or forwards.
229 by more than the normal passage of time.
230*/ 360*/
@@ -234,5 +364,38 @@ static void setMic( int t = 0, int percent = -1 )
234 364
235 This signal is emitted when the user changes the style 365 This signal is emitted when the user changes the clock's style. If
236 of clock. If \a ampm is TRUE, the user wants a 12-hour 366 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
237 AM/PM close, otherwise, they want a 24-hour clock. 367 they want a 24-hour clock.
368*/
369
370/*!
371 \fn void QPEApplication::volumeChanged( bool muted )
372
373 This signal is emitted whenever the mute state is changed. If \a
374 muted is TRUE, then sound output has been muted.
375*/
376
377/*!
378 \fn void QPEApplication::weekChanged( bool startOnMonday )
379
380 This signal is emitted if the week start day is changed. If \a
381 startOnMonday is TRUE then the first day of the week is Monday; if
382 \a startOnMonday is FALSE then the first day of the week is
383 Sunday.
384*/
385
386/*!
387 \fn void QPEApplication::dateFormatChanged()
388
389 This signal is emitted whenever the date format is changed.
390*/
391
392/*!
393 \fn void QPEApplication::flush()
394
395 ###
396*/
397
398/*!
399 \fn void QPEApplication::reload()
400
238*/ 401*/
@@ -242,4 +405,5 @@ static void setMic( int t = 0, int percent = -1 )
242 405
243 This signal is emitted when a message is received on the 406 This signal is emitted when a message is received on this
244 QPE/Application/<i>appname</i> QCop channel for this application. 407 application's QPE/Application/<i>appname</i> \link qcop.html
408 QCop\endlink channel.
245 409
@@ -263,2 +427,4 @@ static void setMic( int t = 0, int percent = -1 )
263 \sa qcop.html 427 \sa qcop.html
428 Note that messages received here may be processed by qpe application
429 and emitted as signals, such as flush() and reload().
264*/ 430*/
@@ -268,2 +434,5 @@ static void setMic( int t = 0, int percent = -1 )
268 a QApplication, passing \a argc, \a argv, and \a t. 434 a QApplication, passing \a argc, \a argv, and \a t.
435
436 For applications, \a t should be the default, GuiClient. Only
437 the Qtopia server passes GuiServer.
269*/ 438*/
@@ -272,10 +441,21 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
272{ 441{
442 d = new QPEApplicationData;
443 d->loadTextCodecs();
444 d->loadImageCodecs();
273 int dw = desktop() ->width(); 445 int dw = desktop() ->width();
274 if ( dw < 200 ) { 446 if ( dw < 200 ) {
275 // setFont( QFont( "helvetica", 8 ) ); 447 setFont( QFont( "helvetica", 8 ) );
276 AppLnk::setSmallIconSize( 10 ); 448 AppLnk::setSmallIconSize( 10 );
277 AppLnk::setBigIconSize( 28 ); 449 AppLnk::setBigIconSize( 28 );
450 }else if ( dw > 600 ) {
451 setFont( QFont( "helvetica", 12 ) );
452 AppLnk::setSmallIconSize( 24 );
453 AppLnk::setBigIconSize( 48 );
454 }else if ( dw > 400 ) {
455 setFont( QFont( "helvetica", 12 ) );
456 AppLnk::setSmallIconSize( 16 );
457 AppLnk::setBigIconSize( 32 );
278 } 458 }
279 459
280 d = new QPEApplicationData; 460
281 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 461 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
@@ -341,3 +521,3 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
341 521
342 qwsSetDecoration( new QPEDecoration() ); 522 //qwsSetDecoration( new QPEDecoration() );
343 523
@@ -366,7 +546,4 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
366 546
367 /*
368 * not required. if using one of these languages, you might as well install
369 * a custom font.
370
371 //###language/font hack; should look it up somewhere 547 //###language/font hack; should look it up somewhere
548#ifdef QWS
372 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 549 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
@@ -375,19 +552,4 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
375 } 552 }
376 553#endif
377 else {
378 */
379 Config config( "qpe" );
380 config.setGroup( "Appearance" );
381 QString familyStr = config.readEntry( "FontFamily", "helvetica" );
382 QString styleStr = config.readEntry( "FontStyle", "Regular" );
383 QString sizeStr = config.readEntry( "FontSize", "10" );
384 QString charSetStr = config.readEntry( "FontCharSet", QString::null );
385 bool ok;
386 int i_size = sizeStr.toInt( &ok, 10 );
387 FontDatabase fdb;
388 QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr );
389 setFont( selectedFont );
390 //}
391 } 554 }
392
393#endif 555#endif
@@ -419,5 +581,6 @@ static void createInputMethodDict()
419 Returns the currently set hint to the system as to whether 581 Returns the currently set hint to the system as to whether
420 \a w has any use for text input methods. 582 widget \a w has any use for text input methods.
421 583
422 \sa setInputMethodHint() 584
585 \sa setInputMethodHint() InputMethodHint
423*/ 586*/
@@ -439,6 +602,6 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
439/*! 602/*!
440 Hints to the system that \a w has use for text input methods 603 Hints to the system that widget \a w has use for text input methods
441 as specified by \a mode. 604 as specified by \a mode.
442 605
443 \sa inputMethodHint() 606 \sa inputMethodHint() InputMethodHint
444*/ 607*/
@@ -459,10 +622,4 @@ class HackDialog : public QDialog
459public: 622public:
460 void acceptIt() 623 void acceptIt() { accept(); }
461 { 624 void rejectIt() { reject(); }
462 accept();
463 }
464 void rejectIt()
465 {
466 reject();
467 }
468}; 625};
@@ -482,3 +639,5 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
482 639
640#ifdef QWS
483 ke->simpleData.keycode = key; 641 ke->simpleData.keycode = key;
642#endif
484} 643}
@@ -489,5 +648,3 @@ public:
489 bool needsOk() 648 bool needsOk()
490 { 649 { return ( getWState() & WState_Reserved1 ); }
491 return ( getWState() & WState_Reserved1 );
492 }
493}; 650};
@@ -497,2 +654,4 @@ public:
497*/ 654*/
655
656#ifdef QWS
498bool QPEApplication::qwsEventFilter( QWSEvent * e ) 657bool QPEApplication::qwsEventFilter( QWSEvent * e )
@@ -511,2 +670,5 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
511 emit clientMoused(); 670 emit clientMoused();
671 break;
672 default:
673 break;
512 } 674 }
@@ -546,4 +708,3 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
546 } 708 }
547 } 709 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
548 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
549 // Use special "select" key to do whatever default action a widget has 710 // Use special "select" key to do whatever default action a widget has
@@ -612,2 +773,3 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
612} 773}
774#endif
613 775
@@ -646,7 +808,3 @@ QString QPEApplication::documentDir()
646{ 808{
647 const char * base = getenv( "HOME" ); 809 return QString( qpeDir() + "Documents");
648 if ( base )
649 return QString( base ) + "/Documents/";
650
651 return QString( "../Documents/" );
652} 810}
@@ -686,5 +844,9 @@ void QPEApplication::setDefaultRotation( int r )
686 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 844 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
687 } 845 Config config("qpe");
688 else { 846 config.setGroup( "Rotation" );
689 QCopEnvelope( "QPE/System", "setDefaultRotation(int)" ) << r; 847 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
848 } else {
849#ifndef QT_NO_COP
850 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; }
851#endif
690 } 852 }
@@ -724,2 +886,14 @@ void QPEApplication::applyStyle()
724 setPalette( pal, TRUE ); 886 setPalette( pal, TRUE );
887
888 // Window Decoration
889 QString dec = config.readEntry( "Decoration", "Qtopia" );
890 if ( dec != d->decorationName ) {
891 qwsSetDecoration( new QPEDecoration( dec ) );
892 d->decorationName = dec;
893 }
894
895 // Font
896 QString ff = config.readEntry( "FontFamily", font().family() );
897 int fs = config.readNumEntry( "FontSize", font().pointSize() );
898 setFont( QFont(ff,fs) );
725} 899}
@@ -732,4 +906,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
732 applyStyle(); 906 applyStyle();
733 } 907 } else if ( msg == "setDefaultRotation(int)" ) {
734 else if ( msg == "setDefaultRotation(int)" ) {
735 if ( type() == GuiServer ) { 908 if ( type() == GuiServer ) {
@@ -739,20 +912,15 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
739 } 912 }
740 } 913 } else if ( msg == "shutdown()" ) {
741 else if ( msg == "shutdown()" ) {
742 if ( type() == GuiServer ) 914 if ( type() == GuiServer )
743 shutdown(); 915 shutdown();
744 } 916 } else if ( msg == "quit()" ) {
745 else if ( msg == "quit()" ) {
746 if ( type() != GuiServer ) 917 if ( type() != GuiServer )
747 tryQuit(); 918 tryQuit();
748 } 919 } else if ( msg == "forceQuit()" ) {
749 else if ( msg == "forceQuit()" ) {
750 if ( type() != GuiServer ) 920 if ( type() != GuiServer )
751 quit(); 921 quit();
752 } 922 } else if ( msg == "restart()" ) {
753 else if ( msg == "restart()" ) {
754 if ( type() == GuiServer ) 923 if ( type() == GuiServer )
755 restart(); 924 restart();
756 } 925 } else if ( msg == "grabKeyboard(QString)" ) {
757 else if ( msg == "grabKeyboard(QString)" ) {
758 QString who; 926 QString who;
@@ -765,6 +933,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
765 d->kbgrabber = 2; 933 d->kbgrabber = 2;
766 934 } else if ( msg == "language(QString)" ) {
767 printf( "'%s' received grabKeyboard ( '%s' ) -> kbgrabber = %d\n", d-> appName.latin1(), who.latin1(), d-> kbgrabber );
768 }
769 else if ( msg == "language(QString)" ) {
770 if ( type() == GuiServer ) { 935 if ( type() == GuiServer ) {
@@ -781,4 +946,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
781 } 946 }
782 } 947 } else if ( msg == "timeChange(QString)" ) {
783 else if ( msg == "timeChange(QString)" ) {
784 QString t; 948 QString t;
@@ -791,4 +955,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
791 emit timeChanged(); 955 emit timeChanged();
792 } 956 } else if ( msg == "execute(QString)" ) {
793 else if ( msg == "execute(QString)" ) {
794 if ( type() == GuiServer ) { 957 if ( type() == GuiServer ) {
@@ -798,4 +961,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
798 } 961 }
799 } 962 } else if ( msg == "execute(QString,QString)" ) {
800 else if ( msg == "execute(QString,QString)" ) {
801 if ( type() == GuiServer ) { 963 if ( type() == GuiServer ) {
@@ -805,4 +967,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
805 } 967 }
806 } 968 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
807 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
808 if ( type() == GuiServer ) { 969 if ( type() == GuiServer ) {
@@ -814,4 +975,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
814 } 975 }
815 } 976 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
816 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
817 if ( type() == GuiServer ) { 977 if ( type() == GuiServer ) {
@@ -823,4 +983,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
823 } 983 }
824 } 984 } else if ( msg == "clockChange(bool)" ) {
825 else if ( msg == "clockChange(bool)" ) {
826 int tmp; 985 int tmp;
@@ -828,4 +987,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
828 emit clockChanged( tmp ); 987 emit clockChanged( tmp );
829 } 988 } else if ( msg == "weekChange(bool)" ) {
830 else if ( msg == "weekChange(bool)" ) {
831 int tmp; 989 int tmp;
@@ -833,4 +991,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
833 emit weekChanged( tmp ); 991 emit weekChanged( tmp );
834 } 992 } else if ( msg == "setDateFormat(DateFormat)" ) {
835 else if ( msg == "setDateFormat(DateFormat)" ) {
836 DateFormat tmp; 993 DateFormat tmp;
@@ -838,4 +995,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
838 emit dateFormatChanged( tmp ); 995 emit dateFormatChanged( tmp );
839 } 996 } else if ( msg == "setVolume(int,int)" ) {
840 else if ( msg == "setVolume(int,int)" ) {
841 int t, v; 997 int t, v;
@@ -844,4 +1000,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
844 emit volumeChanged( muted ); 1000 emit volumeChanged( muted );
845 } 1001 } else if ( msg == "volumeChange(bool)" ) {
846 else if ( msg == "volumeChange(bool)" ) {
847 stream >> muted; 1002 stream >> muted;
@@ -849,4 +1004,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
849 emit volumeChanged( muted ); 1004 emit volumeChanged( muted );
850 } 1005 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
851 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
852 int t, v; 1006 int t, v;
@@ -855,4 +1009,3 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat
855 emit micChanged( micMuted ); 1009 emit micChanged( micMuted );
856 } 1010 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
857 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
858 stream >> micMuted; 1011 stream >> micMuted;
@@ -873,4 +1026,3 @@ bool QPEApplication::raiseAppropriateWindow()
873 QWidget *top = d->qpe_main_widget; 1026 QWidget *top = d->qpe_main_widget;
874 if ( !top ) 1027 if ( !top ) top =mainWidget();
875 top = mainWidget();
876 if ( top && d->keep_running ) { 1028 if ( top && d->keep_running ) {
@@ -878,10 +1030,9 @@ bool QPEApplication::raiseAppropriateWindow()
878 r = TRUE; 1030 r = TRUE;
879#ifdef Q_WS_QWS 1031 else if (d->preloaded) {
880 1032 // We are preloaded and not visible.. pretend we just started..
881 if ( !d->nomaximize ) 1033 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
882 top->showMaximized(); 1034 e << d->appName;
883 else 1035 }
884#endif
885 1036
886 top->show(); 1037 d->show_mx(top,d->nomaximize);
887 top->raise(); 1038 top->raise();
@@ -894,2 +1045,7 @@ bool QPEApplication::raiseAppropriateWindow()
894 topm->setActiveWindow(); 1045 topm->setActiveWindow();
1046 // If we haven't already handled the fastAppShowing message
1047 if (!top && d->preloaded) {
1048 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1049 e << d->appName;
1050 }
895 r = FALSE; 1051 r = FALSE;
@@ -905,11 +1061,8 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
905 tryQuit(); 1061 tryQuit();
906 } 1062 } else if ( msg == "quitIfInvisible()" ) {
907 else if ( msg == "quitIfInvisible()" ) {
908 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1063 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
909 quit(); 1064 quit();
910 } 1065 } else if ( msg == "close()" ) {
911 else if ( msg == "close()" ) {
912 hideOrQuit(); 1066 hideOrQuit();
913 } 1067 } else if ( msg == "disablePreload()" ) {
914 else if ( msg == "disablePreload()" ) {
915 d->preloaded = FALSE; 1068 d->preloaded = FALSE;
@@ -917,4 +1070,4 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
917 /* so that quit will quit */ 1070 /* so that quit will quit */
918 } 1071 } else if ( msg == "enablePreload()" ) {
919 else if ( msg == "enablePreload()" ) { 1072 if (d->qpe_main_widget)
920 d->preloaded = TRUE; 1073 d->preloaded = TRUE;
@@ -922,4 +1075,3 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
922 /* so next quit won't quit */ 1075 /* so next quit won't quit */
923 } 1076 } else if ( msg == "raise()" ) {
924 else if ( msg == "raise()" ) {
925 d->keep_running = TRUE; 1077 d->keep_running = TRUE;
@@ -927,4 +1079,6 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
927 raiseAppropriateWindow(); 1079 raiseAppropriateWindow();
928 } 1080 // Tell the system we're still chugging along...
929 else if ( msg == "flush()" ) { 1081 QCopEnvelope e("QPE/System", "appRaised(QString)");
1082 e << d->appName;
1083 } else if ( msg == "flush()" ) {
930 emit flush(); 1084 emit flush();
@@ -933,7 +1087,5 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
933 e << d->appName; 1087 e << d->appName;
934 } 1088 } else if ( msg == "reload()" ) {
935 else if ( msg == "reload()" ) {
936 emit reload(); 1089 emit reload();
937 } 1090 } else if ( msg == "setDocument(QString)" ) {
938 else if ( msg == "setDocument(QString)" ) {
939 d->keep_running = TRUE; 1091 d->keep_running = TRUE;
@@ -947,35 +1099,13 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
947 Global::setDocument( mw, doc ); 1099 Global::setDocument( mw, doc );
948 } 1100 } else if ( msg == "nextView()" ) {
949 else if ( msg == "nextView()" ) { 1101 qDebug("got nextView()");
1102/*
950 if ( raiseAppropriateWindow() ) 1103 if ( raiseAppropriateWindow() )
1104*/
951 emit appMessage( msg, data ); 1105 emit appMessage( msg, data );
952 } 1106 } else {
953 else {
954 emit appMessage( msg, data ); 1107 emit appMessage( msg, data );
955 } 1108 }
956#endif
957}
958
959
960static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
961{
962 /*
963 // This works but disable it for now until it is safe to apply
964 // What is does is scan the .desktop files of all the apps for
965 // the applnk that has the corresponding argv[0] as this program
966 // then it uses the name stored in the .desktop file as the caption
967 // for the main widget. This saves duplicating translations for
968 // the app name in the program and in the .desktop files.
969 1109
970 AppLnkSet apps( appsPath ); 1110#endif
971
972 QList<AppLnk> appsList = apps.children();
973 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
974 if ( (*it)->exec() == appName ) {
975 mw->setCaption( (*it)->name() );
976 return TRUE;
977 }
978 }
979 */
980 return FALSE;
981} 1111}
@@ -984,3 +1114,3 @@ static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appNa
984/*! 1114/*!
985 Sets \a mw as the mainWidget() and shows it. For small windows, 1115 Sets widget \a mw as the mainWidget() and shows it. For small windows,
986 consider passing TRUE for \a nomaximize rather than the default FALSE. 1116 consider passing TRUE for \a nomaximize rather than the default FALSE.
@@ -991,27 +1121,3 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
991{ 1121{
992 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1122 d->show(mw,nomaximize );
993
994 d->nomaximize = nomaximize;
995 d->qpe_main_widget = mw;
996 d->sendQCopQ();
997 if ( d->preloaded ) {
998 if ( d->forceshow ) {
999#ifdef Q_WS_QWS
1000 if ( !nomaximize )
1001 mw->showMaximized();
1002 else
1003#endif
1004
1005 mw->show();
1006 }
1007 }
1008 else if ( d->keep_running ) {
1009#ifdef Q_WS_QWS
1010 if ( !nomaximize )
1011 mw->showMaximized();
1012 else
1013#endif
1014
1015 mw->show();
1016 }
1017} 1123}
@@ -1019,3 +1125,3 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1019/*! 1125/*!
1020 Sets \a mw as the mainWidget() and shows it. For small windows, 1126 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1021 consider passing TRUE for \a nomaximize rather than the default FALSE. 1127 consider passing TRUE for \a nomaximize rather than the default FALSE.
@@ -1025,3 +1131,3 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1025 1131
1026 The \a mw widget must have a slot: setDocument(const QString&). 1132 The \a mw widget \e must have this slot: setDocument(const QString&).
1027 1133
@@ -1031,29 +1137,6 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1031{ 1137{
1032 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1033
1034 if ( mw && argc() == 2 ) 1138 if ( mw && argc() == 2 )
1035 Global::setDocument( mw, QString::fromUtf8( argv() [ 1 ] ) ); 1139 Global::setDocument( mw, QString::fromUtf8( argv() [ 1 ] ) );
1036 d->nomaximize = nomaximize;
1037 d->qpe_main_widget = mw;
1038 d->sendQCopQ();
1039 if ( d->preloaded ) {
1040 if ( d->forceshow ) {
1041#ifdef Q_WS_QWS
1042 if ( !nomaximize )
1043 mw->showMaximized();
1044 else
1045#endif
1046
1047 mw->show();
1048 }
1049 }
1050 else if ( d->keep_running ) {
1051#ifdef Q_WS_QWS
1052 if ( !nomaximize )
1053 mw->showMaximized();
1054 else
1055#endif
1056 1140
1057 mw->show(); 1141 d->show(mw, nomaximize );
1058 }
1059} 1142}
@@ -1062,7 +1145,8 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1062/*! 1145/*!
1063 Sets that the application should continue running after processing 1146 If an application is started via a \link qcop.html QCop\endlink
1064 qcop messages. Normally if an application is started via a qcop message, 1147 message, the application will process the \link qcop.html
1065 the application will process the qcop message and then quit. If while 1148 QCop\endlink message and then quit. If the application calls this
1066 processing the qcop message it calls this function, then the application 1149 function while processing a \link qcop.html QCop\endlink message,
1067 will show and start proper once it has finished processing qcop messages. 1150 after processing its outstanding \link qcop.html QCop\endlink
1151 messages the application will start 'properly' and show itself.
1068 1152
@@ -1079,4 +1163,4 @@ void QPEApplication::setKeepRunning()
1079/*! 1163/*!
1080 Returns whether the application will quit after processing the current 1164 Returns TRUE if the application will quit after processing the
1081 list of qcop messages. 1165 current list of qcop messages; otherwise returns FALSE.
1082 1166
@@ -1216,5 +1300,5 @@ static void createDict()
1216/*! 1300/*!
1217 Returns the current StylusMode for \a w. 1301 Returns the current StylusMode for widget \a w.
1218 1302
1219 \sa setStylusOperation() 1303 \sa setStylusOperation() StylusMode
1220*/ 1304*/
@@ -1235,3 +1319,3 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w )
1235 1319
1236 See setStylusOperation(). 1320 \sa setStylusOperation() stylusOperation()
1237*/ 1321*/
@@ -1239,5 +1323,6 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w )
1239/*! 1323/*!
1240 Causes \a w to receive mouse events according to \a mode. 1324 Causes widget \a w to receive mouse events according to the stylus
1325 \a mode.
1241 1326
1242 \sa stylusOperation() 1327 \sa stylusOperation() StylusMode
1243*/ 1328*/
@@ -1266,3 +1351,2 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1266 QMouseEvent * me = ( QMouseEvent* ) e; 1351 QMouseEvent * me = ( QMouseEvent* ) e;
1267 if ( me->button() == LeftButton ) {
1268 StylusMode mode = ( StylusMode ) ( int ) stylusDict->find( o ); 1352 StylusMode mode = ( StylusMode ) ( int ) stylusDict->find( o );
@@ -1272,2 +1356,3 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1272 case QEvent::MouseButtonPress: 1356 case QEvent::MouseButtonPress:
1357 if ( me->button() == LeftButton ) {
1273 d->presstimer = startTimer( 500 ); // #### pref. 1358 d->presstimer = startTimer( 500 ); // #### pref.
@@ -1276,4 +1361,12 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1276 d->rightpressed = FALSE; 1361 d->rightpressed = FALSE;
1362 }
1363 break;
1364 case QEvent::MouseMove:
1365 if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) {
1366 killTimer(d->presstimer);
1367 d->presstimer = 0;
1368 }
1277 break; 1369 break;
1278 case QEvent::MouseButtonRelease: 1370 case QEvent::MouseButtonRelease:
1371 if ( me->button() == LeftButton ) {
1279 if ( d->presstimer ) { 1372 if ( d->presstimer ) {
@@ -1297,2 +1390,3 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1297 } 1390 }
1391 }
1298 break; 1392 break;
@@ -1305,5 +1399,3 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1305 } 1399 }
1306 } 1400 }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1307 }
1308 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1309 QKeyEvent * ke = ( QKeyEvent * ) e; 1401 QKeyEvent * ke = ( QKeyEvent * ) e;
@@ -1317,3 +1409,2 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1317 } 1409 }
1318
1319 return FALSE; 1410 return FALSE;
@@ -1362,4 +1453,6 @@ void QPEApplication::ungrabKeyboard()
1362 if ( d->kbgrabber == 2 ) { 1453 if ( d->kbgrabber == 2 ) {
1454#ifndef QT_NO_COP
1363 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1455 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1364 e << QString::null; 1456 e << QString::null;
1457#endif
1365 d->kbregrab = FALSE; 1458 d->kbregrab = FALSE;
@@ -1370,5 +1463,7 @@ void QPEApplication::ungrabKeyboard()
1370/*! 1463/*!
1371 Grabs the keyboard such that the system's application launching 1464 Grabs the physical keyboard keys, e.g. the application's launching
1372 keys no longer work, and instead they are receivable by this 1465 keys. Instead of launching applications when these keys are pressed
1373 application. 1466 the signals emitted are sent to this application instead. Some games
1467 programs take over the launch keys in this way to make interaction
1468 easier.
1374 1469
@@ -1382,4 +1477,6 @@ void QPEApplication::grabKeyboard()
1382 else { 1477 else {
1478#ifndef QT_NO_COP
1383 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1479 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1384 e << d->appName; 1480 e << d->appName;
1481#endif
1385 d->kbgrabber = 2; // me 1482 d->kbgrabber = 2; // me
@@ -1393,3 +1490,5 @@ int QPEApplication::exec()
1393{ 1490{
1491#ifndef QT_NO_COP
1394 d->sendQCopQ(); 1492 d->sendQCopQ();
1493#endif
1395 if ( d->keep_running ) 1494 if ( d->keep_running )
@@ -1398,2 +1497,3 @@ int QPEApplication::exec()
1398 1497
1498#ifndef QT_NO_COP
1399 { 1499 {
@@ -1402,2 +1502,3 @@ int QPEApplication::exec()
1402 } 1502 }
1503#endif
1403 processEvents(); 1504 processEvents();
@@ -1415,2 +1516,3 @@ void QPEApplication::tryQuit()
1415 return ; // Inside modal loop or konsole. Too hard to save state. 1516 return ; // Inside modal loop or konsole. Too hard to save state.
1517#ifndef QT_NO_COP
1416 { 1518 {
@@ -1419,2 +1521,3 @@ void QPEApplication::tryQuit()
1419 } 1521 }
1522#endif
1420 processEvents(); 1523 processEvents();
@@ -1432,10 +1535,14 @@ void QPEApplication::hideOrQuit()
1432{ 1535{
1433 // notify of our demise :)
1434 {
1435 QCopEnvelope e( "QPE/System", "closing(QString)" );
1436 e << d->appName;
1437 }
1438 processEvents(); 1536 processEvents();
1537
1538 // If we are a preloaded application we don't actually quit, so emit
1539 // a System message indicating we're quasi-closing.
1439 if ( d->preloaded && d->qpe_main_widget ) 1540 if ( d->preloaded && d->qpe_main_widget )
1541#ifndef QT_NO_COP
1542 {
1543 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1544 e << d->appName;
1440 d->qpe_main_widget->hide(); 1545 d->qpe_main_widget->hide();
1546 }
1547#endif
1441 else 1548 else
@@ -1485,2 +1592,3 @@ void operator delete( void* p, size_t /*size*/ )
1485#include <qwidgetlist.h> 1592#include <qwidgetlist.h>
1593#ifdef QWS
1486#include <qgfx_qws.h> 1594#include <qgfx_qws.h>
@@ -1505 +1613,2 @@ void qt_setMaxWindowRect( const QRect & r )
1505#endif 1613#endif
1614#endif