author | mickeyl <mickeyl> | 2003-08-26 14:14:34 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-08-26 14:14:34 (UTC) |
commit | dbd38957ae8a24bc29f45a6b80cc17f45d8776df (patch) (unidiff) | |
tree | eef29c893ac21185c7c5fec5b74125d8852f4c72 | |
parent | 93572d0abaae444a56051d21a6fdbb76d56726e3 (diff) | |
download | opie-dbd38957ae8a24bc29f45a6b80cc17f45d8776df.zip opie-dbd38957ae8a24bc29f45a6b80cc17f45d8776df.tar.gz opie-dbd38957ae8a24bc29f45a6b80cc17f45d8776df.tar.bz2 |
fixlet for compilage with older versions
-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index b1b7ed4..9286f9f 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -204,1025 +204,1027 @@ public: | |||
204 | nomaximize = nomax; | 204 | nomaximize = nomax; |
205 | qpe_main_widget = mw; | 205 | qpe_main_widget = mw; |
206 | #ifndef QT_NO_COP | 206 | #ifndef QT_NO_COP |
207 | 207 | ||
208 | sendQCopQ(); | 208 | sendQCopQ(); |
209 | #endif | 209 | #endif |
210 | 210 | ||
211 | if ( preloaded ) { | 211 | if ( preloaded ) { |
212 | if (forceshow) | 212 | if (forceshow) |
213 | show_mx(mw, nomax); | 213 | show_mx(mw, nomax); |
214 | } | 214 | } |
215 | else if ( keep_running ) { | 215 | else if ( keep_running ) { |
216 | show_mx(mw, nomax); | 216 | show_mx(mw, nomax); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | void loadTextCodecs() | 220 | void loadTextCodecs() |
221 | { | 221 | { |
222 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 222 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
223 | QDir dir( path, "lib*.so" ); | 223 | QDir dir( path, "lib*.so" ); |
224 | QStringList list; | 224 | QStringList list; |
225 | if ( dir. exists ( )) | 225 | if ( dir. exists ( )) |
226 | list = dir.entryList(); | 226 | list = dir.entryList(); |
227 | QStringList::Iterator it; | 227 | QStringList::Iterator it; |
228 | for ( it = list.begin(); it != list.end(); ++it ) { | 228 | for ( it = list.begin(); it != list.end(); ++it ) { |
229 | TextCodecInterface *iface = 0; | 229 | TextCodecInterface *iface = 0; |
230 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 230 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
231 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 231 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
232 | QValueList<int> mibs = iface->mibEnums(); | 232 | QValueList<int> mibs = iface->mibEnums(); |
233 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 233 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
234 | (void)iface->createForMib(*i); | 234 | (void)iface->createForMib(*i); |
235 | // ### it exists now; need to remember if we can delete it | 235 | // ### it exists now; need to remember if we can delete it |
236 | } | 236 | } |
237 | } | 237 | } |
238 | else { | 238 | else { |
239 | lib->unload(); | 239 | lib->unload(); |
240 | delete lib; | 240 | delete lib; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void loadImageCodecs() | 245 | void loadImageCodecs() |
246 | { | 246 | { |
247 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 247 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
248 | QDir dir( path, "lib*.so" ); | 248 | QDir dir( path, "lib*.so" ); |
249 | QStringList list; | 249 | QStringList list; |
250 | if ( dir. exists ( )) | 250 | if ( dir. exists ( )) |
251 | list = dir.entryList(); | 251 | list = dir.entryList(); |
252 | QStringList::Iterator it; | 252 | QStringList::Iterator it; |
253 | for ( it = list.begin(); it != list.end(); ++it ) { | 253 | for ( it = list.begin(); it != list.end(); ++it ) { |
254 | ImageCodecInterface *iface = 0; | 254 | ImageCodecInterface *iface = 0; |
255 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 255 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
256 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 256 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
257 | QStringList formats = iface->keys(); | 257 | QStringList formats = iface->keys(); |
258 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 258 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
259 | (void)iface->installIOHandler(*i); | 259 | (void)iface->installIOHandler(*i); |
260 | // ### it exists now; need to remember if we can delete it | 260 | // ### it exists now; need to remember if we can delete it |
261 | } | 261 | } |
262 | } | 262 | } |
263 | else { | 263 | else { |
264 | lib->unload(); | 264 | lib->unload(); |
265 | delete lib; | 265 | delete lib; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | } | 268 | } |
269 | QString styleName; | 269 | QString styleName; |
270 | QString decorationName; | 270 | QString decorationName; |
271 | }; | 271 | }; |
272 | 272 | ||
273 | class ResourceMimeFactory : public QMimeSourceFactory | 273 | class ResourceMimeFactory : public QMimeSourceFactory |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | ResourceMimeFactory() : resImage( 0 ) | 276 | ResourceMimeFactory() : resImage( 0 ) |
277 | { | 277 | { |
278 | setFilePath( Global::helpPath() ); | 278 | setFilePath( Global::helpPath() ); |
279 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 279 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
280 | } | 280 | } |
281 | ~ResourceMimeFactory() { | 281 | ~ResourceMimeFactory() { |
282 | delete resImage; | 282 | delete resImage; |
283 | } | 283 | } |
284 | 284 | ||
285 | const QMimeSource* data( const QString& abs_name ) const | 285 | const QMimeSource* data( const QString& abs_name ) const |
286 | { | 286 | { |
287 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 287 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
288 | if ( !r ) { | 288 | if ( !r ) { |
289 | int sl = abs_name.length(); | 289 | int sl = abs_name.length(); |
290 | do { | 290 | do { |
291 | sl = abs_name.findRev( '/', sl - 1 ); | 291 | sl = abs_name.findRev( '/', sl - 1 ); |
292 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 292 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
293 | int dot = name.findRev( '.' ); | 293 | int dot = name.findRev( '.' ); |
294 | if ( dot >= 0 ) | 294 | if ( dot >= 0 ) |
295 | name = name.left( dot ); | 295 | name = name.left( dot ); |
296 | QImage img = Resource::loadImage( name ); | 296 | QImage img = Resource::loadImage( name ); |
297 | if ( !img.isNull() ) { | 297 | if ( !img.isNull() ) { |
298 | delete resImage; | 298 | delete resImage; |
299 | resImage = new QImageDrag( img ); | 299 | resImage = new QImageDrag( img ); |
300 | r = resImage; | 300 | r = resImage; |
301 | } | 301 | } |
302 | } | 302 | } |
303 | while ( !r && sl > 0 ); | 303 | while ( !r && sl > 0 ); |
304 | } | 304 | } |
305 | return r; | 305 | return r; |
306 | } | 306 | } |
307 | private: | 307 | private: |
308 | mutable QImageDrag *resImage; | 308 | mutable QImageDrag *resImage; |
309 | }; | 309 | }; |
310 | 310 | ||
311 | static int& hack(int& i) | 311 | static int& hack(int& i) |
312 | { | 312 | { |
313 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 313 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
314 | // These should be created, but aren't in Qt 2.3.0 | 314 | // These should be created, but aren't in Qt 2.3.0 |
315 | (void)new QUtf8Codec; | 315 | (void)new QUtf8Codec; |
316 | (void)new QUtf16Codec; | 316 | (void)new QUtf16Codec; |
317 | #endif | 317 | #endif |
318 | return i; | 318 | return i; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int muted = 0; | 321 | static int muted = 0; |
322 | static int micMuted = 0; | 322 | static int micMuted = 0; |
323 | 323 | ||
324 | static void setVolume( int t = 0, int percent = -1 ) | 324 | static void setVolume( int t = 0, int percent = -1 ) |
325 | { | 325 | { |
326 | switch ( t ) { | 326 | switch ( t ) { |
327 | case 0: { | 327 | case 0: { |
328 | Config cfg( "qpe" ); | 328 | Config cfg( "qpe" ); |
329 | cfg.setGroup( "Volume" ); | 329 | cfg.setGroup( "Volume" ); |
330 | if ( percent < 0 ) | 330 | if ( percent < 0 ) |
331 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 331 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
332 | int fd = 0; | 332 | int fd = 0; |
333 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 333 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
334 | int vol = muted ? 0 : percent; | 334 | int vol = muted ? 0 : percent; |
335 | // set both channels to same volume | 335 | // set both channels to same volume |
336 | vol |= vol << 8; | 336 | vol |= vol << 8; |
337 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 337 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
338 | ::close( fd ); | 338 | ::close( fd ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | static void setMic( int t = 0, int percent = -1 ) | 345 | static void setMic( int t = 0, int percent = -1 ) |
346 | { | 346 | { |
347 | switch ( t ) { | 347 | switch ( t ) { |
348 | case 0: { | 348 | case 0: { |
349 | Config cfg( "qpe" ); | 349 | Config cfg( "qpe" ); |
350 | cfg.setGroup( "Volume" ); | 350 | cfg.setGroup( "Volume" ); |
351 | if ( percent < 0 ) | 351 | if ( percent < 0 ) |
352 | percent = cfg.readNumEntry( "Mic", 50 ); | 352 | percent = cfg.readNumEntry( "Mic", 50 ); |
353 | 353 | ||
354 | int fd = 0; | 354 | int fd = 0; |
355 | int mic = micMuted ? 0 : percent; | 355 | int mic = micMuted ? 0 : percent; |
356 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 356 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
357 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 357 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
358 | ::close( fd ); | 358 | ::close( fd ); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | break; | 361 | break; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | static void setBass( int t = 0, int percent = -1 ) | 366 | static void setBass( int t = 0, int percent = -1 ) |
367 | { | 367 | { |
368 | switch ( t ) { | 368 | switch ( t ) { |
369 | case 0: { | 369 | case 0: { |
370 | Config cfg( "qpe" ); | 370 | Config cfg( "qpe" ); |
371 | cfg.setGroup( "Volume" ); | 371 | cfg.setGroup( "Volume" ); |
372 | if ( percent < 0 ) | 372 | if ( percent < 0 ) |
373 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 373 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
374 | 374 | ||
375 | int fd = 0; | 375 | int fd = 0; |
376 | int bass = percent; | 376 | int bass = percent; |
377 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 377 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
378 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 378 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
379 | ::close( fd ); | 379 | ::close( fd ); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | break; | 382 | break; |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | static void setTreble( int t = 0, int percent = -1 ) | 387 | static void setTreble( int t = 0, int percent = -1 ) |
388 | { | 388 | { |
389 | switch ( t ) { | 389 | switch ( t ) { |
390 | case 0: { | 390 | case 0: { |
391 | Config cfg( "qpe" ); | 391 | Config cfg( "qpe" ); |
392 | cfg.setGroup( "Volume" ); | 392 | cfg.setGroup( "Volume" ); |
393 | if ( percent < 0 ) | 393 | if ( percent < 0 ) |
394 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 394 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
395 | 395 | ||
396 | int fd = 0; | 396 | int fd = 0; |
397 | int treble = percent; | 397 | int treble = percent; |
398 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 398 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
399 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 399 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
400 | ::close( fd ); | 400 | ::close( fd ); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | break; | 403 | break; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | /*! | 408 | /*! |
409 | \class QPEApplication qpeapplication.h | 409 | \class QPEApplication qpeapplication.h |
410 | \brief The QPEApplication class implements various system services | 410 | \brief The QPEApplication class implements various system services |
411 | that are available to all Qtopia applications. | 411 | that are available to all Qtopia applications. |
412 | 412 | ||
413 | Simply by using QPEApplication instead of QApplication, a standard Qt | 413 | Simply by using QPEApplication instead of QApplication, a standard Qt |
414 | application becomes a Qtopia application. It automatically follows | 414 | application becomes a Qtopia application. It automatically follows |
415 | style changes, quits and raises, and in the | 415 | style changes, quits and raises, and in the |
416 | case of \link docwidget.html document-oriented\endlink applications, | 416 | case of \link docwidget.html document-oriented\endlink applications, |
417 | changes the currently displayed document in response to the environment. | 417 | changes the currently displayed document in response to the environment. |
418 | 418 | ||
419 | To create a \link docwidget.html document-oriented\endlink | 419 | To create a \link docwidget.html document-oriented\endlink |
420 | application use showMainDocumentWidget(); to create a | 420 | application use showMainDocumentWidget(); to create a |
421 | non-document-oriented application use showMainWidget(). The | 421 | non-document-oriented application use showMainWidget(). The |
422 | keepRunning() function indicates whether the application will | 422 | keepRunning() function indicates whether the application will |
423 | continue running after it's processed the last \link qcop.html | 423 | continue running after it's processed the last \link qcop.html |
424 | QCop\endlink message. This can be changed using setKeepRunning(). | 424 | QCop\endlink message. This can be changed using setKeepRunning(). |
425 | 425 | ||
426 | A variety of signals are emitted when certain events occur, for | 426 | A variety of signals are emitted when certain events occur, for |
427 | example, timeChanged(), clockChanged(), weekChanged(), | 427 | example, timeChanged(), clockChanged(), weekChanged(), |
428 | dateFormatChanged() and volumeChanged(). If the application receives | 428 | dateFormatChanged() and volumeChanged(). If the application receives |
429 | a \link qcop.html QCop\endlink message on the application's | 429 | a \link qcop.html QCop\endlink message on the application's |
430 | QPE/Application/\e{appname} channel, the appMessage() signal is | 430 | QPE/Application/\e{appname} channel, the appMessage() signal is |
431 | emitted. There are also flush() and reload() signals, which | 431 | emitted. There are also flush() and reload() signals, which |
432 | are emitted when synching begins and ends respectively - upon these | 432 | are emitted when synching begins and ends respectively - upon these |
433 | signals, the application should save and reload any data | 433 | signals, the application should save and reload any data |
434 | files that are involved in synching. Most of these signals will initially | 434 | files that are involved in synching. Most of these signals will initially |
435 | be received and unfiltered through the appMessage() signal. | 435 | be received and unfiltered through the appMessage() signal. |
436 | 436 | ||
437 | This class also provides a set of useful static functions. The | 437 | This class also provides a set of useful static functions. The |
438 | qpeDir() and documentDir() functions return the respective paths. | 438 | qpeDir() and documentDir() functions return the respective paths. |
439 | The grabKeyboard() and ungrabKeyboard() functions are used to | 439 | The grabKeyboard() and ungrabKeyboard() functions are used to |
440 | control whether the application takes control of the device's | 440 | control whether the application takes control of the device's |
441 | physical buttons (e.g. application launch keys). The stylus' mode of | 441 | physical buttons (e.g. application launch keys). The stylus' mode of |
442 | operation is set with setStylusOperation() and retrieved with | 442 | operation is set with setStylusOperation() and retrieved with |
443 | stylusOperation(). There are also setInputMethodHint() and | 443 | stylusOperation(). There are also setInputMethodHint() and |
444 | inputMethodHint() functions. | 444 | inputMethodHint() functions. |
445 | 445 | ||
446 | \ingroup qtopiaemb | 446 | \ingroup qtopiaemb |
447 | */ | 447 | */ |
448 | 448 | ||
449 | /*! | 449 | /*! |
450 | \fn void QPEApplication::clientMoused() | 450 | \fn void QPEApplication::clientMoused() |
451 | 451 | ||
452 | \internal | 452 | \internal |
453 | */ | 453 | */ |
454 | 454 | ||
455 | /*! | 455 | /*! |
456 | \fn void QPEApplication::timeChanged(); | 456 | \fn void QPEApplication::timeChanged(); |
457 | This signal is emitted when the time changes outside the normal | 457 | This signal is emitted when the time changes outside the normal |
458 | passage of time, i.e. if the time is set backwards or forwards. | 458 | passage of time, i.e. if the time is set backwards or forwards. |
459 | */ | 459 | */ |
460 | 460 | ||
461 | /*! | 461 | /*! |
462 | \fn void QPEApplication::clockChanged( bool ampm ); | 462 | \fn void QPEApplication::clockChanged( bool ampm ); |
463 | 463 | ||
464 | This signal is emitted when the user changes the clock's style. If | 464 | This signal is emitted when the user changes the clock's style. If |
465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
466 | they want a 24-hour clock. | 466 | they want a 24-hour clock. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | /*! | 469 | /*! |
470 | \fn void QPEApplication::volumeChanged( bool muted ) | 470 | \fn void QPEApplication::volumeChanged( bool muted ) |
471 | 471 | ||
472 | This signal is emitted whenever the mute state is changed. If \a | 472 | This signal is emitted whenever the mute state is changed. If \a |
473 | muted is TRUE, then sound output has been muted. | 473 | muted is TRUE, then sound output has been muted. |
474 | */ | 474 | */ |
475 | 475 | ||
476 | /*! | 476 | /*! |
477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
478 | 478 | ||
479 | This signal is emitted if the week start day is changed. If \a | 479 | This signal is emitted if the week start day is changed. If \a |
480 | startOnMonday is TRUE then the first day of the week is Monday; if | 480 | startOnMonday is TRUE then the first day of the week is Monday; if |
481 | \a startOnMonday is FALSE then the first day of the week is | 481 | \a startOnMonday is FALSE then the first day of the week is |
482 | Sunday. | 482 | Sunday. |
483 | */ | 483 | */ |
484 | 484 | ||
485 | /*! | 485 | /*! |
486 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 486 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
487 | 487 | ||
488 | This signal is emitted whenever the date format is changed. | 488 | This signal is emitted whenever the date format is changed. |
489 | */ | 489 | */ |
490 | 490 | ||
491 | /*! | 491 | /*! |
492 | \fn void QPEApplication::flush() | 492 | \fn void QPEApplication::flush() |
493 | 493 | ||
494 | ### | 494 | ### |
495 | */ | 495 | */ |
496 | 496 | ||
497 | /*! | 497 | /*! |
498 | \fn void QPEApplication::reload() | 498 | \fn void QPEApplication::reload() |
499 | 499 | ||
500 | */ | 500 | */ |
501 | 501 | ||
502 | 502 | ||
503 | 503 | ||
504 | void QPEApplication::processQCopFile() | 504 | void QPEApplication::processQCopFile() |
505 | { | 505 | { |
506 | QString qcopfn("/tmp/qcop-msg-"); | 506 | QString qcopfn("/tmp/qcop-msg-"); |
507 | qcopfn += d->appName; // append command name | 507 | qcopfn += d->appName; // append command name |
508 | 508 | ||
509 | QFile f(qcopfn); | 509 | QFile f(qcopfn); |
510 | if ( f.open(IO_ReadWrite) ) { | 510 | if ( f.open(IO_ReadWrite) ) { |
511 | #ifndef Q_OS_WIN32 | 511 | #ifndef Q_OS_WIN32 |
512 | flock(f.handle(), LOCK_EX); | 512 | flock(f.handle(), LOCK_EX); |
513 | #endif | 513 | #endif |
514 | QDataStream ds(&f); | 514 | QDataStream ds(&f); |
515 | QCString channel, message; | 515 | QCString channel, message; |
516 | QByteArray data; | 516 | QByteArray data; |
517 | while(!ds.atEnd()) { | 517 | while(!ds.atEnd()) { |
518 | ds >> channel >> message >> data; | 518 | ds >> channel >> message >> data; |
519 | d->enqueueQCop(channel,message,data); | 519 | d->enqueueQCop(channel,message,data); |
520 | } | 520 | } |
521 | ::ftruncate(f.handle(), 0); | 521 | ::ftruncate(f.handle(), 0); |
522 | #ifndef Q_OS_WIN32 | 522 | #ifndef Q_OS_WIN32 |
523 | f.flush(); | 523 | f.flush(); |
524 | flock(f.handle(), LOCK_UN); | 524 | flock(f.handle(), LOCK_UN); |
525 | #endif | 525 | #endif |
526 | } | 526 | } |
527 | #endif | 527 | #endif |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | /*! | 531 | /*! |
532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
533 | 533 | ||
534 | This signal is emitted when a message is received on this | 534 | This signal is emitted when a message is received on this |
535 | application's QPE/Application/<i>appname</i> \link qcop.html | 535 | application's QPE/Application/<i>appname</i> \link qcop.html |
536 | QCop\endlink channel. | 536 | QCop\endlink channel. |
537 | 537 | ||
538 | The slot to which you connect this signal uses \a msg and \a data | 538 | The slot to which you connect this signal uses \a msg and \a data |
539 | in the following way: | 539 | in the following way: |
540 | 540 | ||
541 | \code | 541 | \code |
542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
543 | { | 543 | { |
544 | QDataStream stream( data, IO_ReadOnly ); | 544 | QDataStream stream( data, IO_ReadOnly ); |
545 | if ( msg == "someMessage(int,int,int)" ) { | 545 | if ( msg == "someMessage(int,int,int)" ) { |
546 | int a,b,c; | 546 | int a,b,c; |
547 | stream >> a >> b >> c; | 547 | stream >> a >> b >> c; |
548 | ... | 548 | ... |
549 | } else if ( msg == "otherMessage(QString)" ) { | 549 | } else if ( msg == "otherMessage(QString)" ) { |
550 | ... | 550 | ... |
551 | } | 551 | } |
552 | } | 552 | } |
553 | \endcode | 553 | \endcode |
554 | 554 | ||
555 | \sa qcop.html | 555 | \sa qcop.html |
556 | Note that messages received here may be processed by qpe application | 556 | Note that messages received here may be processed by qpe application |
557 | and emitted as signals, such as flush() and reload(). | 557 | and emitted as signals, such as flush() and reload(). |
558 | */ | 558 | */ |
559 | 559 | ||
560 | /*! | 560 | /*! |
561 | Constructs a QPEApplication just as you would construct | 561 | Constructs a QPEApplication just as you would construct |
562 | a QApplication, passing \a argc, \a argv, and \a t. | 562 | a QApplication, passing \a argc, \a argv, and \a t. |
563 | 563 | ||
564 | For applications, \a t should be the default, GuiClient. Only | 564 | For applications, \a t should be the default, GuiClient. Only |
565 | the Qtopia server passes GuiServer. | 565 | the Qtopia server passes GuiServer. |
566 | */ | 566 | */ |
567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
569 | { | 569 | { |
570 | d = new QPEApplicationData; | 570 | d = new QPEApplicationData; |
571 | d->loadTextCodecs(); | 571 | d->loadTextCodecs(); |
572 | d->loadImageCodecs(); | 572 | d->loadImageCodecs(); |
573 | int dw = desktop() ->width(); | 573 | int dw = desktop() ->width(); |
574 | 574 | ||
575 | if ( dw < 200 ) { | 575 | if ( dw < 200 ) { |
576 | setFont( QFont( "vera", 8 ) ); | 576 | setFont( QFont( "vera", 8 ) ); |
577 | AppLnk::setSmallIconSize( 10 ); | 577 | AppLnk::setSmallIconSize( 10 ); |
578 | AppLnk::setBigIconSize( 28 ); | 578 | AppLnk::setBigIconSize( 28 ); |
579 | } | 579 | } |
580 | #ifndef QT_QWS_SIMPAD | 580 | #ifndef QT_QWS_SIMPAD |
581 | else if ( dw > 600 ) { | 581 | else if ( dw > 600 ) { |
582 | setFont( QFont( "vera", 16 ) ); | 582 | setFont( QFont( "vera", 16 ) ); |
583 | AppLnk::setSmallIconSize( 24 ); | 583 | AppLnk::setSmallIconSize( 24 ); |
584 | AppLnk::setBigIconSize( 48 ); | 584 | AppLnk::setBigIconSize( 48 ); |
585 | } | 585 | } |
586 | #endif | 586 | #endif |
587 | else if ( dw > 200 ) { | 587 | else if ( dw > 200 ) { |
588 | setFont( QFont( "vera", 10 ) ); | 588 | setFont( QFont( "vera", 10 ) ); |
589 | AppLnk::setSmallIconSize( 14 ); | 589 | AppLnk::setSmallIconSize( 14 ); |
590 | AppLnk::setBigIconSize( 32 ); | 590 | AppLnk::setBigIconSize( 32 ); |
591 | } | 591 | } |
592 | 592 | ||
593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
594 | 594 | ||
595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
596 | 596 | ||
597 | 597 | ||
598 | sysChannel = new QCopChannel( "QPE/System", this ); | 598 | sysChannel = new QCopChannel( "QPE/System", this ); |
599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
601 | 601 | ||
602 | /* COde now in initapp */ | 602 | /* COde now in initapp */ |
603 | #if 0 | 603 | #if 0 |
604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
605 | 605 | ||
606 | QString qcopfn( "/tmp/qcop-msg-" ); | 606 | QString qcopfn( "/tmp/qcop-msg-" ); |
607 | qcopfn += QString( argv[ 0 ] ); // append command name | 607 | qcopfn += QString( argv[ 0 ] ); // append command name |
608 | 608 | ||
609 | QFile f( qcopfn ); | 609 | QFile f( qcopfn ); |
610 | if ( f.open( IO_ReadOnly ) ) { | 610 | if ( f.open( IO_ReadOnly ) ) { |
611 | flock( f.handle(), LOCK_EX ); | 611 | flock( f.handle(), LOCK_EX ); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | 615 | ||
616 | QCString channel = QCString( argv[ 0 ] ); | 616 | QCString channel = QCString( argv[ 0 ] ); |
617 | channel.replace( QRegExp( ".*/" ), "" ); | 617 | channel.replace( QRegExp( ".*/" ), "" ); |
618 | d->appName = channel; | 618 | d->appName = channel; |
619 | channel = "QPE/Application/" + channel; | 619 | channel = "QPE/Application/" + channel; |
620 | pidChannel = new QCopChannel( channel, this ); | 620 | pidChannel = new QCopChannel( channel, this ); |
621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
623 | 623 | ||
624 | if ( f.isOpen() ) { | 624 | if ( f.isOpen() ) { |
625 | d->keep_running = FALSE; | 625 | d->keep_running = FALSE; |
626 | QDataStream ds( &f ); | 626 | QDataStream ds( &f ); |
627 | QCString channel, message; | 627 | QCString channel, message; |
628 | QByteArray data; | 628 | QByteArray data; |
629 | while ( !ds.atEnd() ) { | 629 | while ( !ds.atEnd() ) { |
630 | ds >> channel >> message >> data; | 630 | ds >> channel >> message >> data; |
631 | d->enqueueQCop( channel, message, data ); | 631 | d->enqueueQCop( channel, message, data ); |
632 | } | 632 | } |
633 | 633 | ||
634 | flock( f.handle(), LOCK_UN ); | 634 | flock( f.handle(), LOCK_UN ); |
635 | f.close(); | 635 | f.close(); |
636 | f.remove(); | 636 | f.remove(); |
637 | } | 637 | } |
638 | 638 | ||
639 | for ( int a = 0; a < argc; a++ ) { | 639 | for ( int a = 0; a < argc; a++ ) { |
640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
641 | argv[ a ] = argv[ a + 1 ]; | 641 | argv[ a ] = argv[ a + 1 ]; |
642 | a++; | 642 | a++; |
643 | d->preloaded = TRUE; | 643 | d->preloaded = TRUE; |
644 | argc -= 1; | 644 | argc -= 1; |
645 | } | 645 | } |
646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
647 | argv[ a ] = argv[ a + 1 ]; | 647 | argv[ a ] = argv[ a + 1 ]; |
648 | a++; | 648 | a++; |
649 | d->preloaded = TRUE; | 649 | d->preloaded = TRUE; |
650 | d->forceshow = TRUE; | 650 | d->forceshow = TRUE; |
651 | argc -= 1; | 651 | argc -= 1; |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | /* overide stored arguments */ | 655 | /* overide stored arguments */ |
656 | setArgs( argc, argv ); | 656 | setArgs( argc, argv ); |
657 | 657 | ||
658 | #endif | 658 | #endif |
659 | #else | 659 | #else |
660 | initApp( argc, argv ); | 660 | initApp( argc, argv ); |
661 | #endif | 661 | #endif |
662 | // qwsSetDecoration( new QPEDecoration() ); | 662 | // qwsSetDecoration( new QPEDecoration() ); |
663 | 663 | ||
664 | #ifndef QT_NO_TRANSLATION | 664 | #ifndef QT_NO_TRANSLATION |
665 | 665 | ||
666 | QStringList langs = Global::languageList(); | 666 | QStringList langs = Global::languageList(); |
667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
668 | QString lang = *it; | 668 | QString lang = *it; |
669 | 669 | ||
670 | installTranslation( lang + "/libopie.qm"); | 670 | installTranslation( lang + "/libopie.qm"); |
671 | installTranslation( lang + "/libqpe.qm" ); | 671 | installTranslation( lang + "/libqpe.qm" ); |
672 | installTranslation( lang + "/" + d->appName + ".qm" ); | 672 | installTranslation( lang + "/" + d->appName + ".qm" ); |
673 | 673 | ||
674 | 674 | ||
675 | //###language/font hack; should look it up somewhere | 675 | //###language/font hack; should look it up somewhere |
676 | #ifdef QWS | 676 | #ifdef QWS |
677 | 677 | ||
678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
680 | setFont( fn ); | 680 | setFont( fn ); |
681 | } | 681 | } |
682 | #endif | 682 | #endif |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | 685 | ||
686 | applyStyle(); | 686 | applyStyle(); |
687 | 687 | ||
688 | if ( type() == GuiServer ) { | 688 | if ( type() == GuiServer ) { |
689 | setVolume(); | 689 | setVolume(); |
690 | } | 690 | } |
691 | 691 | ||
692 | installEventFilter( this ); | 692 | installEventFilter( this ); |
693 | 693 | ||
694 | QPEMenuToolFocusManager::initialize(); | 694 | QPEMenuToolFocusManager::initialize(); |
695 | 695 | ||
696 | #ifdef QT_NO_QWS_CURSOR | 696 | #ifdef QT_NO_QWS_CURSOR |
697 | // if we have no cursor, probably don't want tooltips | 697 | // if we have no cursor, probably don't want tooltips |
698 | QToolTip::setEnabled( FALSE ); | 698 | QToolTip::setEnabled( FALSE ); |
699 | #endif | 699 | #endif |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | #ifdef QTOPIA_INTERNAL_INITAPP | 703 | #ifdef QTOPIA_INTERNAL_INITAPP |
704 | void QPEApplication::initApp( int argc, char **argv ) | 704 | void QPEApplication::initApp( int argc, char **argv ) |
705 | { | 705 | { |
706 | delete pidChannel; | 706 | delete pidChannel; |
707 | d->keep_running = TRUE; | 707 | d->keep_running = TRUE; |
708 | d->preloaded = FALSE; | 708 | d->preloaded = FALSE; |
709 | d->forceshow = FALSE; | 709 | d->forceshow = FALSE; |
710 | 710 | ||
711 | QCString channel = QCString(argv[0]); | 711 | QCString channel = QCString(argv[0]); |
712 | 712 | ||
713 | channel.replace(QRegExp(".*/"),""); | 713 | channel.replace(QRegExp(".*/"),""); |
714 | d->appName = channel; | 714 | d->appName = channel; |
715 | 715 | ||
716 | #if QT_VERSION > 235 | ||
716 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 717 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
718 | #endif | ||
717 | 719 | ||
718 | channel = "QPE/Application/" + channel; | 720 | channel = "QPE/Application/" + channel; |
719 | pidChannel = new QCopChannel( channel, this); | 721 | pidChannel = new QCopChannel( channel, this); |
720 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 722 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
721 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 723 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
722 | 724 | ||
723 | processQCopFile(); | 725 | processQCopFile(); |
724 | d->keep_running = d->qcopq.isEmpty(); | 726 | d->keep_running = d->qcopq.isEmpty(); |
725 | 727 | ||
726 | for (int a=0; a<argc; a++) { | 728 | for (int a=0; a<argc; a++) { |
727 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 729 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
728 | argv[a] = argv[a+1]; | 730 | argv[a] = argv[a+1]; |
729 | a++; | 731 | a++; |
730 | d->preloaded = TRUE; | 732 | d->preloaded = TRUE; |
731 | argc-=1; | 733 | argc-=1; |
732 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 734 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
733 | argv[a] = argv[a+1]; | 735 | argv[a] = argv[a+1]; |
734 | a++; | 736 | a++; |
735 | d->preloaded = TRUE; | 737 | d->preloaded = TRUE; |
736 | d->forceshow = TRUE; | 738 | d->forceshow = TRUE; |
737 | argc-=1; | 739 | argc-=1; |
738 | } | 740 | } |
739 | } | 741 | } |
740 | 742 | ||
741 | /* overide stored arguments */ | 743 | /* overide stored arguments */ |
742 | setArgs(argc, argv); | 744 | setArgs(argc, argv); |
743 | } | 745 | } |
744 | #endif | 746 | #endif |
745 | 747 | ||
746 | 748 | ||
747 | static QPtrDict<void>* inputMethodDict = 0; | 749 | static QPtrDict<void>* inputMethodDict = 0; |
748 | static void createInputMethodDict() | 750 | static void createInputMethodDict() |
749 | { | 751 | { |
750 | if ( !inputMethodDict ) | 752 | if ( !inputMethodDict ) |
751 | inputMethodDict = new QPtrDict<void>; | 753 | inputMethodDict = new QPtrDict<void>; |
752 | } | 754 | } |
753 | 755 | ||
754 | /*! | 756 | /*! |
755 | Returns the currently set hint to the system as to whether | 757 | Returns the currently set hint to the system as to whether |
756 | widget \a w has any use for text input methods. | 758 | widget \a w has any use for text input methods. |
757 | 759 | ||
758 | 760 | ||
759 | \sa setInputMethodHint() InputMethodHint | 761 | \sa setInputMethodHint() InputMethodHint |
760 | */ | 762 | */ |
761 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 763 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
762 | { | 764 | { |
763 | if ( inputMethodDict && w ) | 765 | if ( inputMethodDict && w ) |
764 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 766 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
765 | return Normal; | 767 | return Normal; |
766 | } | 768 | } |
767 | 769 | ||
768 | /*! | 770 | /*! |
769 | \enum QPEApplication::InputMethodHint | 771 | \enum QPEApplication::InputMethodHint |
770 | 772 | ||
771 | \value Normal the application sometimes needs text input (the default). | 773 | \value Normal the application sometimes needs text input (the default). |
772 | \value AlwaysOff the application never needs text input. | 774 | \value AlwaysOff the application never needs text input. |
773 | \value AlwaysOn the application always needs text input. | 775 | \value AlwaysOn the application always needs text input. |
774 | */ | 776 | */ |
775 | 777 | ||
776 | /*! | 778 | /*! |
777 | Hints to the system that widget \a w has use for text input methods | 779 | Hints to the system that widget \a w has use for text input methods |
778 | as specified by \a mode. | 780 | as specified by \a mode. |
779 | 781 | ||
780 | \sa inputMethodHint() InputMethodHint | 782 | \sa inputMethodHint() InputMethodHint |
781 | */ | 783 | */ |
782 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 784 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
783 | { | 785 | { |
784 | createInputMethodDict(); | 786 | createInputMethodDict(); |
785 | if ( mode == Normal ) { | 787 | if ( mode == Normal ) { |
786 | inputMethodDict->remove | 788 | inputMethodDict->remove |
787 | ( w ); | 789 | ( w ); |
788 | } | 790 | } |
789 | else { | 791 | else { |
790 | inputMethodDict->insert( w, ( void* ) mode ); | 792 | inputMethodDict->insert( w, ( void* ) mode ); |
791 | } | 793 | } |
792 | } | 794 | } |
793 | 795 | ||
794 | class HackDialog : public QDialog | 796 | class HackDialog : public QDialog |
795 | { | 797 | { |
796 | public: | 798 | public: |
797 | void acceptIt() | 799 | void acceptIt() |
798 | { | 800 | { |
799 | accept(); | 801 | accept(); |
800 | } | 802 | } |
801 | void rejectIt() | 803 | void rejectIt() |
802 | { | 804 | { |
803 | reject(); | 805 | reject(); |
804 | } | 806 | } |
805 | }; | 807 | }; |
806 | 808 | ||
807 | 809 | ||
808 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 810 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
809 | { | 811 | { |
810 | // specialised actions for certain widgets. May want to | 812 | // specialised actions for certain widgets. May want to |
811 | // add more stuff here. | 813 | // add more stuff here. |
812 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 814 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
813 | && activePopupWidget() ->parentWidget() | 815 | && activePopupWidget() ->parentWidget() |
814 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 816 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
815 | key = Qt::Key_Return; | 817 | key = Qt::Key_Return; |
816 | 818 | ||
817 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 819 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
818 | key = Qt::Key_Return; | 820 | key = Qt::Key_Return; |
819 | 821 | ||
820 | #ifdef QWS | 822 | #ifdef QWS |
821 | 823 | ||
822 | ke->simpleData.keycode = key; | 824 | ke->simpleData.keycode = key; |
823 | #endif | 825 | #endif |
824 | } | 826 | } |
825 | 827 | ||
826 | class HackWidget : public QWidget | 828 | class HackWidget : public QWidget |
827 | { | 829 | { |
828 | public: | 830 | public: |
829 | bool needsOk() | 831 | bool needsOk() |
830 | { | 832 | { |
831 | return ( getWState() & WState_Reserved1 ); | 833 | return ( getWState() & WState_Reserved1 ); |
832 | } | 834 | } |
833 | }; | 835 | }; |
834 | 836 | ||
835 | /*! | 837 | /*! |
836 | \internal | 838 | \internal |
837 | */ | 839 | */ |
838 | 840 | ||
839 | #ifdef QWS | 841 | #ifdef QWS |
840 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 842 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
841 | { | 843 | { |
842 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 844 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
843 | if ( qApp->type() != QApplication::GuiServer ) { | 845 | if ( qApp->type() != QApplication::GuiServer ) { |
844 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 846 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
845 | e << d->appName; | 847 | e << d->appName; |
846 | } | 848 | } |
847 | d->notbusysent = TRUE; | 849 | d->notbusysent = TRUE; |
848 | } | 850 | } |
849 | if ( type() == GuiServer ) { | 851 | if ( type() == GuiServer ) { |
850 | switch ( e->type ) { | 852 | switch ( e->type ) { |
851 | case QWSEvent::Mouse: | 853 | case QWSEvent::Mouse: |
852 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 854 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
853 | emit clientMoused(); | 855 | emit clientMoused(); |
854 | break; | 856 | break; |
855 | default: | 857 | default: |
856 | break; | 858 | break; |
857 | } | 859 | } |
858 | } | 860 | } |
859 | if ( e->type == QWSEvent::Key ) { | 861 | if ( e->type == QWSEvent::Key ) { |
860 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 862 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
861 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 863 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
862 | // Use special "OK" key to press "OK" on top level widgets | 864 | // Use special "OK" key to press "OK" on top level widgets |
863 | QWidget * active = activeWindow(); | 865 | QWidget * active = activeWindow(); |
864 | QWidget *popup = 0; | 866 | QWidget *popup = 0; |
865 | if ( active && active->isPopup() ) { | 867 | if ( active && active->isPopup() ) { |
866 | popup = active; | 868 | popup = active; |
867 | active = active->parentWidget(); | 869 | active = active->parentWidget(); |
868 | } | 870 | } |
869 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 871 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
870 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 872 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
871 | if ( ke->simpleData.is_press ) { | 873 | if ( ke->simpleData.is_press ) { |
872 | if ( popup ) | 874 | if ( popup ) |
873 | popup->close(); | 875 | popup->close(); |
874 | if ( active->inherits( "QDialog" ) ) { | 876 | if ( active->inherits( "QDialog" ) ) { |
875 | HackDialog * d = ( HackDialog * ) active; | 877 | HackDialog * d = ( HackDialog * ) active; |
876 | d->acceptIt(); | 878 | d->acceptIt(); |
877 | return TRUE; | 879 | return TRUE; |
878 | } | 880 | } |
879 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 881 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
880 | QSignal s; | 882 | QSignal s; |
881 | s.connect( active, SLOT( accept() ) ); | 883 | s.connect( active, SLOT( accept() ) ); |
882 | s.activate(); | 884 | s.activate(); |
883 | } | 885 | } |
884 | else { | 886 | else { |
885 | // do the same as with the select key: Map to the default action of the widget: | 887 | // do the same as with the select key: Map to the default action of the widget: |
886 | mapToDefaultAction( ke, Qt::Key_Return ); | 888 | mapToDefaultAction( ke, Qt::Key_Return ); |
887 | } | 889 | } |
888 | } | 890 | } |
889 | } | 891 | } |
890 | } | 892 | } |
891 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 893 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
892 | // Use special "select" key to do whatever default action a widget has | 894 | // Use special "select" key to do whatever default action a widget has |
893 | mapToDefaultAction( ke, Qt::Key_Space ); | 895 | mapToDefaultAction( ke, Qt::Key_Space ); |
894 | } | 896 | } |
895 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 897 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
896 | ke->simpleData.is_press ) { | 898 | ke->simpleData.is_press ) { |
897 | // Escape key closes app if focus on toplevel | 899 | // Escape key closes app if focus on toplevel |
898 | QWidget * active = activeWindow(); | 900 | QWidget * active = activeWindow(); |
899 | if ( active && active->testWFlags( WType_TopLevel ) && | 901 | if ( active && active->testWFlags( WType_TopLevel ) && |
900 | ( int ) active->winId() == ke->simpleData.window && | 902 | ( int ) active->winId() == ke->simpleData.window && |
901 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 903 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
902 | if ( active->inherits( "QDialog" ) ) { | 904 | if ( active->inherits( "QDialog" ) ) { |
903 | HackDialog * d = ( HackDialog * ) active; | 905 | HackDialog * d = ( HackDialog * ) active; |
904 | d->rejectIt(); | 906 | d->rejectIt(); |
905 | return TRUE; | 907 | return TRUE; |
906 | } | 908 | } |
907 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 909 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
908 | active->close(); | 910 | active->close(); |
909 | } | 911 | } |
910 | } | 912 | } |
911 | } | 913 | } |
912 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 914 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
913 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 915 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
914 | // but we cannot access libopie function within libqpe :( | 916 | // but we cannot access libopie function within libqpe :( |
915 | 917 | ||
916 | QWidget * active = activeWindow ( ); | 918 | QWidget * active = activeWindow ( ); |
917 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 919 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
918 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 920 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
919 | QChar ch ( ke-> simpleData.unicode ); | 921 | QChar ch ( ke-> simpleData.unicode ); |
920 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 922 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
921 | ke-> simpleData.keycode, | 923 | ke-> simpleData.keycode, |
922 | ch. latin1 ( ), | 924 | ch. latin1 ( ), |
923 | ke-> simpleData.modifiers, | 925 | ke-> simpleData.modifiers, |
924 | QString ( ch ), | 926 | QString ( ch ), |
925 | ke-> simpleData.is_auto_repeat, 1 ); | 927 | ke-> simpleData.is_auto_repeat, 1 ); |
926 | 928 | ||
927 | QObject *which = QWidget::keyboardGrabber ( ); | 929 | QObject *which = QWidget::keyboardGrabber ( ); |
928 | if ( !which ) | 930 | if ( !which ) |
929 | which = QApplication::focusWidget ( ); | 931 | which = QApplication::focusWidget ( ); |
930 | if ( !which ) | 932 | if ( !which ) |
931 | which = QApplication::activeWindow ( ); | 933 | which = QApplication::activeWindow ( ); |
932 | if ( !which ) | 934 | if ( !which ) |
933 | which = qApp; | 935 | which = qApp; |
934 | 936 | ||
935 | QApplication::sendEvent ( which, &qke ); | 937 | QApplication::sendEvent ( which, &qke ); |
936 | } | 938 | } |
937 | else { // we didn't grab the keyboard, so send the event to the launcher | 939 | else { // we didn't grab the keyboard, so send the event to the launcher |
938 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 940 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
939 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 941 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
940 | } | 942 | } |
941 | } | 943 | } |
942 | return true; | 944 | return true; |
943 | } | 945 | } |
944 | } | 946 | } |
945 | if ( e->type == QWSEvent::Focus ) { | 947 | if ( e->type == QWSEvent::Focus ) { |
946 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 948 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
947 | if ( !fe->simpleData.get_focus ) { | 949 | if ( !fe->simpleData.get_focus ) { |
948 | QWidget * active = activeWindow(); | 950 | QWidget * active = activeWindow(); |
949 | while ( active && active->isPopup() ) { | 951 | while ( active && active->isPopup() ) { |
950 | active->close(); | 952 | active->close(); |
951 | active = activeWindow(); | 953 | active = activeWindow(); |
952 | } | 954 | } |
953 | } | 955 | } |
954 | else { | 956 | else { |
955 | // make sure our modal widget is ALWAYS on top | 957 | // make sure our modal widget is ALWAYS on top |
956 | QWidget *topm = activeModalWidget(); | 958 | QWidget *topm = activeModalWidget(); |
957 | if ( topm ) { | 959 | if ( topm ) { |
958 | topm->raise(); | 960 | topm->raise(); |
959 | } | 961 | } |
960 | } | 962 | } |
961 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 963 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
962 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 964 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
963 | if ( m == AlwaysOff ) | 965 | if ( m == AlwaysOff ) |
964 | Global::hideInputMethod(); | 966 | Global::hideInputMethod(); |
965 | if ( m == AlwaysOn ) | 967 | if ( m == AlwaysOn ) |
966 | Global::showInputMethod(); | 968 | Global::showInputMethod(); |
967 | } | 969 | } |
968 | } | 970 | } |
969 | 971 | ||
970 | 972 | ||
971 | return QApplication::qwsEventFilter( e ); | 973 | return QApplication::qwsEventFilter( e ); |
972 | } | 974 | } |
973 | #endif | 975 | #endif |
974 | 976 | ||
975 | /*! | 977 | /*! |
976 | Destroys the QPEApplication. | 978 | Destroys the QPEApplication. |
977 | */ | 979 | */ |
978 | QPEApplication::~QPEApplication() | 980 | QPEApplication::~QPEApplication() |
979 | { | 981 | { |
980 | ungrabKeyboard(); | 982 | ungrabKeyboard(); |
981 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 983 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
982 | // Need to delete QCopChannels early, since the display will | 984 | // Need to delete QCopChannels early, since the display will |
983 | // be gone by the time we get to ~QObject(). | 985 | // be gone by the time we get to ~QObject(). |
984 | delete sysChannel; | 986 | delete sysChannel; |
985 | delete pidChannel; | 987 | delete pidChannel; |
986 | #endif | 988 | #endif |
987 | 989 | ||
988 | delete d; | 990 | delete d; |
989 | } | 991 | } |
990 | 992 | ||
991 | /*! | 993 | /*! |
992 | Returns <tt>$OPIEDIR/</tt>. | 994 | Returns <tt>$OPIEDIR/</tt>. |
993 | */ | 995 | */ |
994 | QString QPEApplication::qpeDir() | 996 | QString QPEApplication::qpeDir() |
995 | { | 997 | { |
996 | const char * base = getenv( "OPIEDIR" ); | 998 | const char * base = getenv( "OPIEDIR" ); |
997 | if ( base ) | 999 | if ( base ) |
998 | return QString( base ) + "/"; | 1000 | return QString( base ) + "/"; |
999 | 1001 | ||
1000 | return QString( "../" ); | 1002 | return QString( "../" ); |
1001 | } | 1003 | } |
1002 | 1004 | ||
1003 | /*! | 1005 | /*! |
1004 | Returns the user's current Document directory. There is a trailing "/". | 1006 | Returns the user's current Document directory. There is a trailing "/". |
1005 | .. well, it does now,, and there's no trailing '/' | 1007 | .. well, it does now,, and there's no trailing '/' |
1006 | */ | 1008 | */ |
1007 | QString QPEApplication::documentDir() | 1009 | QString QPEApplication::documentDir() |
1008 | { | 1010 | { |
1009 | const char* base = getenv( "HOME"); | 1011 | const char* base = getenv( "HOME"); |
1010 | if ( base ) | 1012 | if ( base ) |
1011 | return QString( base ) + "/Documents"; | 1013 | return QString( base ) + "/Documents"; |
1012 | 1014 | ||
1013 | return QString( "../Documents" ); | 1015 | return QString( "../Documents" ); |
1014 | } | 1016 | } |
1015 | 1017 | ||
1016 | static int deforient = -1; | 1018 | static int deforient = -1; |
1017 | 1019 | ||
1018 | /*! | 1020 | /*! |
1019 | \internal | 1021 | \internal |
1020 | */ | 1022 | */ |
1021 | int QPEApplication::defaultRotation() | 1023 | int QPEApplication::defaultRotation() |
1022 | { | 1024 | { |
1023 | if ( deforient < 0 ) { | 1025 | if ( deforient < 0 ) { |
1024 | QString d = getenv( "QWS_DISPLAY" ); | 1026 | QString d = getenv( "QWS_DISPLAY" ); |
1025 | if ( d.contains( "Rot90" ) ) { | 1027 | if ( d.contains( "Rot90" ) ) { |
1026 | deforient = 90; | 1028 | deforient = 90; |
1027 | } | 1029 | } |
1028 | else if ( d.contains( "Rot180" ) ) { | 1030 | else if ( d.contains( "Rot180" ) ) { |
1029 | deforient = 180; | 1031 | deforient = 180; |
1030 | } | 1032 | } |
1031 | else if ( d.contains( "Rot270" ) ) { | 1033 | else if ( d.contains( "Rot270" ) ) { |
1032 | deforient = 270; | 1034 | deforient = 270; |
1033 | } | 1035 | } |
1034 | else { | 1036 | else { |
1035 | deforient = 0; | 1037 | deforient = 0; |
1036 | } | 1038 | } |
1037 | } | 1039 | } |
1038 | return deforient; | 1040 | return deforient; |
1039 | } | 1041 | } |
1040 | 1042 | ||
1041 | /*! | 1043 | /*! |
1042 | \internal | 1044 | \internal |
1043 | */ | 1045 | */ |
1044 | void QPEApplication::setDefaultRotation( int r ) | 1046 | void QPEApplication::setDefaultRotation( int r ) |
1045 | { | 1047 | { |
1046 | if ( qApp->type() == GuiServer ) { | 1048 | if ( qApp->type() == GuiServer ) { |
1047 | deforient = r; | 1049 | deforient = r; |
1048 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1050 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1049 | Config config("qpe"); | 1051 | Config config("qpe"); |
1050 | config.setGroup( "Rotation" ); | 1052 | config.setGroup( "Rotation" ); |
1051 | config.writeEntry( "Rot", r ); | 1053 | config.writeEntry( "Rot", r ); |
1052 | } | 1054 | } |
1053 | else { | 1055 | else { |
1054 | #ifndef QT_NO_COP | 1056 | #ifndef QT_NO_COP |
1055 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1057 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1056 | e << r; | 1058 | e << r; |
1057 | } | 1059 | } |
1058 | #endif | 1060 | #endif |
1059 | 1061 | ||
1060 | } | 1062 | } |
1061 | } | 1063 | } |
1062 | 1064 | ||
1063 | 1065 | ||
1064 | /*! | 1066 | /*! |
1065 | \internal | 1067 | \internal |
1066 | */ | 1068 | */ |
1067 | void QPEApplication::applyStyle() | 1069 | void QPEApplication::applyStyle() |
1068 | { | 1070 | { |
1069 | Config config( "qpe" ); | 1071 | Config config( "qpe" ); |
1070 | config.setGroup( "Appearance" ); | 1072 | config.setGroup( "Appearance" ); |
1071 | 1073 | ||
1072 | #if QT_VERSION > 233 | 1074 | #if QT_VERSION > 233 |
1073 | // don't block ourselves ... | 1075 | // don't block ourselves ... |
1074 | Opie::force_appearance = 0; | 1076 | Opie::force_appearance = 0; |
1075 | 1077 | ||
1076 | static QString appname = Opie::binaryName ( ); | 1078 | static QString appname = Opie::binaryName ( ); |
1077 | 1079 | ||
1078 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1080 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1079 | int nostyle = 0; | 1081 | int nostyle = 0; |
1080 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1082 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1081 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1083 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1082 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1084 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1083 | break; | 1085 | break; |
1084 | } | 1086 | } |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | // Widget style | 1089 | // Widget style |
1088 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1090 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1089 | 1091 | ||
1090 | // don't set a custom style | 1092 | // don't set a custom style |
1091 | if ( nostyle & Opie::Force_Style ) | 1093 | if ( nostyle & Opie::Force_Style ) |
1092 | style = "FlatStyle"; | 1094 | style = "FlatStyle"; |
1093 | 1095 | ||
1094 | internalSetStyle ( style ); | 1096 | internalSetStyle ( style ); |
1095 | 1097 | ||
1096 | // Colors - from /etc/colors/Liquid.scheme | 1098 | // Colors - from /etc/colors/Liquid.scheme |
1097 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1099 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1098 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1100 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1099 | QPalette pal( btncolor, bgcolor ); | 1101 | QPalette pal( btncolor, bgcolor ); |
1100 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1102 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1101 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1103 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1102 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1104 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1103 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1105 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1104 | color = config.readEntry( "Text", "#000000" ); | 1106 | color = config.readEntry( "Text", "#000000" ); |
1105 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1107 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1106 | color = config.readEntry( "ButtonText", "#000000" ); | 1108 | color = config.readEntry( "ButtonText", "#000000" ); |
1107 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1109 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1108 | color = config.readEntry( "Base", "#FFFFFF" ); | 1110 | color = config.readEntry( "Base", "#FFFFFF" ); |
1109 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1111 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1110 | 1112 | ||
1111 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1113 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1112 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1114 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1113 | 1115 | ||
1114 | setPalette( pal, TRUE ); | 1116 | setPalette( pal, TRUE ); |
1115 | 1117 | ||
1116 | // Window Decoration | 1118 | // Window Decoration |
1117 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1119 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1118 | 1120 | ||
1119 | // don't set a custom deco | 1121 | // don't set a custom deco |
1120 | if ( nostyle & Opie::Force_Decoration ) | 1122 | if ( nostyle & Opie::Force_Decoration ) |
1121 | dec = ""; | 1123 | dec = ""; |
1122 | 1124 | ||
1123 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1125 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1124 | 1126 | ||
1125 | if ( dec != d->decorationName ) { | 1127 | if ( dec != d->decorationName ) { |
1126 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1128 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1127 | d->decorationName = dec; | 1129 | d->decorationName = dec; |
1128 | } | 1130 | } |
1129 | 1131 | ||
1130 | // Font | 1132 | // Font |
1131 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1133 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1132 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1134 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1133 | 1135 | ||
1134 | // don't set a custom font | 1136 | // don't set a custom font |
1135 | if ( nostyle & Opie::Force_Font ) { | 1137 | if ( nostyle & Opie::Force_Font ) { |
1136 | ff = "Vera"; | 1138 | ff = "Vera"; |
1137 | fs = 10; | 1139 | fs = 10; |
1138 | } | 1140 | } |
1139 | 1141 | ||
1140 | setFont ( QFont ( ff, fs ), true ); | 1142 | setFont ( QFont ( ff, fs ), true ); |
1141 | 1143 | ||
1142 | // revert to global blocking policy ... | 1144 | // revert to global blocking policy ... |
1143 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1145 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1144 | Opie::force_appearance &= ~nostyle; | 1146 | Opie::force_appearance &= ~nostyle; |
1145 | #endif | 1147 | #endif |
1146 | } | 1148 | } |
1147 | 1149 | ||
1148 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1150 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1149 | { | 1151 | { |
1150 | #ifdef Q_WS_QWS | 1152 | #ifdef Q_WS_QWS |
1151 | QDataStream stream( data, IO_ReadOnly ); | 1153 | QDataStream stream( data, IO_ReadOnly ); |
1152 | if ( msg == "applyStyle()" ) { | 1154 | if ( msg == "applyStyle()" ) { |
1153 | applyStyle(); | 1155 | applyStyle(); |
1154 | } | 1156 | } |
1155 | else if ( msg == "toggleApplicationMenu()" ) { | 1157 | else if ( msg == "toggleApplicationMenu()" ) { |
1156 | QWidget *active = activeWindow ( ); | 1158 | QWidget *active = activeWindow ( ); |
1157 | 1159 | ||
1158 | if ( active ) { | 1160 | if ( active ) { |
1159 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1161 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1160 | bool oldactive = man-> isActive ( ); | 1162 | bool oldactive = man-> isActive ( ); |
1161 | 1163 | ||
1162 | man-> setActive( !man-> isActive() ); | 1164 | man-> setActive( !man-> isActive() ); |
1163 | 1165 | ||
1164 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1166 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1165 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1167 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1166 | } | 1168 | } |
1167 | } | 1169 | } |
1168 | } | 1170 | } |
1169 | else if ( msg == "setDefaultRotation(int)" ) { | 1171 | else if ( msg == "setDefaultRotation(int)" ) { |
1170 | if ( type() == GuiServer ) { | 1172 | if ( type() == GuiServer ) { |
1171 | int r; | 1173 | int r; |
1172 | stream >> r; | 1174 | stream >> r; |
1173 | setDefaultRotation( r ); | 1175 | setDefaultRotation( r ); |
1174 | } | 1176 | } |
1175 | } | 1177 | } |
1176 | else if ( msg == "setCurrentRotation(int)" ) { | 1178 | else if ( msg == "setCurrentRotation(int)" ) { |
1177 | int r; | 1179 | int r; |
1178 | stream >> r; | 1180 | stream >> r; |
1179 | setCurrentRotation( r ); | 1181 | setCurrentRotation( r ); |
1180 | } | 1182 | } |
1181 | else if ( msg == "shutdown()" ) { | 1183 | else if ( msg == "shutdown()" ) { |
1182 | if ( type() == GuiServer ) | 1184 | if ( type() == GuiServer ) |
1183 | shutdown(); | 1185 | shutdown(); |
1184 | } | 1186 | } |
1185 | else if ( msg == "quit()" ) { | 1187 | else if ( msg == "quit()" ) { |
1186 | if ( type() != GuiServer ) | 1188 | if ( type() != GuiServer ) |
1187 | tryQuit(); | 1189 | tryQuit(); |
1188 | } | 1190 | } |
1189 | else if ( msg == "forceQuit()" ) { | 1191 | else if ( msg == "forceQuit()" ) { |
1190 | if ( type() != GuiServer ) | 1192 | if ( type() != GuiServer ) |
1191 | quit(); | 1193 | quit(); |
1192 | } | 1194 | } |
1193 | else if ( msg == "restart()" ) { | 1195 | else if ( msg == "restart()" ) { |
1194 | if ( type() == GuiServer ) | 1196 | if ( type() == GuiServer ) |
1195 | restart(); | 1197 | restart(); |
1196 | } | 1198 | } |
1197 | else if ( msg == "language(QString)" ) { | 1199 | else if ( msg == "language(QString)" ) { |
1198 | if ( type() == GuiServer ) { | 1200 | if ( type() == GuiServer ) { |
1199 | QString l; | 1201 | QString l; |
1200 | stream >> l; | 1202 | stream >> l; |
1201 | QString cl = getenv( "LANG" ); | 1203 | QString cl = getenv( "LANG" ); |
1202 | if ( cl != l ) { | 1204 | if ( cl != l ) { |
1203 | if ( l.isNull() ) | 1205 | if ( l.isNull() ) |
1204 | unsetenv( "LANG" ); | 1206 | unsetenv( "LANG" ); |
1205 | else | 1207 | else |
1206 | setenv( "LANG", l.latin1(), 1 ); | 1208 | setenv( "LANG", l.latin1(), 1 ); |
1207 | restart(); | 1209 | restart(); |
1208 | } | 1210 | } |
1209 | } | 1211 | } |
1210 | } | 1212 | } |
1211 | else if ( msg == "timeChange(QString)" ) { | 1213 | else if ( msg == "timeChange(QString)" ) { |
1212 | QString t; | 1214 | QString t; |
1213 | stream >> t; | 1215 | stream >> t; |
1214 | if ( t.isNull() ) | 1216 | if ( t.isNull() ) |
1215 | unsetenv( "TZ" ); | 1217 | unsetenv( "TZ" ); |
1216 | else | 1218 | else |
1217 | setenv( "TZ", t.latin1(), 1 ); | 1219 | setenv( "TZ", t.latin1(), 1 ); |
1218 | // emit the signal so everyone else knows... | 1220 | // emit the signal so everyone else knows... |
1219 | emit timeChanged(); | 1221 | emit timeChanged(); |
1220 | } | 1222 | } |
1221 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1223 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1222 | if ( type() == GuiServer ) { | 1224 | if ( type() == GuiServer ) { |
1223 | QDateTime when; | 1225 | QDateTime when; |
1224 | QCString channel, message; | 1226 | QCString channel, message; |
1225 | int data; | 1227 | int data; |
1226 | stream >> when >> channel >> message >> data; | 1228 | stream >> when >> channel >> message >> data; |
1227 | AlarmServer::addAlarm( when, channel, message, data ); | 1229 | AlarmServer::addAlarm( when, channel, message, data ); |
1228 | } | 1230 | } |