author | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
commit | 6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff) | |
tree | 6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/qpeapplication.cpp | |
parent | d10cddb3c9ce75bc90b14add14bc133737fe35aa (diff) | |
download | opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2 |
Qtopia1-6 merge
still to test
bic changes to be resolved
more changes to be made?
-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,10 +1,10 @@ | |||
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 |
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 | ** |
@@ -42,12 +42,13 @@ | |||
42 | #include <qptrdict.h> | 42 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
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> |
50 | #include <qsignal.h> | 51 | #include <qsignal.h> |
51 | #include "qpeapplication.h" | 52 | #include "qpeapplication.h" |
52 | #include "qpestyle.h" | 53 | #include "qpestyle.h" |
53 | #include "styleinterface.h" | 54 | #include "styleinterface.h" |
@@ -61,79 +62,180 @@ | |||
61 | #include "lightstyle.h" | 62 | #include "lightstyle.h" |
62 | 63 | ||
63 | #include <qpe/qlibrary.h> | 64 | #include <qpe/qlibrary.h> |
64 | #endif | 65 | #endif |
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> |
76 | #include <sys/file.h> | 84 | #include <sys/file.h> |
77 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
78 | #include <sys/soundcard.h> | 86 | #include <sys/soundcard.h> |
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 ), |
85 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
86 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
87 | keep_running( TRUE ) | 94 | keep_running( TRUE ) |
88 | { | 95 | { |
89 | qcopq.setAutoDelete( TRUE ); | 96 | qcopq.setAutoDelete( TRUE ); |
90 | } | 97 | } |
91 | 98 | ||
92 | int presstimer; | 99 | int presstimer; |
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; |
108 | QCString message; | 113 | QCString message; |
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 | ||
118 | void enqueueQCop( const QCString &ch, const QCString &msg, | 123 | void enqueueQCop( const QCString &ch, const QCString &msg, |
119 | const QByteArray &data ) | 124 | const QByteArray &data ) |
120 | { | 125 | { |
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() |
136 | { | 238 | { |
137 | setFilePath( Global::helpPath() ); | 239 | setFilePath( Global::helpPath() ); |
138 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 240 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
139 | } | 241 | } |
@@ -206,45 +308,107 @@ static void setMic( int t = 0, int percent = -1 ) | |||
206 | 308 | ||
207 | /*! | 309 | /*! |
208 | \class QPEApplication qpeapplication.h | 310 | \class QPEApplication qpeapplication.h |
209 | \brief The QPEApplication class implements various system services | 311 | \brief The QPEApplication class implements various system services |
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 | ||
219 | /*! | 350 | /*! |
220 | \fn void QPEApplication::clientMoused() | 351 | \fn void QPEApplication::clientMoused() |
221 | 352 | ||
222 | \internal | 353 | \internal |
223 | */ | 354 | */ |
224 | 355 | ||
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 | ||
232 | /*! | 362 | /*! |
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 | ||
240 | /*! | 403 | /*! |
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 |
247 | in the following way: | 411 | in the following way: |
248 | 412 | ||
249 | \code | 413 | \code |
250 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 414 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
@@ -258,29 +422,45 @@ static void setMic( int t = 0, int percent = -1 ) | |||
258 | ... | 422 | ... |
259 | } | 423 | } |
260 | } | 424 | } |
261 | \endcode | 425 | \endcode |
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 | ||
266 | /*! | 432 | /*! |
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 | ||
283 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 463 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
284 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 464 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
285 | 465 | ||
286 | QString qcopfn( "/tmp/qcop-msg-" ); | 466 | QString qcopfn( "/tmp/qcop-msg-" ); |
@@ -336,13 +516,13 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
336 | 516 | ||
337 | /* overide stored arguments */ | 517 | /* overide stored arguments */ |
338 | setArgs( argc, argv ); | 518 | setArgs( argc, argv ); |
339 | 519 | ||
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 |
345 | 525 | ||
346 | QStringList langs = Global::languageList(); | 526 | QStringList langs = Global::languageList(); |
347 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 527 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
348 | QString lang = *it; | 528 | QString lang = *it; |
@@ -361,38 +541,20 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
361 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 541 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
362 | if ( trans->load( tfn ) ) | 542 | if ( trans->load( tfn ) ) |
363 | installTranslator( trans ); | 543 | installTranslator( trans ); |
364 | else | 544 | else |
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 | ||
395 | applyStyle(); | 557 | applyStyle(); |
396 | 558 | ||
397 | if ( type() == GuiServer ) { | 559 | if ( type() == GuiServer ) { |
398 | setVolume(); | 560 | setVolume(); |
@@ -414,15 +576,16 @@ static void createInputMethodDict() | |||
414 | if ( !inputMethodDict ) | 576 | if ( !inputMethodDict ) |
415 | inputMethodDict = new QPtrDict<void>; | 577 | inputMethodDict = new QPtrDict<void>; |
416 | } | 578 | } |
417 | 579 | ||
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 ) |
425 | { | 588 | { |
426 | if ( inputMethodDict && w ) | 589 | if ( inputMethodDict && w ) |
427 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 590 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
428 | return Normal; | 591 | return Normal; |
@@ -434,16 +597,16 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | |||
434 | \value Normal the application sometimes needs text input (the default). | 597 | \value Normal the application sometimes needs text input (the default). |
435 | \value AlwaysOff the application never needs text input. | 598 | \value AlwaysOff the application never needs text input. |
436 | \value AlwaysOn the application always needs text input. | 599 | \value AlwaysOn the application always needs text input. |
437 | */ | 600 | */ |
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 ) |
446 | { | 609 | { |
447 | createInputMethodDict(); | 610 | createInputMethodDict(); |
448 | if ( mode == Normal ) { | 611 | if ( mode == Normal ) { |
449 | inputMethodDict->remove | 612 | inputMethodDict->remove |
@@ -454,20 +617,14 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | |||
454 | } | 617 | } |
455 | } | 618 | } |
456 | 619 | ||
457 | class HackDialog : public QDialog | 620 | 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 | ||
470 | 627 | ||
471 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 628 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
472 | { | 629 | { |
473 | // specialised actions for certain widgets. May want to | 630 | // specialised actions for certain widgets. May want to |
@@ -477,27 +634,29 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | |||
477 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 634 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
478 | key = Qt::Key_Return; | 635 | key = Qt::Key_Return; |
479 | 636 | ||
480 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 637 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
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 | ||
486 | class HackWidget : public QWidget | 645 | class HackWidget : public QWidget |
487 | { | 646 | { |
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 | ||
495 | /*! | 652 | /*! |
496 | \internal | 653 | \internal |
497 | */ | 654 | */ |
655 | |||
656 | #ifdef QWS | ||
498 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 657 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
499 | { | 658 | { |
500 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 659 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
501 | if ( qApp->type() != QApplication::GuiServer ) { | 660 | if ( qApp->type() != QApplication::GuiServer ) { |
502 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 661 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
503 | e << d->appName; | 662 | e << d->appName; |
@@ -506,12 +665,15 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
506 | } | 665 | } |
507 | if ( type() == GuiServer ) { | 666 | if ( type() == GuiServer ) { |
508 | switch ( e->type ) { | 667 | switch ( e->type ) { |
509 | case QWSEvent::Mouse: | 668 | case QWSEvent::Mouse: |
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 | } |
514 | if ( e->type == QWSEvent::Key ) { | 676 | if ( e->type == QWSEvent::Key ) { |
515 | if ( d->kbgrabber == 1 ) | 677 | if ( d->kbgrabber == 1 ) |
516 | return TRUE; | 678 | return TRUE; |
517 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 679 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
@@ -541,14 +703,13 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
541 | else { | 703 | else { |
542 | // do the same as with the select key: Map to the default action of the widget: | 704 | // do the same as with the select key: Map to the default action of the widget: |
543 | mapToDefaultAction( ke, Qt::Key_Return ); | 705 | mapToDefaultAction( ke, Qt::Key_Return ); |
544 | } | 706 | } |
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 ); |
551 | } | 712 | } |
552 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 713 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
553 | ke->simpleData.is_press ) { | 714 | ke->simpleData.is_press ) { |
554 | // Escape key closes app if focus on toplevel | 715 | // Escape key closes app if focus on toplevel |
@@ -607,12 +768,13 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
607 | if ( m == AlwaysOn ) | 768 | if ( m == AlwaysOn ) |
608 | Global::showInputMethod(); | 769 | Global::showInputMethod(); |
609 | } | 770 | } |
610 | } | 771 | } |
611 | return QApplication::qwsEventFilter( e ); | 772 | return QApplication::qwsEventFilter( e ); |
612 | } | 773 | } |
774 | #endif | ||
613 | 775 | ||
614 | /*! | 776 | /*! |
615 | Destroys the QPEApplication. | 777 | Destroys the QPEApplication. |
616 | */ | 778 | */ |
617 | QPEApplication::~QPEApplication() | 779 | QPEApplication::~QPEApplication() |
618 | { | 780 | { |
@@ -641,17 +803,13 @@ QString QPEApplication::qpeDir() | |||
641 | 803 | ||
642 | /*! | 804 | /*! |
643 | Returns the user's current Document directory. There is a trailing "/". | 805 | Returns the user's current Document directory. There is a trailing "/". |
644 | */ | 806 | */ |
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 | ||
654 | static int deforient = -1; | 812 | static int deforient = -1; |
655 | 813 | ||
656 | /*! | 814 | /*! |
657 | \internal | 815 | \internal |
@@ -681,15 +839,19 @@ int QPEApplication::defaultRotation() | |||
681 | */ | 839 | */ |
682 | void QPEApplication::setDefaultRotation( int r ) | 840 | void QPEApplication::setDefaultRotation( int r ) |
683 | { | 841 | { |
684 | if ( qApp->type() == GuiServer ) { | 842 | if ( qApp->type() == GuiServer ) { |
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 | } |
692 | 854 | ||
693 | /*! | 855 | /*! |
694 | \internal | 856 | \internal |
695 | */ | 857 | */ |
@@ -719,145 +881,136 @@ void QPEApplication::applyStyle() | |||
719 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 881 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
720 | 882 | ||
721 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 883 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
722 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 884 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
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 | ||
727 | void QPEApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 901 | void QPEApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
728 | { | 902 | { |
729 | #ifdef Q_WS_QWS | 903 | #ifdef Q_WS_QWS |
730 | QDataStream stream( data, IO_ReadOnly ); | 904 | QDataStream stream( data, IO_ReadOnly ); |
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; |
737 | stream >> r; | 910 | stream >> r; |
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; |
760 | if ( who.isEmpty() ) | 928 | if ( who.isEmpty() ) |
761 | d->kbgrabber = 0; | 929 | d->kbgrabber = 0; |
762 | else if ( who != d->appName ) | 930 | else if ( who != d->appName ) |
763 | d->kbgrabber = 1; | 931 | d->kbgrabber = 1; |
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; |
772 | stream >> l; | 937 | stream >> l; |
773 | QString cl = getenv( "LANG" ); | 938 | QString cl = getenv( "LANG" ); |
774 | if ( cl != l ) { | 939 | if ( cl != l ) { |
775 | if ( l.isNull() ) | 940 | if ( l.isNull() ) |
776 | unsetenv( "LANG" ); | 941 | unsetenv( "LANG" ); |
777 | else | 942 | else |
778 | setenv( "LANG", l.latin1(), 1 ); | 943 | setenv( "LANG", l.latin1(), 1 ); |
779 | restart(); | 944 | restart(); |
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; |
786 | if ( t.isNull() ) | 950 | if ( t.isNull() ) |
787 | unsetenv( "TZ" ); | 951 | unsetenv( "TZ" ); |
788 | else | 952 | else |
789 | setenv( "TZ", t.latin1(), 1 ); | 953 | setenv( "TZ", t.latin1(), 1 ); |
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; |
796 | stream >> t; | 959 | stream >> t; |
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; |
803 | stream >> t >> d; | 965 | stream >> t >> d; |
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; |
810 | QCString channel, message; | 971 | QCString channel, message; |
811 | int data; | 972 | int data; |
812 | stream >> when >> channel >> message >> data; | 973 | stream >> when >> channel >> message >> data; |
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; |
819 | QCString channel, message; | 979 | QCString channel, message; |
820 | int data; | 980 | int data; |
821 | stream >> when >> channel >> message >> data; | 981 | stream >> when >> channel >> message >> data; |
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(); |
860 | emit micChanged( micMuted ); | 1013 | emit micChanged( micMuted ); |
861 | } | 1014 | } |
862 | #endif | 1015 | #endif |
863 | } | 1016 | } |
@@ -868,220 +1021,151 @@ void QPEApplication::systemMessage( const QCString & msg, const QByteArray & dat | |||
868 | bool QPEApplication::raiseAppropriateWindow() | 1021 | bool QPEApplication::raiseAppropriateWindow() |
869 | { | 1022 | { |
870 | bool r = FALSE; | 1023 | bool r = FALSE; |
871 | // ########## raise()ing main window should raise and set active | 1024 | // ########## raise()ing main window should raise and set active |
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(); |
889 | } | 1040 | } |
890 | QWidget *topm = activeModalWidget(); | 1041 | QWidget *topm = activeModalWidget(); |
891 | if ( topm && topm != top ) { | 1042 | if ( topm && topm != top ) { |
892 | topm->show(); | 1043 | topm->show(); |
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 | } |
897 | return r; | 1053 | return r; |
898 | } | 1054 | } |
899 | 1055 | ||
900 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data ) | 1056 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data ) |
901 | { | 1057 | { |
902 | #ifdef Q_WS_QWS | 1058 | #ifdef Q_WS_QWS |
903 | 1059 | ||
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 ); |
941 | QString doc; | 1093 | QString doc; |
942 | stream >> doc; | 1094 | stream >> doc; |
943 | QWidget *mw = mainWidget(); | 1095 | QWidget *mw = mainWidget(); |
944 | if ( !mw ) | 1096 | if ( !mw ) |
945 | mw = d->qpe_main_widget; | 1097 | mw = d->qpe_main_widget; |
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 | ||
988 | \sa showMainDocumentWidget() | 1118 | \sa showMainDocumentWidget() |
989 | */ | 1119 | */ |
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 | ||
1023 | This calls designates the application as | 1129 | This calls designates the application as |
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() |
1029 | */ | 1135 | */ |
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() |
1070 | */ | 1154 | */ |
1071 | void QPEApplication::setKeepRunning() | 1155 | void QPEApplication::setKeepRunning() |
1072 | { | 1156 | { |
1073 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1157 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1074 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1158 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1075 | qpeApp->d->keep_running = TRUE; | 1159 | qpeApp->d->keep_running = TRUE; |
1076 | } | 1160 | } |
1077 | } | 1161 | } |
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() |
1084 | */ | 1168 | */ |
1085 | bool QPEApplication::keepRunning() const | 1169 | bool QPEApplication::keepRunning() const |
1086 | { | 1170 | { |
1087 | return d->keep_running; | 1171 | return d->keep_running; |
@@ -1211,15 +1295,15 @@ static void createDict() | |||
1211 | { | 1295 | { |
1212 | if ( !stylusDict ) | 1296 | if ( !stylusDict ) |
1213 | stylusDict = new QPtrDict<void>; | 1297 | stylusDict = new QPtrDict<void>; |
1214 | } | 1298 | } |
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 ) |
1222 | { | 1306 | { |
1223 | if ( stylusDict ) | 1307 | if ( stylusDict ) |
1224 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1308 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1225 | return LeftOnly; | 1309 | return LeftOnly; |
@@ -1230,19 +1314,20 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) | |||
1230 | 1314 | ||
1231 | \value LeftOnly the stylus only generates LeftButton | 1315 | \value LeftOnly the stylus only generates LeftButton |
1232 | events (the default). | 1316 | events (the default). |
1233 | \value RightOnHold the stylus generates RightButton events | 1317 | \value RightOnHold the stylus generates RightButton events |
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 ) |
1245 | { | 1330 | { |
1246 | createDict(); | 1331 | createDict(); |
1247 | if ( mode == LeftOnly ) { | 1332 | if ( mode == LeftOnly ) { |
1248 | stylusDict->remove | 1333 | stylusDict->remove |
@@ -1261,24 +1346,32 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | |||
1261 | \reimp | 1346 | \reimp |
1262 | */ | 1347 | */ |
1263 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1348 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1264 | { | 1349 | { |
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 ) { |
1270 | case RightOnHold: | 1354 | case RightOnHold: |
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 ); |
1281 | d->presstimer = 0; | 1374 | d->presstimer = 0; |
1282 | } | 1375 | } |
1283 | if ( d->rightpressed && d->presswidget ) { | 1376 | if ( d->rightpressed && d->presswidget ) { |
1284 | // Right released | 1377 | // Right released |
@@ -1292,33 +1385,31 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1292 | postEvent( d->presswidget, | 1385 | postEvent( d->presswidget, |
1293 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1 ), | 1386 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1 ), |
1294 | LeftButton, LeftButton ) ); | 1387 | LeftButton, LeftButton ) ); |
1295 | d->rightpressed = FALSE; | 1388 | d->rightpressed = FALSE; |
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: |
1300 | break; | 1394 | break; |
1301 | } | 1395 | } |
1302 | break; | 1396 | break; |
1303 | default: | 1397 | default: |
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 ) { |
1311 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1403 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1312 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1404 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1313 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1405 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1314 | return TRUE; | 1406 | return TRUE; |
1315 | } | 1407 | } |
1316 | } | 1408 | } |
1317 | } | 1409 | } |
1318 | |||
1319 | return FALSE; | 1410 | return FALSE; |
1320 | } | 1411 | } |
1321 | 1412 | ||
1322 | /*! | 1413 | /*! |
1323 | \reimp | 1414 | \reimp |
1324 | */ | 1415 | */ |
@@ -1357,52 +1448,62 @@ bool QPEApplication::keyboardGrabbed() const | |||
1357 | on program exit. | 1448 | on program exit. |
1358 | */ | 1449 | */ |
1359 | void QPEApplication::ungrabKeyboard() | 1450 | void QPEApplication::ungrabKeyboard() |
1360 | { | 1451 | { |
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; |
1367 | } | 1460 | } |
1368 | } | 1461 | } |
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() |
1376 | */ | 1471 | */ |
1377 | void QPEApplication::grabKeyboard() | 1472 | void QPEApplication::grabKeyboard() |
1378 | { | 1473 | { |
1379 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1474 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1380 | if ( qApp->type() == QApplication::GuiServer ) | 1475 | if ( qApp->type() == QApplication::GuiServer ) |
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 | } |
1387 | } | 1484 | } |
1388 | 1485 | ||
1389 | /*! | 1486 | /*! |
1390 | \reimp | 1487 | \reimp |
1391 | */ | 1488 | */ |
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; |
1405 | } | 1506 | } |
1406 | 1507 | ||
1407 | /*! | 1508 | /*! |
1408 | \internal | 1509 | \internal |
@@ -1410,16 +1511,18 @@ int QPEApplication::exec() | |||
1410 | loosing state. | 1511 | loosing state. |
1411 | */ | 1512 | */ |
1412 | void QPEApplication::tryQuit() | 1513 | void QPEApplication::tryQuit() |
1413 | { | 1514 | { |
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 | ||
1422 | quit(); | 1525 | quit(); |
1423 | } | 1526 | } |
1424 | 1527 | ||
1425 | /*! | 1528 | /*! |
@@ -1427,20 +1530,24 @@ void QPEApplication::tryQuit() | |||
1427 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1530 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1428 | hiding the window. If not it means quitting the application. | 1531 | hiding the window. If not it means quitting the application. |
1429 | As this is user initiated we don't need to check state. | 1532 | As this is user initiated we don't need to check state. |
1430 | */ | 1533 | */ |
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(); |
1443 | } | 1550 | } |
1444 | 1551 | ||
1445 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1552 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1446 | 1553 | ||
@@ -1480,12 +1587,13 @@ void operator delete( void* p, size_t /*size*/ ) | |||
1480 | } | 1587 | } |
1481 | 1588 | ||
1482 | #endif | 1589 | #endif |
1483 | 1590 | ||
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; |
1488 | void qt_setMaxWindowRect( const QRect & r ) | 1596 | void qt_setMaxWindowRect( const QRect & r ) |
1489 | { | 1597 | { |
1490 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1598 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1491 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1599 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
@@ -1500,6 +1608,7 @@ void qt_setMaxWindowRect( const QRect & r ) | |||
1500 | w = l->next(); | 1608 | w = l->next(); |
1501 | } | 1609 | } |
1502 | delete l; | 1610 | delete l; |
1503 | } | 1611 | } |
1504 | } | 1612 | } |
1505 | #endif | 1613 | #endif |
1614 | #endif | ||