-rw-r--r-- | library/qpeapplication.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 34f5e6a..d959c7a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -236,2061 +236,2061 @@ public: | |||
236 | } else { //no stored rectangle, make an estimation | 236 | } else { //no stored rectangle, make an estimation |
237 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 237 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
238 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 238 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
239 | mw->move( QMAX(x,0), QMAX(y,0) ); | 239 | mw->move( QMAX(x,0), QMAX(y,0) ); |
240 | #ifdef Q_WS_QWS | 240 | #ifdef Q_WS_QWS |
241 | if ( !nomaximize ) | 241 | if ( !nomaximize ) |
242 | mw->showMaximized(); | 242 | mw->showMaximized(); |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | if ( max && !nomaximize ) | 245 | if ( max && !nomaximize ) |
246 | mw->showMaximized(); | 246 | mw->showMaximized(); |
247 | else | 247 | else |
248 | mw->show(); | 248 | mw->show(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 253 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
254 | { | 254 | { |
255 | if (!saveWindowsPos) | 255 | if (!saveWindowsPos) |
256 | return FALSE; | 256 | return FALSE; |
257 | maximized = TRUE; | 257 | maximized = TRUE; |
258 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 258 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
259 | if ( qApp->desktop()->width() <= 350 ) | 259 | if ( qApp->desktop()->width() <= 350 ) |
260 | return FALSE; | 260 | return FALSE; |
261 | 261 | ||
262 | Config cfg( "qpe" ); | 262 | Config cfg( "qpe" ); |
263 | cfg.setGroup("ApplicationPositions"); | 263 | cfg.setGroup("ApplicationPositions"); |
264 | QString str = cfg.readEntry( app, QString::null ); | 264 | QString str = cfg.readEntry( app, QString::null ); |
265 | QStringList l = QStringList::split(",", str); | 265 | QStringList l = QStringList::split(",", str); |
266 | 266 | ||
267 | if ( l.count() == 5) { | 267 | if ( l.count() == 5) { |
268 | p.setX( l[0].toInt() ); | 268 | p.setX( l[0].toInt() ); |
269 | p.setY( l[1].toInt() ); | 269 | p.setY( l[1].toInt() ); |
270 | 270 | ||
271 | s.setWidth( l[2].toInt() ); | 271 | s.setWidth( l[2].toInt() ); |
272 | s.setHeight( l[3].toInt() ); | 272 | s.setHeight( l[3].toInt() ); |
273 | 273 | ||
274 | maximized = l[4].toInt(); | 274 | maximized = l[4].toInt(); |
275 | 275 | ||
276 | return TRUE; | 276 | return TRUE; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 281 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
282 | { | 282 | { |
283 | #ifndef Q_WS_QWS | 283 | #ifndef Q_WS_QWS |
284 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 284 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
285 | #endif | 285 | #endif |
286 | int maxX = qt_maxWindowRect.width(); | 286 | int maxX = qt_maxWindowRect.width(); |
287 | int maxY = qt_maxWindowRect.height(); | 287 | int maxY = qt_maxWindowRect.height(); |
288 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 288 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
289 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 289 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
290 | 290 | ||
291 | // total window size is not allowed to be larger than desktop window size | 291 | // total window size is not allowed to be larger than desktop window size |
292 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 292 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
293 | return FALSE; | 293 | return FALSE; |
294 | 294 | ||
295 | if ( wWidth > maxX ) { | 295 | if ( wWidth > maxX ) { |
296 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 296 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
297 | wWidth = maxX; | 297 | wWidth = maxX; |
298 | } | 298 | } |
299 | 299 | ||
300 | if ( wHeight > maxY ) { | 300 | if ( wHeight > maxY ) { |
301 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 301 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
302 | wHeight = maxY; | 302 | wHeight = maxY; |
303 | } | 303 | } |
304 | 304 | ||
305 | // any smaller than this and the maximize/close/help buttons will be overlapping | 305 | // any smaller than this and the maximize/close/help buttons will be overlapping |
306 | if ( wWidth < 80 || wHeight < 60 ) | 306 | if ( wWidth < 80 || wHeight < 60 ) |
307 | return FALSE; | 307 | return FALSE; |
308 | 308 | ||
309 | if ( p.x() < 0 ) | 309 | if ( p.x() < 0 ) |
310 | p.setX(0); | 310 | p.setX(0); |
311 | if ( p.y() < 0 ) | 311 | if ( p.y() < 0 ) |
312 | p.setY(0); | 312 | p.setY(0); |
313 | 313 | ||
314 | if ( p.x() + wWidth > maxX ) | 314 | if ( p.x() + wWidth > maxX ) |
315 | p.setX( maxX - wWidth ); | 315 | p.setX( maxX - wWidth ); |
316 | if ( p.y() + wHeight > maxY ) | 316 | if ( p.y() + wHeight > maxY ) |
317 | p.setY( maxY - wHeight ); | 317 | p.setY( maxY - wHeight ); |
318 | 318 | ||
319 | return TRUE; | 319 | return TRUE; |
320 | } | 320 | } |
321 | 321 | ||
322 | static void store_widget_rect(QWidget *w, QString &app) | 322 | static void store_widget_rect(QWidget *w, QString &app) |
323 | { | 323 | { |
324 | if( !w ) | 324 | if( !w ) |
325 | return; | 325 | return; |
326 | if (!saveWindowsPos) | 326 | if (!saveWindowsPos) |
327 | return; | 327 | return; |
328 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 328 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
329 | if ( qApp->desktop()->width() <= 350 ) | 329 | if ( qApp->desktop()->width() <= 350 ) |
330 | return; | 330 | return; |
331 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 331 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
332 | // get the non-maximized version, so we have to do it the hard way ) | 332 | // get the non-maximized version, so we have to do it the hard way ) |
333 | int offsetX = w->x() - w->geometry().left(); | 333 | int offsetX = w->x() - w->geometry().left(); |
334 | int offsetY = w->y() - w->geometry().top(); | 334 | int offsetY = w->y() - w->geometry().top(); |
335 | 335 | ||
336 | QRect r; | 336 | QRect r; |
337 | if ( w->isMaximized() ) | 337 | if ( w->isMaximized() ) |
338 | r = ( (HackWidget *) w)->normalGeometry(); | 338 | r = ( (HackWidget *) w)->normalGeometry(); |
339 | else | 339 | else |
340 | r = w->geometry(); | 340 | r = w->geometry(); |
341 | 341 | ||
342 | // Stores the window placement as pos(), size() (due to the offset mapping) | 342 | // Stores the window placement as pos(), size() (due to the offset mapping) |
343 | Config cfg( "qpe" ); | 343 | Config cfg( "qpe" ); |
344 | cfg.setGroup("ApplicationPositions"); | 344 | cfg.setGroup("ApplicationPositions"); |
345 | QString s; | 345 | QString s; |
346 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 346 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
347 | cfg.writeEntry( app, s ); | 347 | cfg.writeEntry( app, s ); |
348 | } | 348 | } |
349 | 349 | ||
350 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 350 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
351 | { | 351 | { |
352 | /* | 352 | /* |
353 | // This works but disable it for now until it is safe to apply | 353 | // This works but disable it for now until it is safe to apply |
354 | // What is does is scan the .desktop files of all the apps for | 354 | // What is does is scan the .desktop files of all the apps for |
355 | // the applnk that has the corresponding argv[0] as this program | 355 | // the applnk that has the corresponding argv[0] as this program |
356 | // then it uses the name stored in the .desktop file as the caption | 356 | // then it uses the name stored in the .desktop file as the caption |
357 | // for the main widget. This saves duplicating translations for | 357 | // for the main widget. This saves duplicating translations for |
358 | // the app name in the program and in the .desktop files. | 358 | // the app name in the program and in the .desktop files. |
359 | 359 | ||
360 | AppLnkSet apps( appsPath ); | 360 | AppLnkSet apps( appsPath ); |
361 | 361 | ||
362 | QList<AppLnk> appsList = apps.children(); | 362 | QList<AppLnk> appsList = apps.children(); |
363 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 363 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
364 | if ( (*it)->exec() == appName ) { | 364 | if ( (*it)->exec() == appName ) { |
365 | mw->setCaption( (*it)->name() ); | 365 | mw->setCaption( (*it)->name() ); |
366 | return TRUE; | 366 | return TRUE; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | */ | 369 | */ |
370 | return FALSE; | 370 | return FALSE; |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | void show(QWidget* mw, bool nomax) | 374 | void show(QWidget* mw, bool nomax) |
375 | { | 375 | { |
376 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 376 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
377 | nomaximize = nomax; | 377 | nomaximize = nomax; |
378 | qpe_main_widget = mw; | 378 | qpe_main_widget = mw; |
379 | qcopQok = TRUE; | 379 | qcopQok = TRUE; |
380 | #ifndef QT_NO_COP | 380 | #ifndef QT_NO_COP |
381 | 381 | ||
382 | sendQCopQ(); | 382 | sendQCopQ(); |
383 | #endif | 383 | #endif |
384 | 384 | ||
385 | if ( preloaded ) { | 385 | if ( preloaded ) { |
386 | if (forceshow) | 386 | if (forceshow) |
387 | show_mx(mw, nomax, appName); | 387 | show_mx(mw, nomax, appName); |
388 | } | 388 | } |
389 | else if ( keep_running ) { | 389 | else if ( keep_running ) { |
390 | show_mx(mw, nomax, appName); | 390 | show_mx(mw, nomax, appName); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | void loadTextCodecs() | 394 | void loadTextCodecs() |
395 | { | 395 | { |
396 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; | 396 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; |
397 | #ifdef Q_OS_MACX | 397 | #ifdef Q_OS_MACX |
398 | QDir dir( path, "lib*.dylib" ); | 398 | QDir dir( path, "lib*.dylib" ); |
399 | #else | 399 | #else |
400 | QDir dir( path, "lib*.so" ); | 400 | QDir dir( path, "lib*.so" ); |
401 | #endif | 401 | #endif |
402 | QStringList list; | 402 | QStringList list; |
403 | if ( dir. exists ( )) | 403 | if ( dir. exists ( )) |
404 | list = dir.entryList(); | 404 | list = dir.entryList(); |
405 | QStringList::Iterator it; | 405 | QStringList::Iterator it; |
406 | for ( it = list.begin(); it != list.end(); ++it ) { | 406 | for ( it = list.begin(); it != list.end(); ++it ) { |
407 | TextCodecInterface *iface = 0; | 407 | TextCodecInterface *iface = 0; |
408 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 408 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
409 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 409 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
410 | QValueList<int> mibs = iface->mibEnums(); | 410 | QValueList<int> mibs = iface->mibEnums(); |
411 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 411 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
412 | (void)iface->createForMib(*i); | 412 | (void)iface->createForMib(*i); |
413 | // ### it exists now; need to remember if we can delete it | 413 | // ### it exists now; need to remember if we can delete it |
414 | } | 414 | } |
415 | } | 415 | } |
416 | else { | 416 | else { |
417 | lib->unload(); | 417 | lib->unload(); |
418 | delete lib; | 418 | delete lib; |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | void loadImageCodecs() | 423 | void loadImageCodecs() |
424 | { | 424 | { |
425 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; | 425 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; |
426 | #ifdef Q_OS_MACX | 426 | #ifdef Q_OS_MACX |
427 | QDir dir( path, "lib*.dylib" ); | 427 | QDir dir( path, "lib*.dylib" ); |
428 | #else | 428 | #else |
429 | QDir dir( path, "lib*.so" ); | 429 | QDir dir( path, "lib*.so" ); |
430 | #endif | 430 | #endif |
431 | QStringList list; | 431 | QStringList list; |
432 | if ( dir. exists ( )) | 432 | if ( dir. exists ( )) |
433 | list = dir.entryList(); | 433 | list = dir.entryList(); |
434 | QStringList::Iterator it; | 434 | QStringList::Iterator it; |
435 | for ( it = list.begin(); it != list.end(); ++it ) { | 435 | for ( it = list.begin(); it != list.end(); ++it ) { |
436 | ImageCodecInterface *iface = 0; | 436 | ImageCodecInterface *iface = 0; |
437 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 437 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
438 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 438 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
439 | QStringList formats = iface->keys(); | 439 | QStringList formats = iface->keys(); |
440 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 440 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
441 | (void)iface->installIOHandler(*i); | 441 | (void)iface->installIOHandler(*i); |
442 | // ### it exists now; need to remember if we can delete it | 442 | // ### it exists now; need to remember if we can delete it |
443 | } | 443 | } |
444 | } | 444 | } |
445 | else { | 445 | else { |
446 | lib->unload(); | 446 | lib->unload(); |
447 | delete lib; | 447 | delete lib; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | } | 450 | } |
451 | 451 | ||
452 | }; | 452 | }; |
453 | 453 | ||
454 | class ResourceMimeFactory : public QMimeSourceFactory | 454 | class ResourceMimeFactory : public QMimeSourceFactory |
455 | { | 455 | { |
456 | public: | 456 | public: |
457 | ResourceMimeFactory() : resImage( 0 ) | 457 | ResourceMimeFactory() : resImage( 0 ) |
458 | { | 458 | { |
459 | setFilePath( Global::helpPath() ); | 459 | setFilePath( Global::helpPath() ); |
460 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 460 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
461 | } | 461 | } |
462 | ~ResourceMimeFactory() { | 462 | ~ResourceMimeFactory() { |
463 | delete resImage; | 463 | delete resImage; |
464 | } | 464 | } |
465 | 465 | ||
466 | const QMimeSource* data( const QString& abs_name ) const | 466 | const QMimeSource* data( const QString& abs_name ) const |
467 | { | 467 | { |
468 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 468 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
469 | if ( !r ) { | 469 | if ( !r ) { |
470 | int sl = abs_name.length(); | 470 | int sl = abs_name.length(); |
471 | do { | 471 | do { |
472 | sl = abs_name.findRev( '/', sl - 1 ); | 472 | sl = abs_name.findRev( '/', sl - 1 ); |
473 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 473 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
474 | int dot = name.findRev( '.' ); | 474 | int dot = name.findRev( '.' ); |
475 | if ( dot >= 0 ) | 475 | if ( dot >= 0 ) |
476 | name = name.left( dot ); | 476 | name = name.left( dot ); |
477 | QImage img = Resource::loadImage( name ); | 477 | QImage img = Resource::loadImage( name ); |
478 | if ( !img.isNull() ) { | 478 | if ( !img.isNull() ) { |
479 | delete resImage; | 479 | delete resImage; |
480 | resImage = new QImageDrag( img ); | 480 | resImage = new QImageDrag( img ); |
481 | r = resImage; | 481 | r = resImage; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | while ( !r && sl > 0 ); | 484 | while ( !r && sl > 0 ); |
485 | } | 485 | } |
486 | return r; | 486 | return r; |
487 | } | 487 | } |
488 | private: | 488 | private: |
489 | mutable QImageDrag *resImage; | 489 | mutable QImageDrag *resImage; |
490 | }; | 490 | }; |
491 | 491 | ||
492 | static int& hack(int& i) | 492 | static int& hack(int& i) |
493 | { | 493 | { |
494 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 494 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
495 | // These should be created, but aren't in Qt 2.3.0 | 495 | // These should be created, but aren't in Qt 2.3.0 |
496 | (void)new QUtf8Codec; | 496 | (void)new QUtf8Codec; |
497 | (void)new QUtf16Codec; | 497 | (void)new QUtf16Codec; |
498 | #endif | 498 | #endif |
499 | return i; | 499 | return i; |
500 | } | 500 | } |
501 | 501 | ||
502 | static int muted = 0; | 502 | static int muted = 0; |
503 | static int micMuted = 0; | 503 | static int micMuted = 0; |
504 | 504 | ||
505 | static void setVolume( int t = 0, int percent = -1 ) | 505 | static void setVolume( int t = 0, int percent = -1 ) |
506 | { | 506 | { |
507 | switch ( t ) { | 507 | switch ( t ) { |
508 | case 0: { | 508 | case 0: { |
509 | Config cfg( "qpe" ); | 509 | Config cfg( "qpe" ); |
510 | cfg.setGroup( "Volume" ); | 510 | cfg.setGroup( "Volume" ); |
511 | if ( percent < 0 ) | 511 | if ( percent < 0 ) |
512 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 512 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
513 | #ifndef QT_NO_SOUND | 513 | #ifndef QT_NO_SOUND |
514 | int fd = 0; | 514 | int fd = 0; |
515 | #ifdef QT_QWS_DEVFS | 515 | #ifdef QT_QWS_DEVFS |
516 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 516 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
517 | #else | 517 | #else |
518 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 518 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
519 | #endif | 519 | #endif |
520 | int vol = muted ? 0 : percent; | 520 | int vol = muted ? 0 : percent; |
521 | // set both channels to same volume | 521 | // set both channels to same volume |
522 | vol |= vol << 8; | 522 | vol |= vol << 8; |
523 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 523 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
524 | ::close( fd ); | 524 | ::close( fd ); |
525 | } | 525 | } |
526 | #endif | 526 | #endif |
527 | } | 527 | } |
528 | break; | 528 | break; |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | static void setMic( int t = 0, int percent = -1 ) | 532 | static void setMic( int t = 0, int percent = -1 ) |
533 | { | 533 | { |
534 | switch ( t ) { | 534 | switch ( t ) { |
535 | case 0: { | 535 | case 0: { |
536 | Config cfg( "qpe" ); | 536 | Config cfg( "qpe" ); |
537 | cfg.setGroup( "Volume" ); | 537 | cfg.setGroup( "Volume" ); |
538 | if ( percent < 0 ) | 538 | if ( percent < 0 ) |
539 | percent = cfg.readNumEntry( "Mic", 50 ); | 539 | percent = cfg.readNumEntry( "Mic", 50 ); |
540 | 540 | ||
541 | #ifndef QT_NO_SOUND | 541 | #ifndef QT_NO_SOUND |
542 | int fd = 0; | 542 | int fd = 0; |
543 | int mic = micMuted ? 0 : percent; | 543 | int mic = micMuted ? 0 : percent; |
544 | #ifdef QT_QWS_DEVFS | 544 | #ifdef QT_QWS_DEVFS |
545 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 545 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
546 | #else | 546 | #else |
547 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 547 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
548 | #endif | 548 | #endif |
549 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 549 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
550 | ::close( fd ); | 550 | ::close( fd ); |
551 | } | 551 | } |
552 | #endif | 552 | #endif |
553 | } | 553 | } |
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | static void setBass( int t = 0, int percent = -1 ) | 559 | static void setBass( int t = 0, int percent = -1 ) |
560 | { | 560 | { |
561 | switch ( t ) { | 561 | switch ( t ) { |
562 | case 0: { | 562 | case 0: { |
563 | Config cfg( "qpe" ); | 563 | Config cfg( "qpe" ); |
564 | cfg.setGroup( "Volume" ); | 564 | cfg.setGroup( "Volume" ); |
565 | if ( percent < 0 ) | 565 | if ( percent < 0 ) |
566 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 566 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
567 | 567 | ||
568 | #ifndef QT_NO_SOUND | 568 | #ifndef QT_NO_SOUND |
569 | int fd = 0; | 569 | int fd = 0; |
570 | int bass = percent; | 570 | int bass = percent; |
571 | #ifdef QT_QWS_DEVFS | 571 | #ifdef QT_QWS_DEVFS |
572 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 572 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
573 | #else | 573 | #else |
574 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 574 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
575 | #endif | 575 | #endif |
576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
577 | ::close( fd ); | 577 | ::close( fd ); |
578 | } | 578 | } |
579 | #endif | 579 | #endif |
580 | } | 580 | } |
581 | break; | 581 | break; |
582 | } | 582 | } |
583 | } | 583 | } |
584 | 584 | ||
585 | 585 | ||
586 | static void setTreble( int t = 0, int percent = -1 ) | 586 | static void setTreble( int t = 0, int percent = -1 ) |
587 | { | 587 | { |
588 | switch ( t ) { | 588 | switch ( t ) { |
589 | case 0: { | 589 | case 0: { |
590 | Config cfg( "qpe" ); | 590 | Config cfg( "qpe" ); |
591 | cfg.setGroup( "Volume" ); | 591 | cfg.setGroup( "Volume" ); |
592 | if ( percent < 0 ) | 592 | if ( percent < 0 ) |
593 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 593 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
594 | 594 | ||
595 | #ifndef QT_NO_SOUND | 595 | #ifndef QT_NO_SOUND |
596 | int fd = 0; | 596 | int fd = 0; |
597 | int treble = percent; | 597 | int treble = percent; |
598 | #ifdef QT_QWS_DEVFS | 598 | #ifdef QT_QWS_DEVFS |
599 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 599 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
600 | #else | 600 | #else |
601 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 601 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
602 | #endif | 602 | #endif |
603 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 603 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
604 | ::close( fd ); | 604 | ::close( fd ); |
605 | } | 605 | } |
606 | #endif | 606 | #endif |
607 | } | 607 | } |
608 | break; | 608 | break; |
609 | } | 609 | } |
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | /** | 613 | /** |
614 | \class QPEApplication | 614 | \class QPEApplication |
615 | \brief The QPEApplication class implements various system services | 615 | \brief The QPEApplication class implements various system services |
616 | that are available to all Qtopia applications. | 616 | that are available to all Qtopia applications. |
617 | 617 | ||
618 | Simply by using QPEApplication instead of QApplication, a standard Qt | 618 | Simply by using QPEApplication instead of QApplication, a standard Qt |
619 | application becomes a Qtopia application. It automatically follows | 619 | application becomes a Qtopia application. It automatically follows |
620 | style changes, quits and raises, and in the | 620 | style changes, quits and raises, and in the |
621 | case of \link docwidget.html document-oriented\endlink applications, | 621 | case of \link docwidget.html document-oriented\endlink applications, |
622 | changes the currently displayed document in response to the environment. | 622 | changes the currently displayed document in response to the environment. |
623 | 623 | ||
624 | To create a \link docwidget.html document-oriented\endlink | 624 | To create a \link docwidget.html document-oriented\endlink |
625 | application use showMainDocumentWidget(); to create a | 625 | application use showMainDocumentWidget(); to create a |
626 | non-document-oriented application use showMainWidget(). The | 626 | non-document-oriented application use showMainWidget(). The |
627 | keepRunning() function indicates whether the application will | 627 | keepRunning() function indicates whether the application will |
628 | continue running after it's processed the last \link qcop.html | 628 | continue running after it's processed the last \link qcop.html |
629 | QCop\endlink message. This can be changed using setKeepRunning(). | 629 | QCop\endlink message. This can be changed using setKeepRunning(). |
630 | 630 | ||
631 | A variety of signals are emitted when certain events occur, for | 631 | A variety of signals are emitted when certain events occur, for |
632 | example, timeChanged(), clockChanged(), weekChanged(), | 632 | example, timeChanged(), clockChanged(), weekChanged(), |
633 | dateFormatChanged() and volumeChanged(). If the application receives | 633 | dateFormatChanged() and volumeChanged(). If the application receives |
634 | a \link qcop.html QCop\endlink message on the application's | 634 | a \link qcop.html QCop\endlink message on the application's |
635 | QPE/Application/\e{appname} channel, the appMessage() signal is | 635 | QPE/Application/\e{appname} channel, the appMessage() signal is |
636 | emitted. There are also flush() and reload() signals, which | 636 | emitted. There are also flush() and reload() signals, which |
637 | are emitted when synching begins and ends respectively - upon these | 637 | are emitted when synching begins and ends respectively - upon these |
638 | signals, the application should save and reload any data | 638 | signals, the application should save and reload any data |
639 | files that are involved in synching. Most of these signals will initially | 639 | files that are involved in synching. Most of these signals will initially |
640 | be received and unfiltered through the appMessage() signal. | 640 | be received and unfiltered through the appMessage() signal. |
641 | 641 | ||
642 | This class also provides a set of useful static functions. The | 642 | This class also provides a set of useful static functions. The |
643 | qpeDir() and documentDir() functions return the respective paths. | 643 | qpeDir() and documentDir() functions return the respective paths. |
644 | The grabKeyboard() and ungrabKeyboard() functions are used to | 644 | The grabKeyboard() and ungrabKeyboard() functions are used to |
645 | control whether the application takes control of the device's | 645 | control whether the application takes control of the device's |
646 | physical buttons (e.g. application launch keys). The stylus' mode of | 646 | physical buttons (e.g. application launch keys). The stylus' mode of |
647 | operation is set with setStylusOperation() and retrieved with | 647 | operation is set with setStylusOperation() and retrieved with |
648 | stylusOperation(). There are also setInputMethodHint() and | 648 | stylusOperation(). There are also setInputMethodHint() and |
649 | inputMethodHint() functions. | 649 | inputMethodHint() functions. |
650 | 650 | ||
651 | \ingroup qtopiaemb | 651 | \ingroup qtopiaemb |
652 | */ | 652 | */ |
653 | 653 | ||
654 | /*! | 654 | /*! |
655 | \fn void QPEApplication::clientMoused() | 655 | \fn void QPEApplication::clientMoused() |
656 | 656 | ||
657 | \internal | 657 | \internal |
658 | */ | 658 | */ |
659 | 659 | ||
660 | /*! | 660 | /*! |
661 | \fn void QPEApplication::timeChanged(); | 661 | \fn void QPEApplication::timeChanged(); |
662 | This signal is emitted when the time changes outside the normal | 662 | This signal is emitted when the time changes outside the normal |
663 | passage of time, i.e. if the time is set backwards or forwards. | 663 | passage of time, i.e. if the time is set backwards or forwards. |
664 | */ | 664 | */ |
665 | 665 | ||
666 | /*! | 666 | /*! |
667 | \fn void QPEApplication::clockChanged( bool ampm ); | 667 | \fn void QPEApplication::clockChanged( bool ampm ); |
668 | 668 | ||
669 | This signal is emitted when the user changes the clock's style. If | 669 | This signal is emitted when the user changes the clock's style. If |
670 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 670 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
671 | they want a 24-hour clock. | 671 | they want a 24-hour clock. |
672 | */ | 672 | */ |
673 | 673 | ||
674 | /*! | 674 | /*! |
675 | \fn void QPEApplication::volumeChanged( bool muted ) | 675 | \fn void QPEApplication::volumeChanged( bool muted ) |
676 | 676 | ||
677 | This signal is emitted whenever the mute state is changed. If \a | 677 | This signal is emitted whenever the mute state is changed. If \a |
678 | muted is TRUE, then sound output has been muted. | 678 | muted is TRUE, then sound output has been muted. |
679 | */ | 679 | */ |
680 | 680 | ||
681 | /*! | 681 | /*! |
682 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 682 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
683 | 683 | ||
684 | This signal is emitted if the week start day is changed. If \a | 684 | This signal is emitted if the week start day is changed. If \a |
685 | startOnMonday is TRUE then the first day of the week is Monday; if | 685 | startOnMonday is TRUE then the first day of the week is Monday; if |
686 | \a startOnMonday is FALSE then the first day of the week is | 686 | \a startOnMonday is FALSE then the first day of the week is |
687 | Sunday. | 687 | Sunday. |
688 | */ | 688 | */ |
689 | 689 | ||
690 | /*! | 690 | /*! |
691 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 691 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
692 | 692 | ||
693 | This signal is emitted whenever the date format is changed. | 693 | This signal is emitted whenever the date format is changed. |
694 | */ | 694 | */ |
695 | 695 | ||
696 | /*! | 696 | /*! |
697 | \fn void QPEApplication::flush() | 697 | \fn void QPEApplication::flush() |
698 | 698 | ||
699 | ### | 699 | ### |
700 | */ | 700 | */ |
701 | 701 | ||
702 | /*! | 702 | /*! |
703 | \fn void QPEApplication::reload() | 703 | \fn void QPEApplication::reload() |
704 | 704 | ||
705 | */ | 705 | */ |
706 | 706 | ||
707 | 707 | ||
708 | 708 | ||
709 | void QPEApplication::processQCopFile() | 709 | void QPEApplication::processQCopFile() |
710 | { | 710 | { |
711 | QString qcopfn("/tmp/qcop-msg-"); | 711 | QString qcopfn("/tmp/qcop-msg-"); |
712 | qcopfn += d->appName; // append command name | 712 | qcopfn += d->appName; // append command name |
713 | 713 | ||
714 | QFile f(qcopfn); | 714 | QFile f(qcopfn); |
715 | if ( f.open(IO_ReadWrite) ) { | 715 | if ( f.open(IO_ReadWrite) ) { |
716 | #ifndef Q_OS_WIN32 | 716 | #ifndef Q_OS_WIN32 |
717 | flock(f.handle(), LOCK_EX); | 717 | flock(f.handle(), LOCK_EX); |
718 | #endif | 718 | #endif |
719 | QDataStream ds(&f); | 719 | QDataStream ds(&f); |
720 | QCString channel, message; | 720 | QCString channel, message; |
721 | QByteArray data; | 721 | QByteArray data; |
722 | while(!ds.atEnd()) { | 722 | while(!ds.atEnd()) { |
723 | ds >> channel >> message >> data; | 723 | ds >> channel >> message >> data; |
724 | d->enqueueQCop(channel,message,data); | 724 | d->enqueueQCop(channel,message,data); |
725 | } | 725 | } |
726 | ::ftruncate(f.handle(), 0); | 726 | ::ftruncate(f.handle(), 0); |
727 | #ifndef Q_OS_WIN32 | 727 | #ifndef Q_OS_WIN32 |
728 | f.flush(); | 728 | f.flush(); |
729 | flock(f.handle(), LOCK_UN); | 729 | flock(f.handle(), LOCK_UN); |
730 | #endif | 730 | #endif |
731 | } | 731 | } |
732 | #endif | 732 | #endif |
733 | } | 733 | } |
734 | 734 | ||
735 | 735 | ||
736 | /*! | 736 | /*! |
737 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 737 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
738 | 738 | ||
739 | This signal is emitted when a message is received on this | 739 | This signal is emitted when a message is received on this |
740 | application's QPE/Application/<i>appname</i> \link qcop.html | 740 | application's QPE/Application/<i>appname</i> \link qcop.html |
741 | QCop\endlink channel. | 741 | QCop\endlink channel. |
742 | 742 | ||
743 | The slot to which you connect this signal uses \a msg and \a data | 743 | The slot to which you connect this signal uses \a msg and \a data |
744 | in the following way: | 744 | in the following way: |
745 | 745 | ||
746 | \code | 746 | \code |
747 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 747 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
748 | { | 748 | { |
749 | QDataStream stream( data, IO_ReadOnly ); | 749 | QDataStream stream( data, IO_ReadOnly ); |
750 | if ( msg == "someMessage(int,int,int)" ) { | 750 | if ( msg == "someMessage(int,int,int)" ) { |
751 | int a,b,c; | 751 | int a,b,c; |
752 | stream >> a >> b >> c; | 752 | stream >> a >> b >> c; |
753 | ... | 753 | ... |
754 | } else if ( msg == "otherMessage(QString)" ) { | 754 | } else if ( msg == "otherMessage(QString)" ) { |
755 | ... | 755 | ... |
756 | } | 756 | } |
757 | } | 757 | } |
758 | \endcode | 758 | \endcode |
759 | 759 | ||
760 | \sa qcop.html | 760 | \sa qcop.html |
761 | Note that messages received here may be processed by qpe application | 761 | Note that messages received here may be processed by qpe application |
762 | and emitted as signals, such as flush() and reload(). | 762 | and emitted as signals, such as flush() and reload(). |
763 | */ | 763 | */ |
764 | 764 | ||
765 | #ifndef QT_NO_TRANSLATION | 765 | #ifndef QT_NO_TRANSLATION |
766 | static void qtopia_loadTranslations( const QStringList& qms ) | 766 | static void qtopia_loadTranslations( const QStringList& qms ) |
767 | { | 767 | { |
768 | QStringList langs = Global::languageList(); | 768 | QStringList langs = Global::languageList(); |
769 | 769 | ||
770 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 770 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
771 | QString lang = *it; | 771 | QString lang = *it; |
772 | 772 | ||
773 | QTranslator * trans; | 773 | QTranslator * trans; |
774 | QString tfn; | 774 | QString tfn; |
775 | 775 | ||
776 | for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { | 776 | for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { |
777 | trans = new QTranslator(qApp); | 777 | trans = new QTranslator(qApp); |
778 | tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; | 778 | tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; |
779 | if ( trans->load( tfn )) | 779 | if ( trans->load( tfn )) |
780 | qApp->installTranslator( trans ); | 780 | qApp->installTranslator( trans ); |
781 | else | 781 | else |
782 | delete trans; | 782 | delete trans; |
783 | } | 783 | } |
784 | } | 784 | } |
785 | } | 785 | } |
786 | #endif | 786 | #endif |
787 | 787 | ||
788 | /* | 788 | /* |
789 | Turn off qDebug in release mode | 789 | Turn off qDebug in release mode |
790 | */ | 790 | */ |
791 | static void qtopiaMsgHandler(QtMsgType type, const char* msg) | 791 | static void qtopiaMsgHandler(QtMsgType type, const char* msg) |
792 | { | 792 | { |
793 | switch ( type ) { | 793 | switch ( type ) { |
794 | case QtDebugMsg: | 794 | case QtDebugMsg: |
795 | #ifdef QT_DEBUG | 795 | #ifdef QT_DEBUG |
796 | fprintf( stderr, "Debug: %s\n", msg ); | 796 | fprintf( stderr, "Debug: %s\n", msg ); |
797 | #endif | 797 | #endif |
798 | break; | 798 | break; |
799 | case QtWarningMsg: | 799 | case QtWarningMsg: |
800 | #ifdef QT_DEBUG | 800 | #ifdef QT_DEBUG |
801 | fprintf( stderr, "Warning: %s\n", msg ); | 801 | fprintf( stderr, "Warning: %s\n", msg ); |
802 | #endif | 802 | #endif |
803 | break; | 803 | break; |
804 | case QtFatalMsg: | 804 | case QtFatalMsg: |
805 | fprintf( stderr, "Fatal: %s\n", msg ); | 805 | fprintf( stderr, "Fatal: %s\n", msg ); |
806 | abort(); | 806 | abort(); |
807 | } | 807 | } |
808 | } | 808 | } |
809 | 809 | ||
810 | /*! | 810 | /*! |
811 | Constructs a QPEApplication just as you would construct | 811 | Constructs a QPEApplication just as you would construct |
812 | a QApplication, passing \a argc, \a argv, and \a t. | 812 | a QApplication, passing \a argc, \a argv, and \a t. |
813 | 813 | ||
814 | For applications, \a t should be the default, GuiClient. Only | 814 | For applications, \a t should be the default, GuiClient. Only |
815 | the Qtopia server passes GuiServer. | 815 | the Qtopia server passes GuiServer. |
816 | */ | 816 | */ |
817 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 817 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
818 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 818 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
819 | { | 819 | { |
820 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 820 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
821 | qInstallMsgHandler(qtopiaMsgHandler); | 821 | qInstallMsgHandler(qtopiaMsgHandler); |
822 | 822 | ||
823 | d = new QPEApplicationData; | 823 | d = new QPEApplicationData; |
824 | d->loadTextCodecs(); | 824 | d->loadTextCodecs(); |
825 | d->loadImageCodecs(); | 825 | d->loadImageCodecs(); |
826 | 826 | ||
827 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 827 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
828 | AppLnk::setSmallIconSize( d->smallIconSize ); | 828 | AppLnk::setSmallIconSize( d->smallIconSize ); |
829 | AppLnk::setBigIconSize( d->bigIconSize ); | 829 | AppLnk::setBigIconSize( d->bigIconSize ); |
830 | 830 | ||
831 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 831 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
832 | 832 | ||
833 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 833 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
834 | 834 | ||
835 | 835 | ||
836 | sysChannel = new QCopChannel( "QPE/System", this ); | 836 | sysChannel = new QCopChannel( "QPE/System", this ); |
837 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 837 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
838 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 838 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
839 | 839 | ||
840 | /* COde now in initapp */ | 840 | /* COde now in initapp */ |
841 | #if 0 | 841 | #if 0 |
842 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 842 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
843 | 843 | ||
844 | QString qcopfn( "/tmp/qcop-msg-" ); | 844 | QString qcopfn( "/tmp/qcop-msg-" ); |
845 | qcopfn += QString( argv[ 0 ] ); // append command name | 845 | qcopfn += QString( argv[ 0 ] ); // append command name |
846 | 846 | ||
847 | QFile f( qcopfn ); | 847 | QFile f( qcopfn ); |
848 | if ( f.open( IO_ReadOnly ) ) { | 848 | if ( f.open( IO_ReadOnly ) ) { |
849 | flock( f.handle(), LOCK_EX ); | 849 | flock( f.handle(), LOCK_EX ); |
850 | } | 850 | } |
851 | 851 | ||
852 | 852 | ||
853 | 853 | ||
854 | QCString channel = QCString( argv[ 0 ] ); | 854 | QCString channel = QCString( argv[ 0 ] ); |
855 | channel.replace( QRegExp( ".*/" ), "" ); | 855 | channel.replace( QRegExp( ".*/" ), "" ); |
856 | d->appName = channel; | 856 | d->appName = channel; |
857 | channel = "QPE/Application/" + channel; | 857 | channel = "QPE/Application/" + channel; |
858 | pidChannel = new QCopChannel( channel, this ); | 858 | pidChannel = new QCopChannel( channel, this ); |
859 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 859 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
860 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 860 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
861 | 861 | ||
862 | if ( f.isOpen() ) { | 862 | if ( f.isOpen() ) { |
863 | d->keep_running = FALSE; | 863 | d->keep_running = FALSE; |
864 | QDataStream ds( &f ); | 864 | QDataStream ds( &f ); |
865 | QCString channel, message; | 865 | QCString channel, message; |
866 | QByteArray data; | 866 | QByteArray data; |
867 | while ( !ds.atEnd() ) { | 867 | while ( !ds.atEnd() ) { |
868 | ds >> channel >> message >> data; | 868 | ds >> channel >> message >> data; |
869 | d->enqueueQCop( channel, message, data ); | 869 | d->enqueueQCop( channel, message, data ); |
870 | } | 870 | } |
871 | 871 | ||
872 | flock( f.handle(), LOCK_UN ); | 872 | flock( f.handle(), LOCK_UN ); |
873 | f.close(); | 873 | f.close(); |
874 | f.remove(); | 874 | f.remove(); |
875 | } | 875 | } |
876 | 876 | ||
877 | for ( int a = 0; a < argc; a++ ) { | 877 | for ( int a = 0; a < argc; a++ ) { |
878 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 878 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
879 | argv[ a ] = argv[ a + 1 ]; | 879 | argv[ a ] = argv[ a + 1 ]; |
880 | a++; | 880 | a++; |
881 | d->preloaded = TRUE; | 881 | d->preloaded = TRUE; |
882 | argc -= 1; | 882 | argc -= 1; |
883 | } | 883 | } |
884 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 884 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
885 | argv[ a ] = argv[ a + 1 ]; | 885 | argv[ a ] = argv[ a + 1 ]; |
886 | a++; | 886 | a++; |
887 | d->preloaded = TRUE; | 887 | d->preloaded = TRUE; |
888 | d->forceshow = TRUE; | 888 | d->forceshow = TRUE; |
889 | argc -= 1; | 889 | argc -= 1; |
890 | } | 890 | } |
891 | } | 891 | } |
892 | 892 | ||
893 | /* overide stored arguments */ | 893 | /* overide stored arguments */ |
894 | setArgs( argc, argv ); | 894 | setArgs( argc, argv ); |
895 | 895 | ||
896 | #endif | 896 | #endif |
897 | #else | 897 | #else |
898 | initApp( argc, argv ); | 898 | initApp( argc, argv ); |
899 | #endif | 899 | #endif |
900 | #ifdef Q_WS_QWS | 900 | #ifdef Q_WS_QWS |
901 | /* load the font renderer factories */ | 901 | /* load the font renderer factories */ |
902 | FontDatabase::loadRenderers(); | 902 | FontDatabase::loadRenderers(); |
903 | #endif | 903 | #endif |
904 | #ifndef QT_NO_TRANSLATION | 904 | #ifndef QT_NO_TRANSLATION |
905 | QStringList qms; | 905 | QStringList qms; |
906 | qms << "libqpe"; | 906 | qms << "libqpe"; |
907 | qms << "libopie"; | 907 | qms << "libopie"; |
908 | qms << d->appName; | 908 | qms << d->appName; |
909 | 909 | ||
910 | qtopia_loadTranslations(qms); | 910 | qtopia_loadTranslations(qms); |
911 | #endif | 911 | #endif |
912 | 912 | ||
913 | applyStyle(); | 913 | applyStyle(); |
914 | 914 | ||
915 | if ( type() == GuiServer ) { | 915 | if ( type() == GuiServer ) { |
916 | setVolume(); | 916 | setVolume(); |
917 | } | 917 | } |
918 | 918 | ||
919 | installEventFilter( this ); | 919 | installEventFilter( this ); |
920 | 920 | ||
921 | QPEMenuToolFocusManager::initialize(); | 921 | QPEMenuToolFocusManager::initialize(); |
922 | 922 | ||
923 | #ifdef QT_NO_QWS_CURSOR | 923 | #ifdef QT_NO_QWS_CURSOR |
924 | // if we have no cursor, probably don't want tooltips | 924 | // if we have no cursor, probably don't want tooltips |
925 | QToolTip::setEnabled( FALSE ); | 925 | QToolTip::setEnabled( FALSE ); |
926 | #endif | 926 | #endif |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | #ifdef QTOPIA_INTERNAL_INITAPP | 930 | #ifdef QTOPIA_INTERNAL_INITAPP |
931 | void QPEApplication::initApp( int argc, char **argv ) | 931 | void QPEApplication::initApp( int argc, char **argv ) |
932 | { | 932 | { |
933 | delete pidChannel; | 933 | delete pidChannel; |
934 | d->keep_running = TRUE; | 934 | d->keep_running = TRUE; |
935 | d->preloaded = FALSE; | 935 | d->preloaded = FALSE; |
936 | d->forceshow = FALSE; | 936 | d->forceshow = FALSE; |
937 | 937 | ||
938 | QCString channel = QCString(argv[0]); | 938 | QCString channel = QCString(argv[0]); |
939 | 939 | ||
940 | channel.replace(QRegExp(".*/"),""); | 940 | channel.replace(QRegExp(".*/"),""); |
941 | d->appName = channel; | 941 | d->appName = channel; |
942 | 942 | ||
943 | #ifndef QT_NO_TRANSLATION | 943 | #ifndef QT_NO_TRANSLATION |
944 | qtopia_loadTranslations( QStringList()<<channel ); | 944 | qtopia_loadTranslations( QStringList()<<channel ); |
945 | #endif | 945 | #endif |
946 | 946 | ||
947 | #if QT_VERSION > 235 | 947 | #if QT_VERSION > 235 |
948 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 948 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
949 | #endif | 949 | #endif |
950 | 950 | ||
951 | channel = "QPE/Application/" + channel; | 951 | channel = "QPE/Application/" + channel; |
952 | pidChannel = new QCopChannel( channel, this); | 952 | pidChannel = new QCopChannel( channel, this); |
953 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 953 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
954 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 954 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
955 | 955 | ||
956 | 956 | ||
957 | 957 | ||
958 | processQCopFile(); | 958 | processQCopFile(); |
959 | d->keep_running = d->qcopq.isEmpty(); | 959 | d->keep_running = d->qcopq.isEmpty(); |
960 | 960 | ||
961 | for (int a=0; a<argc; a++) { | 961 | for (int a=0; a<argc; a++) { |
962 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 962 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
963 | argv[a] = argv[a+1]; | 963 | argv[a] = argv[a+1]; |
964 | a++; | 964 | a++; |
965 | d->preloaded = TRUE; | 965 | d->preloaded = TRUE; |
966 | argc-=1; | 966 | argc-=1; |
967 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 967 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
968 | argv[a] = argv[a+1]; | 968 | argv[a] = argv[a+1]; |
969 | a++; | 969 | a++; |
970 | d->preloaded = TRUE; | 970 | d->preloaded = TRUE; |
971 | d->forceshow = TRUE; | 971 | d->forceshow = TRUE; |
972 | argc-=1; | 972 | argc-=1; |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | /* overide stored arguments */ | 976 | /* overide stored arguments */ |
977 | setArgs(argc, argv); | 977 | setArgs(argc, argv); |
978 | } | 978 | } |
979 | #endif | 979 | #endif |
980 | 980 | ||
981 | 981 | ||
982 | static QPtrDict<void>* inputMethodDict = 0; | 982 | static QPtrDict<void>* inputMethodDict = 0; |
983 | static void createInputMethodDict() | 983 | static void createInputMethodDict() |
984 | { | 984 | { |
985 | if ( !inputMethodDict ) | 985 | if ( !inputMethodDict ) |
986 | inputMethodDict = new QPtrDict<void>; | 986 | inputMethodDict = new QPtrDict<void>; |
987 | } | 987 | } |
988 | 988 | ||
989 | /*! | 989 | /*! |
990 | Returns the currently set hint to the system as to whether | 990 | Returns the currently set hint to the system as to whether |
991 | widget \a w has any use for text input methods. | 991 | widget \a w has any use for text input methods. |
992 | 992 | ||
993 | 993 | ||
994 | \sa setInputMethodHint() InputMethodHint | 994 | \sa setInputMethodHint() InputMethodHint |
995 | */ | 995 | */ |
996 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 996 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
997 | { | 997 | { |
998 | if ( inputMethodDict && w ) | 998 | if ( inputMethodDict && w ) |
999 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 999 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
1000 | return Normal; | 1000 | return Normal; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | /*! | 1003 | /*! |
1004 | \enum QPEApplication::InputMethodHint | 1004 | \enum QPEApplication::InputMethodHint |
1005 | 1005 | ||
1006 | \value Normal the application sometimes needs text input (the default). | 1006 | \value Normal the application sometimes needs text input (the default). |
1007 | \value AlwaysOff the application never needs text input. | 1007 | \value AlwaysOff the application never needs text input. |
1008 | \value AlwaysOn the application always needs text input. | 1008 | \value AlwaysOn the application always needs text input. |
1009 | */ | 1009 | */ |
1010 | 1010 | ||
1011 | /*! | 1011 | /*! |
1012 | Hints to the system that widget \a w has use for text input methods | 1012 | Hints to the system that widget \a w has use for text input methods |
1013 | as specified by \a mode. | 1013 | as specified by \a mode. |
1014 | 1014 | ||
1015 | \sa inputMethodHint() InputMethodHint | 1015 | \sa inputMethodHint() InputMethodHint |
1016 | */ | 1016 | */ |
1017 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1017 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1018 | { | 1018 | { |
1019 | createInputMethodDict(); | 1019 | createInputMethodDict(); |
1020 | if ( mode == Normal ) { | 1020 | if ( mode == Normal ) { |
1021 | inputMethodDict->remove | 1021 | inputMethodDict->remove |
1022 | ( w ); | 1022 | ( w ); |
1023 | } | 1023 | } |
1024 | else { | 1024 | else { |
1025 | inputMethodDict->insert( w, ( void* ) mode ); | 1025 | inputMethodDict->insert( w, ( void* ) mode ); |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | class HackDialog : public QDialog | 1029 | class HackDialog : public QDialog |
1030 | { | 1030 | { |
1031 | public: | 1031 | public: |
1032 | void acceptIt() | 1032 | void acceptIt() |
1033 | { | 1033 | { |
1034 | accept(); | 1034 | accept(); |
1035 | } | 1035 | } |
1036 | void rejectIt() | 1036 | void rejectIt() |
1037 | { | 1037 | { |
1038 | reject(); | 1038 | reject(); |
1039 | } | 1039 | } |
1040 | }; | 1040 | }; |
1041 | 1041 | ||
1042 | 1042 | ||
1043 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1043 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1044 | { | 1044 | { |
1045 | // specialised actions for certain widgets. May want to | 1045 | // specialised actions for certain widgets. May want to |
1046 | // add more stuff here. | 1046 | // add more stuff here. |
1047 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1047 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1048 | && activePopupWidget() ->parentWidget() | 1048 | && activePopupWidget() ->parentWidget() |
1049 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1049 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1050 | key = Qt::Key_Return; | 1050 | key = Qt::Key_Return; |
1051 | 1051 | ||
1052 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1052 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1053 | key = Qt::Key_Return; | 1053 | key = Qt::Key_Return; |
1054 | 1054 | ||
1055 | #ifdef QWS | 1055 | #ifdef QWS |
1056 | 1056 | ||
1057 | ke->simpleData.keycode = key; | 1057 | ke->simpleData.keycode = key; |
1058 | #endif | 1058 | #endif |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | 1061 | ||
1062 | /*! | 1062 | /*! |
1063 | \internal | 1063 | \internal |
1064 | */ | 1064 | */ |
1065 | 1065 | ||
1066 | #ifdef QWS | 1066 | #ifdef QWS |
1067 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1067 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1068 | { | 1068 | { |
1069 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1069 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1070 | if ( qApp->type() != QApplication::GuiServer ) { | 1070 | if ( qApp->type() != QApplication::GuiServer ) { |
1071 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1071 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1072 | e << d->appName; | 1072 | e << d->appName; |
1073 | } | 1073 | } |
1074 | d->notbusysent = TRUE; | 1074 | d->notbusysent = TRUE; |
1075 | } | 1075 | } |
1076 | if ( type() == GuiServer ) { | 1076 | if ( type() == GuiServer ) { |
1077 | switch ( e->type ) { | 1077 | switch ( e->type ) { |
1078 | case QWSEvent::Mouse: | 1078 | case QWSEvent::Mouse: |
1079 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1079 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1080 | emit clientMoused(); | 1080 | emit clientMoused(); |
1081 | break; | 1081 | break; |
1082 | default: | 1082 | default: |
1083 | break; | 1083 | break; |
1084 | } | 1084 | } |
1085 | } | 1085 | } |
1086 | if ( e->type == QWSEvent::Key ) { | 1086 | if ( e->type == QWSEvent::Key ) { |
1087 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1087 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1088 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1088 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1089 | // Use special "OK" key to press "OK" on top level widgets | 1089 | // Use special "OK" key to press "OK" on top level widgets |
1090 | QWidget * active = activeWindow(); | 1090 | QWidget * active = activeWindow(); |
1091 | QWidget *popup = 0; | 1091 | QWidget *popup = 0; |
1092 | if ( active && active->isPopup() ) { | 1092 | if ( active && active->isPopup() ) { |
1093 | popup = active; | 1093 | popup = active; |
1094 | active = active->parentWidget(); | 1094 | active = active->parentWidget(); |
1095 | } | 1095 | } |
1096 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1096 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1097 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1097 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1098 | if ( ke->simpleData.is_press ) { | 1098 | if ( ke->simpleData.is_press ) { |
1099 | if ( popup ) | 1099 | if ( popup ) |
1100 | popup->close(); | 1100 | popup->close(); |
1101 | if ( active->inherits( "QDialog" ) ) { | 1101 | if ( active->inherits( "QDialog" ) ) { |
1102 | HackDialog * d = ( HackDialog * ) active; | 1102 | HackDialog * d = ( HackDialog * ) active; |
1103 | d->acceptIt(); | 1103 | d->acceptIt(); |
1104 | return TRUE; | 1104 | return TRUE; |
1105 | } | 1105 | } |
1106 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1106 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1107 | QSignal s; | 1107 | QSignal s; |
1108 | s.connect( active, SLOT( accept() ) ); | 1108 | s.connect( active, SLOT( accept() ) ); |
1109 | s.activate(); | 1109 | s.activate(); |
1110 | } | 1110 | } |
1111 | else { | 1111 | else { |
1112 | // do the same as with the select key: Map to the default action of the widget: | 1112 | // do the same as with the select key: Map to the default action of the widget: |
1113 | mapToDefaultAction( ke, Qt::Key_Return ); | 1113 | mapToDefaultAction( ke, Qt::Key_Return ); |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1118 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1119 | // Use special "select" key to do whatever default action a widget has | 1119 | // Use special "select" key to do whatever default action a widget has |
1120 | mapToDefaultAction( ke, Qt::Key_Space ); | 1120 | mapToDefaultAction( ke, Qt::Key_Space ); |
1121 | } | 1121 | } |
1122 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1122 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1123 | ke->simpleData.is_press ) { | 1123 | ke->simpleData.is_press ) { |
1124 | // Escape key closes app if focus on toplevel | 1124 | // Escape key closes app if focus on toplevel |
1125 | QWidget * active = activeWindow(); | 1125 | QWidget * active = activeWindow(); |
1126 | if ( active && active->testWFlags( WType_TopLevel ) && | 1126 | if ( active && active->testWFlags( WType_TopLevel ) && |
1127 | ( int ) active->winId() == ke->simpleData.window && | 1127 | ( int ) active->winId() == ke->simpleData.window && |
1128 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1128 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1129 | if ( active->inherits( "QDialog" ) ) { | 1129 | if ( active->inherits( "QDialog" ) ) { |
1130 | HackDialog * d = ( HackDialog * ) active; | 1130 | HackDialog * d = ( HackDialog * ) active; |
1131 | d->rejectIt(); | 1131 | d->rejectIt(); |
1132 | return TRUE; | 1132 | return TRUE; |
1133 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1133 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1134 | active->close(); | 1134 | active->close(); |
1135 | } | 1135 | } |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | } | 1138 | } |
1139 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1139 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1140 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1140 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1141 | // but we cannot access libopie function within libqpe :( | 1141 | // but we cannot access libopie function within libqpe :( |
1142 | 1142 | ||
1143 | QWidget * active = activeWindow ( ); | 1143 | QWidget * active = activeWindow ( ); |
1144 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1144 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1145 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1145 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1146 | QChar ch ( ke-> simpleData.unicode ); | 1146 | QChar ch ( ke-> simpleData.unicode ); |
1147 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1147 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1148 | ke-> simpleData.keycode, | 1148 | ke-> simpleData.keycode, |
1149 | ch. latin1 ( ), | 1149 | ch. latin1 ( ), |
1150 | ke-> simpleData.modifiers, | 1150 | ke-> simpleData.modifiers, |
1151 | QString ( ch ), | 1151 | QString ( ch ), |
1152 | ke-> simpleData.is_auto_repeat, 1 ); | 1152 | ke-> simpleData.is_auto_repeat, 1 ); |
1153 | 1153 | ||
1154 | QObject *which = QWidget::keyboardGrabber ( ); | 1154 | QObject *which = QWidget::keyboardGrabber ( ); |
1155 | if ( !which ) | 1155 | if ( !which ) |
1156 | which = QApplication::focusWidget ( ); | 1156 | which = QApplication::focusWidget ( ); |
1157 | if ( !which ) | 1157 | if ( !which ) |
1158 | which = QApplication::activeWindow ( ); | 1158 | which = QApplication::activeWindow ( ); |
1159 | if ( !which ) | 1159 | if ( !which ) |
1160 | which = qApp; | 1160 | which = qApp; |
1161 | 1161 | ||
1162 | QApplication::sendEvent ( which, &qke ); | 1162 | QApplication::sendEvent ( which, &qke ); |
1163 | } | 1163 | } |
1164 | else { // we didn't grab the keyboard, so send the event to the launcher | 1164 | else { // we didn't grab the keyboard, so send the event to the launcher |
1165 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1165 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1166 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1166 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | return true; | 1169 | return true; |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | if ( e->type == QWSEvent::Focus ) { | 1172 | if ( e->type == QWSEvent::Focus ) { |
1173 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1173 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1174 | if ( !fe->simpleData.get_focus ) { | 1174 | if ( !fe->simpleData.get_focus ) { |
1175 | QWidget * active = activeWindow(); | 1175 | QWidget * active = activeWindow(); |
1176 | while ( active && active->isPopup() ) { | 1176 | while ( active && active->isPopup() ) { |
1177 | active->close(); | 1177 | active->close(); |
1178 | active = activeWindow(); | 1178 | active = activeWindow(); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | else { | 1181 | else { |
1182 | // make sure our modal widget is ALWAYS on top | 1182 | // make sure our modal widget is ALWAYS on top |
1183 | QWidget *topm = activeModalWidget(); | 1183 | QWidget *topm = activeModalWidget(); |
1184 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1184 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1185 | topm->raise(); | 1185 | topm->raise(); |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1188 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1189 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1189 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1190 | if ( m == AlwaysOff ) | 1190 | if ( m == AlwaysOff ) |
1191 | Global::hideInputMethod(); | 1191 | Global::hideInputMethod(); |
1192 | if ( m == AlwaysOn ) | 1192 | if ( m == AlwaysOn ) |
1193 | Global::showInputMethod(); | 1193 | Global::showInputMethod(); |
1194 | } | 1194 | } |
1195 | } | 1195 | } |
1196 | 1196 | ||
1197 | 1197 | ||
1198 | return QApplication::qwsEventFilter( e ); | 1198 | return QApplication::qwsEventFilter( e ); |
1199 | } | 1199 | } |
1200 | #endif | 1200 | #endif |
1201 | 1201 | ||
1202 | /*! | 1202 | /*! |
1203 | Destroys the QPEApplication. | 1203 | Destroys the QPEApplication. |
1204 | */ | 1204 | */ |
1205 | QPEApplication::~QPEApplication() | 1205 | QPEApplication::~QPEApplication() |
1206 | { | 1206 | { |
1207 | ungrabKeyboard(); | 1207 | ungrabKeyboard(); |
1208 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1208 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1209 | // Need to delete QCopChannels early, since the display will | 1209 | // Need to delete QCopChannels early, since the display will |
1210 | // be gone by the time we get to ~QObject(). | 1210 | // be gone by the time we get to ~QObject(). |
1211 | delete sysChannel; | 1211 | delete sysChannel; |
1212 | delete pidChannel; | 1212 | delete pidChannel; |
1213 | #endif | 1213 | #endif |
1214 | 1214 | ||
1215 | #ifdef OPIE_WITHROHFEEDBACK | 1215 | #ifdef OPIE_WITHROHFEEDBACK |
1216 | if( d->RoH ) | 1216 | if( d->RoH ) |
1217 | delete d->RoH; | 1217 | delete d->RoH; |
1218 | #endif | 1218 | #endif |
1219 | delete d; | 1219 | delete d; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | /*! | 1222 | /*! |
1223 | Returns <tt>$OPIEDIR/</tt>. | 1223 | Returns <tt>$OPIEDIR/</tt>. |
1224 | */ | 1224 | */ |
1225 | QString QPEApplication::qpeDir() | 1225 | QString QPEApplication::qpeDir() |
1226 | { | 1226 | { |
1227 | QString base, dir; | 1227 | QString base, dir; |
1228 | 1228 | ||
1229 | if (getenv( "OPIEDIR" )) | 1229 | if (getenv( "OPIEDIR" )) |
1230 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); | 1230 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); |
1231 | if ( !base.isNull() && (base.length() > 0 )){ | 1231 | if ( !base.isNull() && (base.length() > 0 )){ |
1232 | #ifdef Q_OS_WIN32 | 1232 | #ifdef Q_OS_WIN32 |
1233 | QString temp(base); | 1233 | QString temp(base); |
1234 | if (temp[(int)temp.length()-1] != QDir::separator()) | 1234 | if (temp[(int)temp.length()-1] != QDir::separator()) |
1235 | temp.append(QDir::separator()); | 1235 | temp.append(QDir::separator()); |
1236 | dir = temp; | 1236 | dir = temp; |
1237 | #else | 1237 | #else |
1238 | dir = QString( base ) + "/"; | 1238 | dir = QString( base ) + "/"; |
1239 | #endif | 1239 | #endif |
1240 | }else{ | 1240 | }else{ |
1241 | dir = QString( ".." ) + QDir::separator(); | 1241 | dir = QString( ".." ) + QDir::separator(); |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | return dir; | 1244 | return dir; |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | /*! | 1247 | /*! |
1248 | Returns the user's current Document directory. There is a trailing "/". | 1248 | Returns the user's current Document directory. There is a trailing "/". |
1249 | .. well, it does now,, and there's no trailing '/' | 1249 | .. well, it does now,, and there's no trailing '/' |
1250 | */ | 1250 | */ |
1251 | QString QPEApplication::documentDir() | 1251 | QString QPEApplication::documentDir() |
1252 | { | 1252 | { |
1253 | const char* base = getenv( "HOME"); | 1253 | const char* base = getenv( "HOME"); |
1254 | if ( base ) | 1254 | if ( base ) |
1255 | return QString( base ) + "/Documents"; | 1255 | return QString( base ) + "/Documents"; |
1256 | 1256 | ||
1257 | return QString( "../Documents" ); | 1257 | return QString( "../Documents" ); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | static int deforient = -1; | 1260 | static int deforient = -1; |
1261 | 1261 | ||
1262 | /*! | 1262 | /*! |
1263 | \internal | 1263 | \internal |
1264 | */ | 1264 | */ |
1265 | int QPEApplication::defaultRotation() | 1265 | int QPEApplication::defaultRotation() |
1266 | { | 1266 | { |
1267 | if ( deforient < 0 ) { | 1267 | if ( deforient < 0 ) { |
1268 | QString d = getenv( "QWS_DISPLAY" ); | 1268 | QString d = getenv( "QWS_DISPLAY" ); |
1269 | if ( d.contains( "Rot90" ) ) { | 1269 | if ( d.contains( "Rot90" ) ) { |
1270 | deforient = 90; | 1270 | deforient = 90; |
1271 | } | 1271 | } |
1272 | else if ( d.contains( "Rot180" ) ) { | 1272 | else if ( d.contains( "Rot180" ) ) { |
1273 | deforient = 180; | 1273 | deforient = 180; |
1274 | } | 1274 | } |
1275 | else if ( d.contains( "Rot270" ) ) { | 1275 | else if ( d.contains( "Rot270" ) ) { |
1276 | deforient = 270; | 1276 | deforient = 270; |
1277 | } | 1277 | } |
1278 | else { | 1278 | else { |
1279 | deforient = 0; | 1279 | deforient = 0; |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | return deforient; | 1282 | return deforient; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | /*! | 1285 | /*! |
1286 | \internal | 1286 | \internal |
1287 | */ | 1287 | */ |
1288 | void QPEApplication::setDefaultRotation( int r ) | 1288 | void QPEApplication::setDefaultRotation( int r ) |
1289 | { | 1289 | { |
1290 | if ( qApp->type() == GuiServer ) { | 1290 | if ( qApp->type() == GuiServer ) { |
1291 | deforient = r; | 1291 | deforient = r; |
1292 | int j = 0; | 1292 | int j = 0; |
1293 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; | 1293 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
1294 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); | 1294 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); |
1295 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); | 1295 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); |
1296 | Config config("qpe"); | 1296 | Config config("qpe"); |
1297 | config.setGroup( "Rotation" ); | 1297 | config.setGroup( "Rotation" ); |
1298 | config.writeEntry( "Rot", r ); | 1298 | config.writeEntry( "Rot", r ); |
1299 | } | 1299 | } |
1300 | else { | 1300 | else { |
1301 | #ifndef QT_NO_COP | 1301 | #ifndef QT_NO_COP |
1302 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1302 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1303 | e << r; | 1303 | e << r; |
1304 | } | 1304 | } |
1305 | #endif | 1305 | #endif |
1306 | 1306 | ||
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | #include <qgfx_qws.h> | 1310 | #include <qgfx_qws.h> |
1311 | #include <qwindowsystem_qws.h> | 1311 | #include <qwindowsystem_qws.h> |
1312 | 1312 | ||
1313 | #if QT_VERSION > 236 | 1313 | #if QT_VERSION > 236 |
1314 | extern void qws_clearLoadedFonts(); | 1314 | extern void qws_clearLoadedFonts(); |
1315 | #endif | 1315 | #endif |
1316 | 1316 | ||
1317 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1317 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1318 | { | 1318 | { |
1319 | // Reset the caches | 1319 | // Reset the caches |
1320 | #if QT_VERSION > 236 | 1320 | #if QT_VERSION > 236 |
1321 | qws_clearLoadedFonts(); | 1321 | qws_clearLoadedFonts(); |
1322 | #endif | 1322 | #endif |
1323 | QPixmapCache::clear(); | 1323 | QPixmapCache::clear(); |
1324 | 1324 | ||
1325 | // Change the screen mode | 1325 | // Change the screen mode |
1326 | qt_screen->setMode(x, y, depth); | 1326 | qt_screen->setMode(x, y, depth); |
1327 | 1327 | ||
1328 | if ( qApp->type() == GuiServer ) { | 1328 | if ( qApp->type() == GuiServer ) { |
1329 | #if QT_VERSION > 236 | 1329 | #if QT_VERSION > 236 |
1330 | // Reconfigure the GuiServer | 1330 | // Reconfigure the GuiServer |
1331 | qwsServer->beginDisplayReconfigure(); | 1331 | qwsServer->beginDisplayReconfigure(); |
1332 | qwsServer->endDisplayReconfigure(); | 1332 | qwsServer->endDisplayReconfigure(); |
1333 | #endif | 1333 | #endif |
1334 | // Get all the running apps to reset | 1334 | // Get all the running apps to reset |
1335 | QCopEnvelope env( "QPE/System", "reset()" ); | 1335 | QCopEnvelope env( "QPE/System", "reset()" ); |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | void QPEApplication::reset() { | 1339 | void QPEApplication::reset() { |
1340 | // Reconnect to the screen | 1340 | // Reconnect to the screen |
1341 | qt_screen->disconnect(); | 1341 | qt_screen->disconnect(); |
1342 | qt_screen->connect( QString::null ); | 1342 | qt_screen->connect( QString::null ); |
1343 | 1343 | ||
1344 | // Redraw everything | 1344 | // Redraw everything |
1345 | applyStyle(); | 1345 | applyStyle(); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1348 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1349 | bool qt_left_hand_scrollbars = false; | 1349 | bool qt_left_hand_scrollbars = false; |
1350 | #else | 1350 | #else |
1351 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; | 1351 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; |
1352 | #endif | 1352 | #endif |
1353 | 1353 | ||
1354 | /*! | 1354 | /*! |
1355 | \internal | 1355 | \internal |
1356 | */ | 1356 | */ |
1357 | void QPEApplication::applyStyle() | 1357 | void QPEApplication::applyStyle() |
1358 | { | 1358 | { |
1359 | Config config( "qpe" ); | 1359 | Config config( "qpe" ); |
1360 | config.setGroup( "Appearance" ); | 1360 | config.setGroup( "Appearance" ); |
1361 | 1361 | ||
1362 | #if QT_VERSION > 233 | 1362 | #if QT_VERSION > 233 |
1363 | // Widget style | 1363 | // Widget style |
1364 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1364 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1365 | 1365 | ||
1366 | internalSetStyle ( style ); | 1366 | internalSetStyle ( style ); |
1367 | 1367 | ||
1368 | // Colors - from /etc/colors/Liquid.scheme | 1368 | // Colors - from /etc/colors/Liquid.scheme |
1369 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1369 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1370 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1370 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1371 | QPalette pal( btncolor, bgcolor ); | 1371 | QPalette pal( btncolor, bgcolor ); |
1372 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1372 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1373 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1373 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1374 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1374 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1375 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1375 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1376 | color = config.readEntry( "Text", "#000000" ); | 1376 | color = config.readEntry( "Text", "#000000" ); |
1377 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1377 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1378 | color = config.readEntry( "ButtonText", "#000000" ); | 1378 | color = config.readEntry( "ButtonText", "#000000" ); |
1379 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1379 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1380 | color = config.readEntry( "Base", "#FFFFFF" ); | 1380 | color = config.readEntry( "Base", "#FFFFFF" ); |
1381 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1381 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1382 | 1382 | ||
1383 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1383 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1384 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1384 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1385 | 1385 | ||
1386 | setPalette( pal, TRUE ); | 1386 | setPalette( pal, TRUE ); |
1387 | 1387 | ||
1388 | 1388 | ||
1389 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1389 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1390 | if (&qt_left_hand_scrollbars ) | 1390 | if (&qt_left_hand_scrollbars ) |
1391 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1391 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1392 | 1392 | ||
1393 | // Window Decoration | 1393 | // Window Decoration |
1394 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1394 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1395 | 1395 | ||
1396 | if ( dec != d->decorationName ) { | 1396 | if ( dec != d->decorationName ) { |
1397 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1397 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1398 | d->decorationName = dec; | 1398 | d->decorationName = dec; |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | // Font | 1401 | // Font |
1402 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1402 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1403 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1403 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1404 | 1404 | ||
1405 | setFont ( QFont ( ff, fs ), true ); | 1405 | setFont ( QFont ( ff, fs ), true ); |
1406 | #endif | 1406 | #endif |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1409 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1410 | { | 1410 | { |
1411 | #ifdef Q_WS_QWS | 1411 | #ifdef Q_WS_QWS |
1412 | QDataStream stream( data, IO_ReadOnly ); | 1412 | QDataStream stream( data, IO_ReadOnly ); |
1413 | if ( msg == "applyStyle()" ) { | 1413 | if ( msg == "applyStyle()" ) { |
1414 | applyStyle(); | 1414 | applyStyle(); |
1415 | } | 1415 | } |
1416 | else if ( msg == "toggleApplicationMenu()" ) { | 1416 | else if ( msg == "toggleApplicationMenu()" ) { |
1417 | QWidget *active = activeWindow ( ); | 1417 | QWidget *active = activeWindow ( ); |
1418 | 1418 | ||
1419 | if ( active ) { | 1419 | if ( active ) { |
1420 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1420 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1421 | bool oldactive = man-> isActive ( ); | 1421 | bool oldactive = man-> isActive ( ); |
1422 | 1422 | ||
1423 | man-> setActive( !man-> isActive() ); | 1423 | man-> setActive( !man-> isActive() ); |
1424 | 1424 | ||
1425 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1425 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1426 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1426 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | else if ( msg == "setDefaultRotation(int)" ) { | 1430 | else if ( msg == "setDefaultRotation(int)" ) { |
1431 | if ( type() == GuiServer ) { | 1431 | if ( type() == GuiServer ) { |
1432 | int r; | 1432 | int r; |
1433 | stream >> r; | 1433 | stream >> r; |
1434 | setDefaultRotation( r ); | 1434 | setDefaultRotation( r ); |
1435 | } | 1435 | } |
1436 | } | 1436 | } |
1437 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1437 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1438 | if ( type() == GuiServer ) { | 1438 | if ( type() == GuiServer ) { |
1439 | int x, y, depth; | 1439 | int x, y, depth; |
1440 | stream >> x; | 1440 | stream >> x; |
1441 | stream >> y; | 1441 | stream >> y; |
1442 | stream >> depth; | 1442 | stream >> depth; |
1443 | setCurrentMode( x, y, depth ); | 1443 | setCurrentMode( x, y, depth ); |
1444 | } | 1444 | } |
1445 | } | 1445 | } |
1446 | else if ( msg == "reset()" ) { | 1446 | else if ( msg == "reset()" ) { |
1447 | if ( type() != GuiServer ) | 1447 | if ( type() != GuiServer ) |
1448 | reset(); | 1448 | reset(); |
1449 | } | 1449 | } |
1450 | else if ( msg == "setCurrentRotation(int)" ) { | 1450 | else if ( msg == "setCurrentRotation(int)" ) { |
1451 | int r; | 1451 | int r; |
1452 | stream >> r; | 1452 | stream >> r; |
1453 | setCurrentRotation( r ); | 1453 | setCurrentRotation( r ); |
1454 | } | 1454 | } |
1455 | else if ( msg == "shutdown()" ) { | 1455 | else if ( msg == "shutdown()" ) { |
1456 | if ( type() == GuiServer ) | 1456 | if ( type() == GuiServer ) |
1457 | shutdown(); | 1457 | shutdown(); |
1458 | } | 1458 | } |
1459 | else if ( msg == "quit()" ) { | 1459 | else if ( msg == "quit()" ) { |
1460 | if ( type() != GuiServer ) | 1460 | if ( type() != GuiServer ) |
1461 | tryQuit(); | 1461 | tryQuit(); |
1462 | } | 1462 | } |
1463 | else if ( msg == "forceQuit()" ) { | 1463 | else if ( msg == "forceQuit()" ) { |
1464 | if ( type() != GuiServer ) | 1464 | if ( type() != GuiServer ) |
1465 | quit(); | 1465 | quit(); |
1466 | } | 1466 | } |
1467 | else if ( msg == "restart()" ) { | 1467 | else if ( msg == "restart()" ) { |
1468 | if ( type() == GuiServer ) | 1468 | if ( type() == GuiServer ) |
1469 | restart(); | 1469 | restart(); |
1470 | } | 1470 | } |
1471 | else if ( msg == "language(QString)" ) { | 1471 | else if ( msg == "language(QString)" ) { |
1472 | if ( type() == GuiServer ) { | 1472 | if ( type() == GuiServer ) { |
1473 | QString l; | 1473 | QString l; |
1474 | stream >> l; | 1474 | stream >> l; |
1475 | QString cl = getenv( "LANG" ); | 1475 | QString cl = getenv( "LANG" ); |
1476 | if ( cl != l ) { | 1476 | if ( cl != l ) { |
1477 | if ( l.isNull() ) | 1477 | if ( l.isNull() ) |
1478 | unsetenv( "LANG" ); | 1478 | unsetenv( "LANG" ); |
1479 | else | 1479 | else |
1480 | setenv( "LANG", l.latin1(), 1 ); | 1480 | setenv( "LANG", l.latin1(), 1 ); |
1481 | restart(); | 1481 | restart(); |
1482 | } | 1482 | } |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | else if ( msg == "timeChange(QString)" ) { | 1485 | else if ( msg == "timeChange(QString)" ) { |
1486 | QString t; | 1486 | QString t; |
1487 | stream >> t; | 1487 | stream >> t; |
1488 | if ( t.isNull() ) | 1488 | if ( t.isNull() ) |
1489 | unsetenv( "TZ" ); | 1489 | unsetenv( "TZ" ); |
1490 | else | 1490 | else |
1491 | setenv( "TZ", t.latin1(), 1 ); | 1491 | setenv( "TZ", t.latin1(), 1 ); |
1492 | // emit the signal so everyone else knows... | 1492 | // emit the signal so everyone else knows... |
1493 | emit timeChanged(); | 1493 | emit timeChanged(); |
1494 | } | 1494 | } |
1495 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1495 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1496 | if ( type() == GuiServer ) { | 1496 | if ( type() == GuiServer ) { |
1497 | QDateTime when; | 1497 | QDateTime when; |
1498 | QCString channel, message; | 1498 | QCString channel, message; |
1499 | int data; | 1499 | int data; |
1500 | stream >> when >> channel >> message >> data; | 1500 | stream >> when >> channel >> message >> data; |
1501 | AlarmServer::addAlarm( when, channel, message, data ); | 1501 | AlarmServer::addAlarm( when, channel, message, data ); |
1502 | } | 1502 | } |
1503 | } | 1503 | } |
1504 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1504 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1505 | if ( type() == GuiServer ) { | 1505 | if ( type() == GuiServer ) { |
1506 | QDateTime when; | 1506 | QDateTime when; |
1507 | QCString channel, message; | 1507 | QCString channel, message; |
1508 | int data; | 1508 | int data; |
1509 | stream >> when >> channel >> message >> data; | 1509 | stream >> when >> channel >> message >> data; |
1510 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1510 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | else if ( msg == "clockChange(bool)" ) { | 1513 | else if ( msg == "clockChange(bool)" ) { |
1514 | int tmp; | 1514 | int tmp; |
1515 | stream >> tmp; | 1515 | stream >> tmp; |
1516 | emit clockChanged( tmp ); | 1516 | emit clockChanged( tmp ); |
1517 | } | 1517 | } |
1518 | else if ( msg == "weekChange(bool)" ) { | 1518 | else if ( msg == "weekChange(bool)" ) { |
1519 | int tmp; | 1519 | int tmp; |
1520 | stream >> tmp; | 1520 | stream >> tmp; |
1521 | emit weekChanged( tmp ); | 1521 | emit weekChanged( tmp ); |
1522 | } | 1522 | } |
1523 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1523 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1524 | DateFormat tmp; | 1524 | DateFormat tmp; |
1525 | stream >> tmp; | 1525 | stream >> tmp; |
1526 | emit dateFormatChanged( tmp ); | 1526 | emit dateFormatChanged( tmp ); |
1527 | } | 1527 | } |
1528 | else if ( msg == "setVolume(int,int)" ) { | 1528 | else if ( msg == "setVolume(int,int)" ) { |
1529 | int t, v; | 1529 | int t, v; |
1530 | stream >> t >> v; | 1530 | stream >> t >> v; |
1531 | setVolume( t, v ); | 1531 | setVolume( t, v ); |
1532 | emit volumeChanged( muted ); | 1532 | emit volumeChanged( muted ); |
1533 | } | 1533 | } |
1534 | else if ( msg == "volumeChange(bool)" ) { | 1534 | else if ( msg == "volumeChange(bool)" ) { |
1535 | stream >> muted; | 1535 | stream >> muted; |
1536 | setVolume(); | 1536 | setVolume(); |
1537 | emit volumeChanged( muted ); | 1537 | emit volumeChanged( muted ); |
1538 | } | 1538 | } |
1539 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1539 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1540 | int t, v; | 1540 | int t, v; |
1541 | stream >> t >> v; | 1541 | stream >> t >> v; |
1542 | setMic( t, v ); | 1542 | setMic( t, v ); |
1543 | emit micChanged( micMuted ); | 1543 | emit micChanged( micMuted ); |
1544 | } | 1544 | } |
1545 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1545 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1546 | stream >> micMuted; | 1546 | stream >> micMuted; |
1547 | setMic(); | 1547 | setMic(); |
1548 | emit micChanged( micMuted ); | 1548 | emit micChanged( micMuted ); |
1549 | } | 1549 | } |
1550 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1550 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1551 | int t, v; | 1551 | int t, v; |
1552 | stream >> t >> v; | 1552 | stream >> t >> v; |
1553 | setBass( t, v ); | 1553 | setBass( t, v ); |
1554 | } | 1554 | } |
1555 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1555 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1556 | setBass(); | 1556 | setBass(); |
1557 | } | 1557 | } |
1558 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1558 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1559 | int t, v; | 1559 | int t, v; |
1560 | stream >> t >> v; | 1560 | stream >> t >> v; |
1561 | setTreble( t, v ); | 1561 | setTreble( t, v ); |
1562 | } | 1562 | } |
1563 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1563 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1564 | setTreble(); | 1564 | setTreble(); |
1565 | } else if ( msg == "getMarkedText()" ) { | 1565 | } else if ( msg == "getMarkedText()" ) { |
1566 | if ( type() == GuiServer ) { | 1566 | if ( type() == GuiServer ) { |
1567 | const ushort unicode = 'C'-'@'; | 1567 | const ushort unicode = 'C'-'@'; |
1568 | const int scan = Key_C; | 1568 | const int scan = Key_C; |
1569 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1569 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1570 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1570 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1571 | } | 1571 | } |
1572 | } else if ( msg == "newChannel(QString)") { | 1572 | } else if ( msg == "newChannel(QString)") { |
1573 | QString myChannel = "QPE/Application/" + d->appName; | 1573 | QString myChannel = "QPE/Application/" + d->appName; |
1574 | QString channel; | 1574 | QString channel; |
1575 | stream >> channel; | 1575 | stream >> channel; |
1576 | if (channel == myChannel) { | 1576 | if (channel == myChannel) { |
1577 | processQCopFile(); | 1577 | processQCopFile(); |
1578 | d->sendQCopQ(); | 1578 | d->sendQCopQ(); |
1579 | } | 1579 | } |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | 1582 | ||
1583 | #endif | 1583 | #endif |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | 1586 | ||
1587 | 1587 | ||
1588 | 1588 | ||
1589 | 1589 | ||
1590 | /*! | 1590 | /*! |
1591 | \internal | 1591 | \internal |
1592 | */ | 1592 | */ |
1593 | bool QPEApplication::raiseAppropriateWindow() | 1593 | bool QPEApplication::raiseAppropriateWindow() |
1594 | { | 1594 | { |
1595 | bool r=FALSE; | 1595 | bool r=FALSE; |
1596 | 1596 | ||
1597 | // 1. Raise the main widget | 1597 | // 1. Raise the main widget |
1598 | QWidget *top = d->qpe_main_widget; | 1598 | QWidget *top = d->qpe_main_widget; |
1599 | if ( !top ) top = mainWidget(); | 1599 | if ( !top ) top = mainWidget(); |
1600 | 1600 | ||
1601 | if ( top && d->keep_running ) { | 1601 | if ( top && d->keep_running ) { |
1602 | if ( top->isVisible() ) | 1602 | if ( top->isVisible() ) |
1603 | r = TRUE; | 1603 | r = TRUE; |
1604 | else if (d->preloaded) { | 1604 | else if (d->preloaded) { |
1605 | // We are preloaded and not visible.. pretend we just started.. | 1605 | // We are preloaded and not visible.. pretend we just started.. |
1606 | #ifndef QT_NO_COP | 1606 | #ifndef QT_NO_COP |
1607 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1607 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1608 | e << d->appName; | 1608 | e << d->appName; |
1609 | #endif | 1609 | #endif |
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | d->show_mx(top,d->nomaximize, d->appName); | 1612 | d->show_mx(top,d->nomaximize, d->appName); |
1613 | top->raise(); | 1613 | top->raise(); |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | QWidget *topm = activeModalWidget(); | 1616 | QWidget *topm = activeModalWidget(); |
1617 | 1617 | ||
1618 | // 2. Raise any parentless widgets (except top and topm, as they | 1618 | // 2. Raise any parentless widgets (except top and topm, as they |
1619 | // are raised before and after this loop). Order from most | 1619 | // are raised before and after this loop). Order from most |
1620 | // recently raised as deepest to least recently as top, so | 1620 | // recently raised as deepest to least recently as top, so |
1621 | // that repeated calls cycle through widgets. | 1621 | // that repeated calls cycle through widgets. |
1622 | QWidgetList *list = topLevelWidgets(); | 1622 | QWidgetList *list = topLevelWidgets(); |
1623 | if ( list ) { | 1623 | if ( list ) { |
1624 | bool foundlast = FALSE; | 1624 | bool foundlast = FALSE; |
1625 | QWidget* topsub = 0; | 1625 | QWidget* topsub = 0; |
1626 | if ( d->lastraised ) { | 1626 | if ( d->lastraised ) { |
1627 | for (QWidget* w = list->first(); w; w = list->next()) { | 1627 | for (QWidget* w = list->first(); w; w = list->next()) { |
1628 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1628 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1629 | if ( w == d->lastraised ) | 1629 | if ( w == d->lastraised ) |
1630 | foundlast = TRUE; | 1630 | foundlast = TRUE; |
1631 | if ( foundlast ) { | 1631 | if ( foundlast ) { |
1632 | w->raise(); | 1632 | w->raise(); |
1633 | topsub = w; | 1633 | topsub = w; |
1634 | } | 1634 | } |
1635 | } | 1635 | } |
1636 | } | 1636 | } |
1637 | } | 1637 | } |
1638 | for (QWidget* w = list->first(); w; w = list->next()) { | 1638 | for (QWidget* w = list->first(); w; w = list->next()) { |
1639 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1639 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1640 | if ( w == d->lastraised ) | 1640 | if ( w == d->lastraised ) |
1641 | break; | 1641 | break; |
1642 | w->raise(); | 1642 | w->raise(); |
1643 | topsub = w; | 1643 | topsub = w; |
1644 | } | 1644 | } |
1645 | } | 1645 | } |
1646 | d->lastraised = topsub; | 1646 | d->lastraised = topsub; |
1647 | delete list; | 1647 | delete list; |
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | // 3. Raise the active modal widget. | 1650 | // 3. Raise the active modal widget. |
1651 | if ( topm ) { | 1651 | if ( topm ) { |
1652 | topm->show(); | 1652 | topm->show(); |
1653 | topm->raise(); | 1653 | topm->raise(); |
1654 | // If we haven't already handled the fastAppShowing message | 1654 | // If we haven't already handled the fastAppShowing message |
1655 | if (!top && d->preloaded) { | 1655 | if (!top && d->preloaded) { |
1656 | #ifndef QT_NO_COP | 1656 | #ifndef QT_NO_COP |
1657 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1657 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1658 | e << d->appName; | 1658 | e << d->appName; |
1659 | #endif | 1659 | #endif |
1660 | } | 1660 | } |
1661 | r = FALSE; | 1661 | r = FALSE; |
1662 | } | 1662 | } |
1663 | 1663 | ||
1664 | return r; | 1664 | return r; |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | 1667 | ||
1668 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1668 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1669 | { | 1669 | { |
1670 | #ifdef Q_WS_QWS | 1670 | #ifdef Q_WS_QWS |
1671 | 1671 | ||
1672 | if ( msg == "quit()" ) { | 1672 | if ( msg == "quit()" ) { |
1673 | tryQuit(); | 1673 | tryQuit(); |
1674 | } | 1674 | } |
1675 | else if ( msg == "quitIfInvisible()" ) { | 1675 | else if ( msg == "quitIfInvisible()" ) { |
1676 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1676 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1677 | quit(); | 1677 | quit(); |
1678 | } | 1678 | } |
1679 | else if ( msg == "close()" ) { | 1679 | else if ( msg == "close()" ) { |
1680 | hideOrQuit(); | 1680 | hideOrQuit(); |
1681 | } | 1681 | } |
1682 | else if ( msg == "disablePreload()" ) { | 1682 | else if ( msg == "disablePreload()" ) { |
1683 | d->preloaded = FALSE; | 1683 | d->preloaded = FALSE; |
1684 | d->keep_running = TRUE; | 1684 | d->keep_running = TRUE; |
1685 | /* so that quit will quit */ | 1685 | /* so that quit will quit */ |
1686 | } | 1686 | } |
1687 | else if ( msg == "enablePreload()" ) { | 1687 | else if ( msg == "enablePreload()" ) { |
1688 | if (d->qpe_main_widget) | 1688 | if (d->qpe_main_widget) |
1689 | d->preloaded = TRUE; | 1689 | d->preloaded = TRUE; |
1690 | d->keep_running = TRUE; | 1690 | d->keep_running = TRUE; |
1691 | /* so next quit won't quit */ | 1691 | /* so next quit won't quit */ |
1692 | } | 1692 | } |
1693 | else if ( msg == "raise()" ) { | 1693 | else if ( msg == "raise()" ) { |
1694 | d->keep_running = TRUE; | 1694 | d->keep_running = TRUE; |
1695 | d->notbusysent = FALSE; | 1695 | d->notbusysent = FALSE; |
1696 | raiseAppropriateWindow(); | 1696 | raiseAppropriateWindow(); |
1697 | // Tell the system we're still chugging along... | 1697 | // Tell the system we're still chugging along... |
1698 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1698 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1699 | e << d->appName; | 1699 | e << d->appName; |
1700 | } | 1700 | } |
1701 | else if ( msg == "flush()" ) { | 1701 | else if ( msg == "flush()" ) { |
1702 | emit flush(); | 1702 | emit flush(); |
1703 | // we need to tell the desktop | 1703 | // we need to tell the desktop |
1704 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1704 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1705 | e << d->appName; | 1705 | e << d->appName; |
1706 | } | 1706 | } |
1707 | else if ( msg == "reload()" ) { | 1707 | else if ( msg == "reload()" ) { |
1708 | emit reload(); | 1708 | emit reload(); |
1709 | } | 1709 | } |
1710 | else if ( msg == "setDocument(QString)" ) { | 1710 | else if ( msg == "setDocument(QString)" ) { |
1711 | d->keep_running = TRUE; | 1711 | d->keep_running = TRUE; |
1712 | QDataStream stream( data, IO_ReadOnly ); | 1712 | QDataStream stream( data, IO_ReadOnly ); |
1713 | QString doc; | 1713 | QString doc; |
1714 | stream >> doc; | 1714 | stream >> doc; |
1715 | QWidget *mw = mainWidget(); | 1715 | QWidget *mw = mainWidget(); |
1716 | if ( !mw ) | 1716 | if ( !mw ) |
1717 | mw = d->qpe_main_widget; | 1717 | mw = d->qpe_main_widget; |
1718 | if ( mw ) | 1718 | if ( mw ) |
1719 | Global::setDocument( mw, doc ); | 1719 | Global::setDocument( mw, doc ); |
1720 | 1720 | ||
1721 | } else if ( msg == "QPEProcessQCop()" ) { | 1721 | } else if ( msg == "QPEProcessQCop()" ) { |
1722 | processQCopFile(); | 1722 | processQCopFile(); |
1723 | d->sendQCopQ(); | 1723 | d->sendQCopQ(); |
1724 | }else | 1724 | }else |
1725 | { | 1725 | { |
1726 | bool p = d->keep_running; | 1726 | bool p = d->keep_running; |
1727 | d->keep_running = FALSE; | 1727 | d->keep_running = FALSE; |
1728 | emit appMessage( msg, data); | 1728 | emit appMessage( msg, data); |
1729 | if ( d->keep_running ) { | 1729 | if ( d->keep_running ) { |
1730 | d->notbusysent = FALSE; | 1730 | d->notbusysent = FALSE; |
1731 | raiseAppropriateWindow(); | 1731 | raiseAppropriateWindow(); |
1732 | if ( !p ) { | 1732 | if ( !p ) { |
1733 | // Tell the system we're still chugging along... | 1733 | // Tell the system we're still chugging along... |
1734 | #ifndef QT_NO_COP | 1734 | #ifndef QT_NO_COP |
1735 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1735 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1736 | e << d->appName; | 1736 | e << d->appName; |
1737 | #endif | 1737 | #endif |
1738 | } | 1738 | } |
1739 | } | 1739 | } |
1740 | if ( p ) | 1740 | if ( p ) |
1741 | d->keep_running = p; | 1741 | d->keep_running = p; |
1742 | } | 1742 | } |
1743 | #endif | 1743 | #endif |
1744 | } | 1744 | } |
1745 | 1745 | ||
1746 | 1746 | ||
1747 | /*! | 1747 | /*! |
1748 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1748 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1749 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1749 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1750 | 1750 | ||
1751 | \sa showMainDocumentWidget() | 1751 | \sa showMainDocumentWidget() |
1752 | */ | 1752 | */ |
1753 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1753 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1754 | { | 1754 | { |
1755 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1755 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1756 | d->show(mw, nomaximize ); | 1756 | d->show(mw, nomaximize ); |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | /*! | 1759 | /*! |
1760 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1760 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1761 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1761 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1762 | 1762 | ||
1763 | This calls designates the application as | 1763 | This calls designates the application as |
1764 | a \link docwidget.html document-oriented\endlink application. | 1764 | a \link docwidget.html document-oriented\endlink application. |
1765 | 1765 | ||
1766 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1766 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1767 | 1767 | ||
1768 | \sa showMainWidget() | 1768 | \sa showMainWidget() |
1769 | */ | 1769 | */ |
1770 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1770 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1771 | { | 1771 | { |
1772 | if ( mw && argc() == 2 ) | 1772 | if ( mw ) { |
1773 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1773 | if ( argc() == 2 ) |
1774 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | ||
1774 | 1775 | ||
1775 | 1776 | d->show(mw, nomaximize ); | |
1776 | // setMainWidget(mw); see above | 1777 | } |
1777 | d->show(mw, nomaximize ); | ||
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | 1780 | ||
1781 | /*! | 1781 | /*! |
1782 | If an application is started via a \link qcop.html QCop\endlink | 1782 | If an application is started via a \link qcop.html QCop\endlink |
1783 | message, the application will process the \link qcop.html | 1783 | message, the application will process the \link qcop.html |
1784 | QCop\endlink message and then quit. If the application calls this | 1784 | QCop\endlink message and then quit. If the application calls this |
1785 | function while processing a \link qcop.html QCop\endlink message, | 1785 | function while processing a \link qcop.html QCop\endlink message, |
1786 | after processing its outstanding \link qcop.html QCop\endlink | 1786 | after processing its outstanding \link qcop.html QCop\endlink |
1787 | messages the application will start 'properly' and show itself. | 1787 | messages the application will start 'properly' and show itself. |
1788 | 1788 | ||
1789 | \sa keepRunning() | 1789 | \sa keepRunning() |
1790 | */ | 1790 | */ |
1791 | void QPEApplication::setKeepRunning() | 1791 | void QPEApplication::setKeepRunning() |
1792 | { | 1792 | { |
1793 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1793 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1794 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1794 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1795 | qpeApp->d->keep_running = TRUE; | 1795 | qpeApp->d->keep_running = TRUE; |
1796 | } | 1796 | } |
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | /*! | 1799 | /*! |
1800 | Returns TRUE if the application will quit after processing the | 1800 | Returns TRUE if the application will quit after processing the |
1801 | current list of qcop messages; otherwise returns FALSE. | 1801 | current list of qcop messages; otherwise returns FALSE. |
1802 | 1802 | ||
1803 | \sa setKeepRunning() | 1803 | \sa setKeepRunning() |
1804 | */ | 1804 | */ |
1805 | bool QPEApplication::keepRunning() const | 1805 | bool QPEApplication::keepRunning() const |
1806 | { | 1806 | { |
1807 | return d->keep_running; | 1807 | return d->keep_running; |
1808 | } | 1808 | } |
1809 | 1809 | ||
1810 | /*! | 1810 | /*! |
1811 | \internal | 1811 | \internal |
1812 | */ | 1812 | */ |
1813 | void QPEApplication::internalSetStyle( const QString &style ) | 1813 | void QPEApplication::internalSetStyle( const QString &style ) |
1814 | { | 1814 | { |
1815 | #if QT_VERSION >= 0x030000 | 1815 | #if QT_VERSION >= 0x030000 |
1816 | if ( style == "QPE" ) { | 1816 | if ( style == "QPE" ) { |
1817 | setStyle( new QPEStyle ); | 1817 | setStyle( new QPEStyle ); |
1818 | } | 1818 | } |
1819 | else { | 1819 | else { |
1820 | QStyle *s = QStyleFactory::create( style ); | 1820 | QStyle *s = QStyleFactory::create( style ); |
1821 | if ( s ) | 1821 | if ( s ) |
1822 | setStyle( s ); | 1822 | setStyle( s ); |
1823 | } | 1823 | } |
1824 | #else | 1824 | #else |
1825 | if ( style == "Windows" ) { | 1825 | if ( style == "Windows" ) { |
1826 | setStyle( new QWindowsStyle ); | 1826 | setStyle( new QWindowsStyle ); |
1827 | } | 1827 | } |
1828 | else if ( style == "QPE" ) { | 1828 | else if ( style == "QPE" ) { |
1829 | setStyle( new QPEStyle ); | 1829 | setStyle( new QPEStyle ); |
1830 | } | 1830 | } |
1831 | else if ( style == "Light" ) { | 1831 | else if ( style == "Light" ) { |
1832 | setStyle( new LightStyle ); | 1832 | setStyle( new LightStyle ); |
1833 | } | 1833 | } |
1834 | #ifndef QT_NO_STYLE_PLATINUM | 1834 | #ifndef QT_NO_STYLE_PLATINUM |
1835 | else if ( style == "Platinum" ) { | 1835 | else if ( style == "Platinum" ) { |
1836 | setStyle( new QPlatinumStyle ); | 1836 | setStyle( new QPlatinumStyle ); |
1837 | } | 1837 | } |
1838 | #endif | 1838 | #endif |
1839 | #ifndef QT_NO_STYLE_MOTIF | 1839 | #ifndef QT_NO_STYLE_MOTIF |
1840 | else if ( style == "Motif" ) { | 1840 | else if ( style == "Motif" ) { |
1841 | setStyle( new QMotifStyle ); | 1841 | setStyle( new QMotifStyle ); |
1842 | } | 1842 | } |
1843 | #endif | 1843 | #endif |
1844 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1844 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1845 | else if ( style == "MotifPlus" ) { | 1845 | else if ( style == "MotifPlus" ) { |
1846 | setStyle( new QMotifPlusStyle ); | 1846 | setStyle( new QMotifPlusStyle ); |
1847 | } | 1847 | } |
1848 | #endif | 1848 | #endif |
1849 | 1849 | ||
1850 | else { | 1850 | else { |
1851 | QStyle *sty = 0; | 1851 | QStyle *sty = 0; |
1852 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; | 1852 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
1853 | 1853 | ||
1854 | #ifdef Q_OS_MACX | 1854 | #ifdef Q_OS_MACX |
1855 | if ( style. find ( ".dylib" ) > 0 ) | 1855 | if ( style. find ( ".dylib" ) > 0 ) |
1856 | path += style; | 1856 | path += style; |
1857 | else | 1857 | else |
1858 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1858 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1859 | #else | 1859 | #else |
1860 | if ( style. find ( ".so" ) > 0 ) | 1860 | if ( style. find ( ".so" ) > 0 ) |
1861 | path += style; | 1861 | path += style; |
1862 | else | 1862 | else |
1863 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1863 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1864 | #endif | 1864 | #endif |
1865 | static QLibrary *lastlib = 0; | 1865 | static QLibrary *lastlib = 0; |
1866 | static StyleInterface *lastiface = 0; | 1866 | static StyleInterface *lastiface = 0; |
1867 | 1867 | ||
1868 | QLibrary *lib = new QLibrary ( path ); | 1868 | QLibrary *lib = new QLibrary ( path ); |
1869 | StyleInterface *iface = 0; | 1869 | StyleInterface *iface = 0; |
1870 | 1870 | ||
1871 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1871 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1872 | sty = iface-> style ( ); | 1872 | sty = iface-> style ( ); |
1873 | 1873 | ||
1874 | if ( sty ) { | 1874 | if ( sty ) { |
1875 | setStyle ( sty ); | 1875 | setStyle ( sty ); |
1876 | 1876 | ||
1877 | if ( lastiface ) | 1877 | if ( lastiface ) |
1878 | lastiface-> release ( ); | 1878 | lastiface-> release ( ); |
1879 | lastiface = iface; | 1879 | lastiface = iface; |
1880 | 1880 | ||
1881 | if ( lastlib ) { | 1881 | if ( lastlib ) { |
1882 | lastlib-> unload ( ); | 1882 | lastlib-> unload ( ); |
1883 | delete lastlib; | 1883 | delete lastlib; |
1884 | } | 1884 | } |
1885 | lastlib = lib; | 1885 | lastlib = lib; |
1886 | } | 1886 | } |
1887 | else { | 1887 | else { |
1888 | if ( iface ) | 1888 | if ( iface ) |
1889 | iface-> release ( ); | 1889 | iface-> release ( ); |
1890 | delete lib; | 1890 | delete lib; |
1891 | 1891 | ||
1892 | setStyle ( new LightStyle ( )); | 1892 | setStyle ( new LightStyle ( )); |
1893 | } | 1893 | } |
1894 | } | 1894 | } |
1895 | #endif | 1895 | #endif |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | /*! | 1898 | /*! |
1899 | \internal | 1899 | \internal |
1900 | */ | 1900 | */ |
1901 | void QPEApplication::prepareForTermination( bool willrestart ) | 1901 | void QPEApplication::prepareForTermination( bool willrestart ) |
1902 | { | 1902 | { |
1903 | if ( willrestart ) { | 1903 | if ( willrestart ) { |
1904 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1904 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1905 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1905 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1906 | lblWait->setAlignment( QWidget::AlignCenter ); | 1906 | lblWait->setAlignment( QWidget::AlignCenter ); |
1907 | lblWait->show(); | 1907 | lblWait->show(); |
1908 | lblWait->showMaximized(); | 1908 | lblWait->showMaximized(); |
1909 | } | 1909 | } |
1910 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1910 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1911 | } | 1911 | } |
1912 | processEvents(); // ensure the message goes out. | 1912 | processEvents(); // ensure the message goes out. |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | /*! | 1915 | /*! |
1916 | \internal | 1916 | \internal |
1917 | */ | 1917 | */ |
1918 | void QPEApplication::shutdown() | 1918 | void QPEApplication::shutdown() |
1919 | { | 1919 | { |
1920 | // Implement in server's QPEApplication subclass | 1920 | // Implement in server's QPEApplication subclass |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | /*! | 1923 | /*! |
1924 | \internal | 1924 | \internal |
1925 | */ | 1925 | */ |
1926 | void QPEApplication::restart() | 1926 | void QPEApplication::restart() |
1927 | { | 1927 | { |
1928 | // Implement in server's QPEApplication subclass | 1928 | // Implement in server's QPEApplication subclass |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | static QPtrDict<void>* stylusDict = 0; | 1931 | static QPtrDict<void>* stylusDict = 0; |
1932 | static void createDict() | 1932 | static void createDict() |
1933 | { | 1933 | { |
1934 | if ( !stylusDict ) | 1934 | if ( !stylusDict ) |
1935 | stylusDict = new QPtrDict<void>; | 1935 | stylusDict = new QPtrDict<void>; |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | /*! | 1938 | /*! |
1939 | Returns the current StylusMode for widget \a w. | 1939 | Returns the current StylusMode for widget \a w. |
1940 | 1940 | ||
1941 | \sa setStylusOperation() StylusMode | 1941 | \sa setStylusOperation() StylusMode |
1942 | */ | 1942 | */ |
1943 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1943 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1944 | { | 1944 | { |
1945 | if ( stylusDict ) | 1945 | if ( stylusDict ) |
1946 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1946 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1947 | return LeftOnly; | 1947 | return LeftOnly; |
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | /*! | 1950 | /*! |
1951 | \enum QPEApplication::StylusMode | 1951 | \enum QPEApplication::StylusMode |
1952 | 1952 | ||
1953 | \value LeftOnly the stylus only generates LeftButton | 1953 | \value LeftOnly the stylus only generates LeftButton |
1954 | events (the default). | 1954 | events (the default). |
1955 | \value RightOnHold the stylus generates RightButton events | 1955 | \value RightOnHold the stylus generates RightButton events |
1956 | if the user uses the press-and-hold gesture. | 1956 | if the user uses the press-and-hold gesture. |
1957 | 1957 | ||
1958 | \sa setStylusOperation() stylusOperation() | 1958 | \sa setStylusOperation() stylusOperation() |
1959 | */ | 1959 | */ |
1960 | 1960 | ||
1961 | /*! | 1961 | /*! |
1962 | Causes widget \a w to receive mouse events according to the stylus | 1962 | Causes widget \a w to receive mouse events according to the stylus |
1963 | \a mode. | 1963 | \a mode. |
1964 | 1964 | ||
1965 | \sa stylusOperation() StylusMode | 1965 | \sa stylusOperation() StylusMode |
1966 | */ | 1966 | */ |
1967 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1967 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1968 | { | 1968 | { |
1969 | createDict(); | 1969 | createDict(); |
1970 | if ( mode == LeftOnly ) { | 1970 | if ( mode == LeftOnly ) { |
1971 | stylusDict->remove | 1971 | stylusDict->remove |
1972 | ( w ); | 1972 | ( w ); |
1973 | w->removeEventFilter( qApp ); | 1973 | w->removeEventFilter( qApp ); |
1974 | } | 1974 | } |
1975 | else { | 1975 | else { |
1976 | stylusDict->insert( w, ( void* ) mode ); | 1976 | stylusDict->insert( w, ( void* ) mode ); |
1977 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1977 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1978 | w->installEventFilter( qApp ); | 1978 | w->installEventFilter( qApp ); |
1979 | } | 1979 | } |
1980 | } | 1980 | } |
1981 | 1981 | ||
1982 | 1982 | ||
1983 | /*! | 1983 | /*! |
1984 | \reimp | 1984 | \reimp |
1985 | */ | 1985 | */ |
1986 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1986 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1987 | { | 1987 | { |
1988 | if ( !o->isWidgetType() ) | 1988 | if ( !o->isWidgetType() ) |
1989 | return FALSE; | 1989 | return FALSE; |
1990 | 1990 | ||
1991 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1991 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1992 | QMouseEvent * me = ( QMouseEvent* ) e; | 1992 | QMouseEvent * me = ( QMouseEvent* ) e; |
1993 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1993 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1994 | switch (mode) { | 1994 | switch (mode) { |
1995 | case RightOnHold: | 1995 | case RightOnHold: |
1996 | switch ( me->type() ) { | 1996 | switch ( me->type() ) { |
1997 | case QEvent::MouseButtonPress: | 1997 | case QEvent::MouseButtonPress: |
1998 | if ( me->button() == LeftButton ) { | 1998 | if ( me->button() == LeftButton ) { |
1999 | static long Pref = 500; // #### pref. | 1999 | static long Pref = 500; // #### pref. |
2000 | d->presswidget = (QWidget*)o; | 2000 | d->presswidget = (QWidget*)o; |
2001 | d->presspos = me->pos(); | 2001 | d->presspos = me->pos(); |
2002 | d->rightpressed = FALSE; | 2002 | d->rightpressed = FALSE; |
2003 | #ifdef OPIE_WITHROHFEEDBACK | 2003 | #ifdef OPIE_WITHROHFEEDBACK |
2004 | if( ! d->RoH ) | 2004 | if( ! d->RoH ) |
2005 | d->RoH = new Opie::Internal::RoHFeedback; | 2005 | d->RoH = new Opie::Internal::RoHFeedback; |
2006 | 2006 | ||
2007 | d->RoH->init( me->globalPos(), d->presswidget ); | 2007 | d->RoH->init( me->globalPos(), d->presswidget ); |
2008 | Pref = d->RoH->delay(); | 2008 | Pref = d->RoH->delay(); |
2009 | 2009 | ||
2010 | #endif | 2010 | #endif |
2011 | if (!d->presstimer ) | 2011 | if (!d->presstimer ) |
2012 | d->presstimer = startTimer( Pref ); // #### pref. | 2012 | d->presstimer = startTimer( Pref ); // #### pref. |
2013 | 2013 | ||
2014 | } | 2014 | } |
2015 | break; | 2015 | break; |
2016 | case QEvent::MouseMove: | 2016 | case QEvent::MouseMove: |
2017 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2017 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2018 | killTimer(d->presstimer); | 2018 | killTimer(d->presstimer); |
2019 | #ifdef OPIE_WITHROHFEEDBACK | 2019 | #ifdef OPIE_WITHROHFEEDBACK |
2020 | d->RoH->stop(); | 2020 | d->RoH->stop(); |
2021 | #endif | 2021 | #endif |
2022 | d->presstimer = 0; | 2022 | d->presstimer = 0; |
2023 | } | 2023 | } |
2024 | break; | 2024 | break; |
2025 | case QEvent::MouseButtonRelease: | 2025 | case QEvent::MouseButtonRelease: |
2026 | if ( me->button() == LeftButton ) { | 2026 | if ( me->button() == LeftButton ) { |
2027 | if ( d->presstimer ) { | 2027 | if ( d->presstimer ) { |
2028 | killTimer(d->presstimer); | 2028 | killTimer(d->presstimer); |
2029 | #ifdef OPIE_WITHROHFEEDBACK | 2029 | #ifdef OPIE_WITHROHFEEDBACK |
2030 | d->RoH->stop( ); | 2030 | d->RoH->stop( ); |
2031 | #endif | 2031 | #endif |
2032 | d->presstimer = 0; | 2032 | d->presstimer = 0; |
2033 | } | 2033 | } |
2034 | if ( d->rightpressed && d->presswidget ) { | 2034 | if ( d->rightpressed && d->presswidget ) { |
2035 | printf( "Send ButtonRelease\n" ); | 2035 | printf( "Send ButtonRelease\n" ); |
2036 | // Right released | 2036 | // Right released |
2037 | postEvent( d->presswidget, | 2037 | postEvent( d->presswidget, |
2038 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2038 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2039 | RightButton, LeftButton + RightButton ) ); | 2039 | RightButton, LeftButton + RightButton ) ); |
2040 | // Left released, off-widget | 2040 | // Left released, off-widget |
2041 | postEvent( d->presswidget, | 2041 | postEvent( d->presswidget, |
2042 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2042 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2043 | LeftButton, LeftButton ) ); | 2043 | LeftButton, LeftButton ) ); |
2044 | postEvent( d->presswidget, | 2044 | postEvent( d->presswidget, |
2045 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2045 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2046 | LeftButton, LeftButton ) ); | 2046 | LeftButton, LeftButton ) ); |
2047 | d->rightpressed = FALSE; | 2047 | d->rightpressed = FALSE; |
2048 | return TRUE; // don't send the real Left release | 2048 | return TRUE; // don't send the real Left release |
2049 | } | 2049 | } |
2050 | } | 2050 | } |
2051 | break; | 2051 | break; |
2052 | default: | 2052 | default: |
2053 | break; | 2053 | break; |
2054 | } | 2054 | } |
2055 | break; | 2055 | break; |
2056 | default: | 2056 | default: |
2057 | ; | 2057 | ; |
2058 | } | 2058 | } |
2059 | } | 2059 | } |
2060 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2060 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2061 | QKeyEvent *ke = (QKeyEvent *)e; | 2061 | QKeyEvent *ke = (QKeyEvent *)e; |
2062 | if ( ke->key() == Key_Enter ) { | 2062 | if ( ke->key() == Key_Enter ) { |
2063 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2063 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2064 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2064 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2065 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2065 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2066 | return TRUE; | 2066 | return TRUE; |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | } | 2069 | } |
2070 | return FALSE; | 2070 | return FALSE; |
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | /*! | 2073 | /*! |
2074 | \reimp | 2074 | \reimp |
2075 | */ | 2075 | */ |
2076 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2076 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2077 | { | 2077 | { |
2078 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2078 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2079 | 2079 | ||
2080 | // Right pressed | 2080 | // Right pressed |
2081 | postEvent( d->presswidget, | 2081 | postEvent( d->presswidget, |
2082 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2082 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2083 | RightButton, LeftButton ) ); | 2083 | RightButton, LeftButton ) ); |
2084 | killTimer( d->presstimer ); | 2084 | killTimer( d->presstimer ); |
2085 | d->presstimer = 0; | 2085 | d->presstimer = 0; |
2086 | d->rightpressed = TRUE; | 2086 | d->rightpressed = TRUE; |
2087 | #ifdef OPIE_WITHROHFEEDBACK | 2087 | #ifdef OPIE_WITHROHFEEDBACK |
2088 | d->RoH->stop(); | 2088 | d->RoH->stop(); |
2089 | #endif | 2089 | #endif |
2090 | } | 2090 | } |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | void QPEApplication::removeSenderFromStylusDict() | 2093 | void QPEApplication::removeSenderFromStylusDict() |
2094 | { | 2094 | { |
2095 | stylusDict->remove | 2095 | stylusDict->remove |
2096 | ( ( void* ) sender() ); | 2096 | ( ( void* ) sender() ); |
2097 | if ( d->presswidget == sender() ) | 2097 | if ( d->presswidget == sender() ) |
2098 | d->presswidget = 0; | 2098 | d->presswidget = 0; |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | /*! | 2101 | /*! |
2102 | \internal | 2102 | \internal |
2103 | */ | 2103 | */ |
2104 | bool QPEApplication::keyboardGrabbed() const | 2104 | bool QPEApplication::keyboardGrabbed() const |
2105 | { | 2105 | { |
2106 | return d->kbgrabbed; | 2106 | return d->kbgrabbed; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | 2109 | ||
2110 | /*! | 2110 | /*! |
2111 | Reverses the effect of grabKeyboard(). This is called automatically | 2111 | Reverses the effect of grabKeyboard(). This is called automatically |
2112 | on program exit. | 2112 | on program exit. |
2113 | */ | 2113 | */ |
2114 | void QPEApplication::ungrabKeyboard() | 2114 | void QPEApplication::ungrabKeyboard() |
2115 | { | 2115 | { |
2116 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2116 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2117 | } | 2117 | } |
2118 | 2118 | ||
2119 | /*! | 2119 | /*! |
2120 | Grabs the physical keyboard keys, e.g. the application's launching | 2120 | Grabs the physical keyboard keys, e.g. the application's launching |
2121 | keys. Instead of launching applications when these keys are pressed | 2121 | keys. Instead of launching applications when these keys are pressed |
2122 | the signals emitted are sent to this application instead. Some games | 2122 | the signals emitted are sent to this application instead. Some games |
2123 | programs take over the launch keys in this way to make interaction | 2123 | programs take over the launch keys in this way to make interaction |
2124 | easier. | 2124 | easier. |
2125 | 2125 | ||
2126 | \sa ungrabKeyboard() | 2126 | \sa ungrabKeyboard() |
2127 | */ | 2127 | */ |
2128 | void QPEApplication::grabKeyboard() | 2128 | void QPEApplication::grabKeyboard() |
2129 | { | 2129 | { |
2130 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2130 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2131 | } | 2131 | } |
2132 | 2132 | ||
2133 | /*! | 2133 | /*! |
2134 | \reimp | 2134 | \reimp |
2135 | */ | 2135 | */ |
2136 | int QPEApplication::exec() | 2136 | int QPEApplication::exec() |
2137 | { | 2137 | { |
2138 | d->qcopQok = true; | 2138 | d->qcopQok = true; |
2139 | #ifndef QT_NO_COP | 2139 | #ifndef QT_NO_COP |
2140 | d->sendQCopQ(); | 2140 | d->sendQCopQ(); |
2141 | if ( !d->keep_running ) | 2141 | if ( !d->keep_running ) |
2142 | processEvents(); // we may have received QCop messages in the meantime. | 2142 | processEvents(); // we may have received QCop messages in the meantime. |
2143 | #endif | 2143 | #endif |
2144 | 2144 | ||
2145 | if ( d->keep_running ) | 2145 | if ( d->keep_running ) |
2146 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2146 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2147 | return QApplication::exec(); | 2147 | return QApplication::exec(); |
2148 | 2148 | ||
2149 | #ifndef QT_NO_COP | 2149 | #ifndef QT_NO_COP |
2150 | 2150 | ||
2151 | { | 2151 | { |
2152 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2152 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2153 | e << d->appName; | 2153 | e << d->appName; |
2154 | } | 2154 | } |
2155 | #endif | 2155 | #endif |
2156 | processEvents(); | 2156 | processEvents(); |
2157 | return 0; | 2157 | return 0; |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | /*! | 2160 | /*! |
2161 | \internal | 2161 | \internal |
2162 | External request for application to quit. Quits if possible without | 2162 | External request for application to quit. Quits if possible without |
2163 | loosing state. | 2163 | loosing state. |
2164 | */ | 2164 | */ |
2165 | void QPEApplication::tryQuit() | 2165 | void QPEApplication::tryQuit() |
2166 | { | 2166 | { |
2167 | if ( activeModalWidget() ) | 2167 | if ( activeModalWidget() ) |
2168 | return ; // Inside modal loop or konsole. Too hard to save state. | 2168 | return ; // Inside modal loop or konsole. Too hard to save state. |
2169 | #ifndef QT_NO_COP | 2169 | #ifndef QT_NO_COP |
2170 | 2170 | ||
2171 | { | 2171 | { |
2172 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2172 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2173 | e << d->appName; | 2173 | e << d->appName; |
2174 | } | 2174 | } |
2175 | #endif | 2175 | #endif |
2176 | if ( d->keep_running ) | 2176 | if ( d->keep_running ) |
2177 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2177 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2178 | processEvents(); | 2178 | processEvents(); |
2179 | 2179 | ||
2180 | quit(); | 2180 | quit(); |
2181 | } | 2181 | } |
2182 | 2182 | ||
2183 | 2183 | ||
2184 | /*! | 2184 | /*! |
2185 | \internal | 2185 | \internal |
2186 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2186 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2187 | hiding the window. If not it means quitting the application. | 2187 | hiding the window. If not it means quitting the application. |
2188 | As this is user initiated we don't need to check state. | 2188 | As this is user initiated we don't need to check state. |
2189 | */ | 2189 | */ |
2190 | void QPEApplication::hideOrQuit() | 2190 | void QPEApplication::hideOrQuit() |
2191 | { | 2191 | { |
2192 | if ( d->keep_running ) | 2192 | if ( d->keep_running ) |
2193 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2193 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2194 | processEvents(); | 2194 | processEvents(); |
2195 | 2195 | ||
2196 | // If we are a preloaded application we don't actually quit, so emit | 2196 | // If we are a preloaded application we don't actually quit, so emit |
2197 | // a System message indicating we're quasi-closing. | 2197 | // a System message indicating we're quasi-closing. |
2198 | if ( d->preloaded && d->qpe_main_widget ) | 2198 | if ( d->preloaded && d->qpe_main_widget ) |
2199 | #ifndef QT_NO_COP | 2199 | #ifndef QT_NO_COP |
2200 | 2200 | ||
2201 | { | 2201 | { |
2202 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2202 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2203 | e << d->appName; | 2203 | e << d->appName; |
2204 | d->qpe_main_widget->hide(); | 2204 | d->qpe_main_widget->hide(); |
2205 | } | 2205 | } |
2206 | #endif | 2206 | #endif |
2207 | else | 2207 | else |
2208 | quit(); | 2208 | quit(); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | bool QPEApplication::isSaveWindowsPos() | 2211 | bool QPEApplication::isSaveWindowsPos() |
2212 | { | 2212 | { |
2213 | return saveWindowsPos; | 2213 | return saveWindowsPos; |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | #if (__GNUC__ > 2 ) && !defined(_OS_MACX_) | 2216 | #if (__GNUC__ > 2 ) && !defined(_OS_MACX_) |
2217 | extern "C" void __cxa_pure_virtual(); | 2217 | extern "C" void __cxa_pure_virtual(); |
2218 | 2218 | ||
2219 | void __cxa_pure_virtual() | 2219 | void __cxa_pure_virtual() |
2220 | { | 2220 | { |
2221 | fprintf( stderr, "Pure virtual called\n"); | 2221 | fprintf( stderr, "Pure virtual called\n"); |
2222 | abort(); | 2222 | abort(); |
2223 | 2223 | ||
2224 | } | 2224 | } |
2225 | 2225 | ||
2226 | #endif | 2226 | #endif |
2227 | 2227 | ||
2228 | 2228 | ||
2229 | #if defined(OPIE_NEW_MALLOC) | 2229 | #if defined(OPIE_NEW_MALLOC) |
2230 | 2230 | ||
2231 | // The libraries with the skiff package (and possibly others) have | 2231 | // The libraries with the skiff package (and possibly others) have |
2232 | // completely useless implementations of builtin new and delete that | 2232 | // completely useless implementations of builtin new and delete that |
2233 | // use about 50% of your CPU. Here we revert to the simple libc | 2233 | // use about 50% of your CPU. Here we revert to the simple libc |
2234 | // functions. | 2234 | // functions. |
2235 | 2235 | ||
2236 | void* operator new[]( size_t size ) | 2236 | void* operator new[]( size_t size ) |
2237 | { | 2237 | { |
2238 | return malloc( size ); | 2238 | return malloc( size ); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void* operator new( size_t size ) | 2241 | void* operator new( size_t size ) |
2242 | { | 2242 | { |
2243 | return malloc( size ); | 2243 | return malloc( size ); |
2244 | } | 2244 | } |
2245 | 2245 | ||
2246 | void operator delete[]( void* p ) | 2246 | void operator delete[]( void* p ) |
2247 | { | 2247 | { |
2248 | if ( p ) | 2248 | if ( p ) |
2249 | free( p ); | 2249 | free( p ); |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | void operator delete[]( void* p, size_t /*size*/ ) | 2252 | void operator delete[]( void* p, size_t /*size*/ ) |
2253 | { | 2253 | { |
2254 | if ( p ) | 2254 | if ( p ) |
2255 | free( p ); | 2255 | free( p ); |
2256 | } | 2256 | } |
2257 | 2257 | ||
2258 | 2258 | ||
2259 | void operator delete( void* p ) | 2259 | void operator delete( void* p ) |
2260 | { | 2260 | { |
2261 | if ( p ) | 2261 | if ( p ) |
2262 | free( p ); | 2262 | free( p ); |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | void operator delete( void* p, size_t /*size*/ ) | 2265 | void operator delete( void* p, size_t /*size*/ ) |
2266 | { | 2266 | { |
2267 | if ( p ) | 2267 | if ( p ) |
2268 | free( p ); | 2268 | free( p ); |
2269 | } | 2269 | } |
2270 | 2270 | ||
2271 | #endif | 2271 | #endif |
2272 | 2272 | ||
2273 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2273 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2274 | #include <qwidgetlist.h> | 2274 | #include <qwidgetlist.h> |
2275 | #ifdef QWS | 2275 | #ifdef QWS |
2276 | #include <qgfx_qws.h> | 2276 | #include <qgfx_qws.h> |
2277 | extern QRect qt_maxWindowRect; | 2277 | extern QRect qt_maxWindowRect; |
2278 | void qt_setMaxWindowRect(const QRect& r ) | 2278 | void qt_setMaxWindowRect(const QRect& r ) |
2279 | { | 2279 | { |
2280 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2280 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2281 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2281 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2282 | // Re-resize any maximized windows | 2282 | // Re-resize any maximized windows |
2283 | QWidgetList* l = QApplication::topLevelWidgets(); | 2283 | QWidgetList* l = QApplication::topLevelWidgets(); |
2284 | if ( l ) { | 2284 | if ( l ) { |
2285 | QWidget * w = l->first(); | 2285 | QWidget * w = l->first(); |
2286 | while ( w ) { | 2286 | while ( w ) { |
2287 | if ( w->isVisible() && w->isMaximized() ) { | 2287 | if ( w->isVisible() && w->isMaximized() ) { |
2288 | w->showMaximized(); | 2288 | w->showMaximized(); |
2289 | } | 2289 | } |
2290 | w = l->next(); | 2290 | w = l->next(); |
2291 | } | 2291 | } |
2292 | delete l; | 2292 | delete l; |
2293 | } | 2293 | } |
2294 | } | 2294 | } |
2295 | #endif | 2295 | #endif |
2296 | #endif | 2296 | #endif |