-rw-r--r-- | library/qpeapplication.cpp | 605 |
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,6 +1,6 @@ | |||
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 | ** |
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 |
@@ -46,4 +46,5 @@ | |||
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 47 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | ||
48 | #include <qevent.h> | 49 | #include <qevent.h> |
49 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
@@ -65,11 +66,18 @@ | |||
65 | #include "global.h" | 66 | #include "global.h" |
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 | ||
71 | #include "alarmserver.h" | 77 | #include "alarmserver.h" |
72 | #include "applnk.h" | 78 | #include "applnk.h" |
73 | #include "qpemenubar.h" | 79 | #include "qpemenubar.h" |
80 | #include "textcodecinterface.h" | ||
81 | #include "imagecodecinterface.h" | ||
74 | 82 | ||
75 | #include <unistd.h> | 83 | #include <unistd.h> |
@@ -79,6 +87,5 @@ | |||
79 | 87 | ||
80 | 88 | ||
81 | class QPEApplicationData | 89 | class QPEApplicationData { |
82 | { | ||
83 | public: | 90 | public: |
84 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
@@ -93,15 +100,13 @@ public: | |||
93 | QWidget* presswidget; | 100 | QWidget* presswidget; |
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 | ||
107 | QCString channel; | 112 | QCString channel; |
@@ -109,9 +114,9 @@ public: | |||
109 | QByteArray data; | 114 | QByteArray data; |
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; |
117 | 122 | ||
@@ -121,15 +126,112 @@ public: | |||
121 | qcopq.append( new QCopRec( ch, msg, data ) ); | 126 | qcopq.append( new QCopRec( ch, msg, data ) ); |
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 | ||
132 | class 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 | |||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | ||
134 | public: | 236 | public: |
135 | ResourceMimeFactory() | 237 | ResourceMimeFactory() |
@@ -210,9 +312,38 @@ static void setMic( int t = 0, int percent = -1 ) | |||
210 | that are available to all Qtopia applications. | 312 | that are available to all Qtopia applications. |
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 |
214 | style changes, quits and raises, and in the | 316 | style changes, quits and raises, and in the |
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 | */ |
218 | 349 | ||
@@ -225,7 +356,6 @@ static void setMic( int t = 0, int percent = -1 ) | |||
225 | /*! | 356 | /*! |
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 | */ |
231 | 361 | ||
@@ -233,7 +363,40 @@ static void setMic( int t = 0, int percent = -1 ) | |||
233 | \fn void QPEApplication::clockChanged( bool ampm ); | 363 | \fn void QPEApplication::clockChanged( bool ampm ); |
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 | */ |
239 | 402 | ||
@@ -241,6 +404,7 @@ static void setMic( int t = 0, int percent = -1 ) | |||
241 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 404 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
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 | ||
246 | The slot to which you connect this signal uses \a msg and \a data | 410 | The slot to which you connect this signal uses \a msg and \a data |
@@ -262,4 +426,6 @@ static void setMic( int t = 0, int percent = -1 ) | |||
262 | 426 | ||
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 | */ |
265 | 431 | ||
@@ -267,16 +433,30 @@ static void setMic( int t = 0, int percent = -1 ) | |||
267 | Constructs a QPEApplication just as you would construct | 433 | Constructs a QPEApplication just as you would construct |
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 | */ |
270 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 439 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
271 | : QApplication( argc, argv, t ) | 440 | : QApplication( argc, argv, 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 ); |
282 | 462 | ||
@@ -340,5 +520,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
340 | #endif | 520 | #endif |
341 | 521 | ||
342 | qwsSetDecoration( new QPEDecoration() ); | 522 | //qwsSetDecoration( new QPEDecoration() ); |
343 | 523 | ||
344 | #ifndef QT_NO_TRANSLATION | 524 | #ifndef QT_NO_TRANSLATION |
@@ -365,30 +545,12 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
365 | delete trans; | 545 | delete trans; |
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" ) { |
373 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 550 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
374 | setFont( fn ); | 551 | setFont( fn ); |
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 |
394 | 556 | ||
@@ -418,7 +580,8 @@ static void createInputMethodDict() | |||
418 | /*! | 580 | /*! |
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 | */ |
424 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 587 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
@@ -438,8 +601,8 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | |||
438 | 601 | ||
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 | */ |
445 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 608 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
@@ -458,12 +621,6 @@ class HackDialog : public QDialog | |||
458 | { | 621 | { |
459 | public: | 622 | public: |
460 | void acceptIt() | 623 | void acceptIt() { accept(); } |
461 | { | 624 | void rejectIt() { reject(); } |
462 | accept(); | ||
463 | } | ||
464 | void rejectIt() | ||
465 | { | ||
466 | reject(); | ||
467 | } | ||
468 | }; | 625 | }; |
469 | 626 | ||
@@ -481,5 +638,7 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | |||
481 | key = Qt::Key_Return; | 638 | key = Qt::Key_Return; |
482 | 639 | ||
640 | #ifdef QWS | ||
483 | ke->simpleData.keycode = key; | 641 | ke->simpleData.keycode = key; |
642 | #endif | ||
484 | } | 643 | } |
485 | 644 | ||
@@ -488,7 +647,5 @@ class HackWidget : public QWidget | |||
488 | public: | 647 | public: |
489 | bool needsOk() | 648 | bool needsOk() |
490 | { | 649 | { return ( getWState() & WState_Reserved1 ); } |
491 | return ( getWState() & WState_Reserved1 ); | ||
492 | } | ||
493 | }; | 650 | }; |
494 | 651 | ||
@@ -496,4 +653,6 @@ public: | |||
496 | \internal | 653 | \internal |
497 | */ | 654 | */ |
655 | |||
656 | #ifdef QWS | ||
498 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 657 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
499 | { | 658 | { |
@@ -510,4 +669,7 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
510 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 669 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
511 | emit clientMoused(); | 670 | emit clientMoused(); |
671 | break; | ||
672 | default: | ||
673 | break; | ||
512 | } | 674 | } |
513 | } | 675 | } |
@@ -545,6 +707,5 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
545 | } | 707 | } |
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 |
550 | mapToDefaultAction( ke, Qt::Key_Space ); | 711 | mapToDefaultAction( ke, Qt::Key_Space ); |
@@ -611,4 +772,5 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
611 | return QApplication::qwsEventFilter( e ); | 772 | return QApplication::qwsEventFilter( e ); |
612 | } | 773 | } |
774 | #endif | ||
613 | 775 | ||
614 | /*! | 776 | /*! |
@@ -645,9 +807,5 @@ QString QPEApplication::qpeDir() | |||
645 | QString QPEApplication::documentDir() | 807 | 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 | } |
653 | 811 | ||
@@ -685,7 +843,11 @@ void QPEApplication::setDefaultRotation( int r ) | |||
685 | deforient = r; | 843 | deforient = 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 | } |
691 | } | 853 | } |
@@ -723,4 +885,16 @@ void QPEApplication::applyStyle() | |||
723 | 885 | ||
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 | } |
726 | 900 | ||
@@ -731,6 +905,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
731 | if ( msg == "applyStyle()" ) { | 905 | if ( msg == "applyStyle()" ) { |
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 ) { |
736 | int r; | 909 | int r; |
@@ -738,22 +911,17 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
738 | setDefaultRotation( r ); | 911 | setDefaultRotation( r ); |
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; |
759 | stream >> who; | 927 | stream >> who; |
@@ -764,8 +932,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
764 | else | 932 | else |
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 ) { |
771 | QString l; | 936 | QString l; |
@@ -780,6 +945,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
780 | } | 945 | } |
781 | } | 946 | } |
782 | } | 947 | } else if ( msg == "timeChange(QString)" ) { |
783 | else if ( msg == "timeChange(QString)" ) { | ||
784 | QString t; | 948 | QString t; |
785 | stream >> t; | 949 | stream >> t; |
@@ -790,6 +954,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
790 | // emit the signal so everyone else knows... | 954 | // emit the signal so everyone else knows... |
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 ) { |
795 | QString t; | 958 | QString t; |
@@ -797,6 +960,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
797 | Global::execute( t ); | 960 | Global::execute( t ); |
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 ) { |
802 | QString t, d; | 964 | QString t, d; |
@@ -804,6 +966,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
804 | Global::execute( t, d ); | 966 | Global::execute( t, d ); |
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 ) { |
809 | QDateTime when; | 970 | QDateTime when; |
@@ -813,6 +974,5 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
813 | AlarmServer::addAlarm( when, channel, message, data ); | 974 | AlarmServer::addAlarm( when, channel, message, data ); |
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 ) { |
818 | QDateTime when; | 978 | QDateTime when; |
@@ -822,38 +982,31 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
822 | AlarmServer::deleteAlarm( when, channel, message, data ); | 982 | AlarmServer::deleteAlarm( when, channel, message, data ); |
823 | } | 983 | } |
824 | } | 984 | } else if ( msg == "clockChange(bool)" ) { |
825 | else if ( msg == "clockChange(bool)" ) { | ||
826 | int tmp; | 985 | int tmp; |
827 | stream >> tmp; | 986 | stream >> tmp; |
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; |
832 | stream >> tmp; | 990 | stream >> tmp; |
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; |
837 | stream >> tmp; | 994 | stream >> tmp; |
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; |
842 | stream >> t >> v; | 998 | stream >> t >> v; |
843 | setVolume( t, v ); | 999 | setVolume( t, v ); |
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; |
848 | setVolume(); | 1003 | setVolume(); |
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; |
853 | stream >> t >> v; | 1007 | stream >> t >> v; |
854 | setMic( t, v ); | 1008 | setMic( t, v ); |
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; |
859 | setMic(); | 1012 | setMic(); |
@@ -872,17 +1025,15 @@ bool QPEApplication::raiseAppropriateWindow() | |||
872 | // ########## it and then all childen. This belongs in Qt/Embedded | 1025 | // ########## it and then all childen. This belongs in Qt/Embedded |
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 ) { |
877 | if ( top->isVisible() ) | 1029 | if ( top->isVisible() ) |
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(); |
888 | top->setActiveWindow(); | 1039 | top->setActiveWindow(); |
@@ -893,4 +1044,9 @@ bool QPEApplication::raiseAppropriateWindow() | |||
893 | topm->raise(); | 1044 | topm->raise(); |
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; |
896 | } | 1052 | } |
@@ -904,37 +1060,33 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data ) | |||
904 | if ( msg == "quit()" ) { | 1060 | if ( msg == "quit()" ) { |
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; |
916 | d->keep_running = TRUE; | 1069 | d->keep_running = TRUE; |
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; |
921 | d->keep_running = TRUE; | 1074 | d->keep_running = TRUE; |
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; |
926 | d->notbusysent = FALSE; | 1078 | d->notbusysent = FALSE; |
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(); |
931 | // we need to tell the desktop | 1085 | // we need to tell the desktop |
932 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1086 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
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; |
940 | QDataStream stream( data, IO_ReadOnly ); | 1092 | QDataStream stream( data, IO_ReadOnly ); |
@@ -946,42 +1098,20 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data ) | |||
946 | if ( mw ) | 1098 | if ( mw ) |
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 | |||
960 | static 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 | } |
982 | 1112 | ||
983 | 1113 | ||
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. |
987 | 1117 | ||
@@ -990,33 +1120,9 @@ static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appNa | |||
990 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1120 | 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 | } |
1018 | 1124 | ||
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. |
1022 | 1128 | ||
@@ -1024,5 +1130,5 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | |||
1024 | a \link docwidget.html document-oriented\endlink application. | 1130 | a \link docwidget.html document-oriented\endlink application. |
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 | ||
1028 | \sa showMainWidget() | 1134 | \sa showMainWidget() |
@@ -1030,40 +1136,18 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | |||
1030 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1136 | 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 | } |
1060 | 1143 | ||
1061 | 1144 | ||
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 | ||
1069 | \sa keepRunning() | 1153 | \sa keepRunning() |
@@ -1078,6 +1162,6 @@ void QPEApplication::setKeepRunning() | |||
1078 | 1162 | ||
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 | ||
1083 | \sa setKeepRunning() | 1167 | \sa setKeepRunning() |
@@ -1215,7 +1299,7 @@ static void createDict() | |||
1215 | 1299 | ||
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 | */ |
1221 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) | 1305 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) |
@@ -1234,11 +1318,12 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) | |||
1234 | if the user uses the press-and-hold gesture. | 1318 | if the user uses the press-and-hold gesture. |
1235 | 1319 | ||
1236 | See setStylusOperation(). | 1320 | \sa setStylusOperation() stylusOperation() |
1237 | */ | 1321 | */ |
1238 | 1322 | ||
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 | */ |
1244 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1329 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
@@ -1265,5 +1350,4 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1265 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1350 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
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 ); |
1269 | switch ( mode ) { | 1353 | switch ( mode ) { |
@@ -1271,10 +1355,19 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1271 | switch ( me->type() ) { | 1355 | switch ( me->type() ) { |
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. |
1274 | d->presswidget = ( QWidget* ) o; | 1359 | d->presswidget = ( QWidget* ) o; |
1275 | d->presspos = me->pos(); | 1360 | d->presspos = me->pos(); |
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 ) { |
1280 | killTimer( d->presstimer ); | 1373 | killTimer( d->presstimer ); |
@@ -1296,4 +1389,5 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1296 | return TRUE; // don't send the real Left release | 1389 | return TRUE; // don't send the real Left release |
1297 | } | 1390 | } |
1391 | } | ||
1298 | break; | 1392 | break; |
1299 | default: | 1393 | default: |
@@ -1304,7 +1398,5 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1304 | ; | 1398 | ; |
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; |
1310 | if ( ke->key() == Key_Enter ) { | 1402 | if ( ke->key() == Key_Enter ) { |
@@ -1316,5 +1408,4 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1316 | } | 1408 | } |
1317 | } | 1409 | } |
1318 | |||
1319 | return FALSE; | 1410 | return FALSE; |
1320 | } | 1411 | } |
@@ -1361,6 +1452,8 @@ void QPEApplication::ungrabKeyboard() | |||
1361 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1452 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
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; |
1366 | d->kbgrabber = 0; | 1459 | d->kbgrabber = 0; |
@@ -1369,7 +1462,9 @@ void QPEApplication::ungrabKeyboard() | |||
1369 | 1462 | ||
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 | ||
1375 | \sa ungrabKeyboard() | 1470 | \sa ungrabKeyboard() |
@@ -1381,6 +1476,8 @@ void QPEApplication::grabKeyboard() | |||
1381 | d->kbgrabber = 0; | 1476 | d->kbgrabber = 0; |
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 |
1386 | } | 1483 | } |
@@ -1392,13 +1489,17 @@ void QPEApplication::grabKeyboard() | |||
1392 | int QPEApplication::exec() | 1489 | 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 ) |
1396 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1495 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1397 | return QApplication::exec(); | 1496 | return QApplication::exec(); |
1398 | 1497 | ||
1498 | #ifndef QT_NO_COP | ||
1399 | { | 1499 | { |
1400 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1500 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1401 | e << d->appName; | 1501 | e << d->appName; |
1402 | } | 1502 | } |
1503 | #endif | ||
1403 | processEvents(); | 1504 | processEvents(); |
1404 | return 0; | 1505 | return 0; |
@@ -1414,8 +1515,10 @@ void QPEApplication::tryQuit() | |||
1414 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1515 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
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 | { |
1417 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1519 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1418 | e << d->appName; | 1520 | e << d->appName; |
1419 | } | 1521 | } |
1522 | #endif | ||
1420 | processEvents(); | 1523 | processEvents(); |
1421 | 1524 | ||
@@ -1431,12 +1534,16 @@ void QPEApplication::tryQuit() | |||
1431 | void QPEApplication::hideOrQuit() | 1534 | 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 |
1442 | quit(); | 1549 | quit(); |
@@ -1484,4 +1591,5 @@ void operator delete( void* p, size_t /*size*/ ) | |||
1484 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1591 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1485 | #include <qwidgetlist.h> | 1592 | #include <qwidgetlist.h> |
1593 | #ifdef QWS | ||
1486 | #include <qgfx_qws.h> | 1594 | #include <qgfx_qws.h> |
1487 | extern QRect qt_maxWindowRect; | 1595 | extern QRect qt_maxWindowRect; |
@@ -1504,2 +1612,3 @@ void qt_setMaxWindowRect( const QRect & r ) | |||
1504 | } | 1612 | } |
1505 | #endif | 1613 | #endif |
1614 | #endif | ||