author | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
commit | 9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (patch) (unidiff) | |
tree | 53927c6a19c69d54bb3d0e092ac57180bcb60222 /library/qpeapplication.cpp | |
parent | ed70ec4945c7816ec6e899207ec8b99e20e10da5 (diff) | |
download | opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.zip opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.gz opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.bz2 |
added support for DEVFS
-rw-r--r-- | library/qpeapplication.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c6d9cfd..ca90427 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -376,456 +376,472 @@ static void qpe_show_dialog( QDialog* d, bool nomax ) | |||
376 | return TRUE; | 376 | return TRUE; |
377 | } | 377 | } |
378 | 378 | ||
379 | static void store_widget_rect(QWidget *w, QString &app) | 379 | static void store_widget_rect(QWidget *w, QString &app) |
380 | { | 380 | { |
381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
382 | if ( qApp->desktop()->width() <= 350 ) | 382 | if ( qApp->desktop()->width() <= 350 ) |
383 | return; | 383 | return; |
384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
385 | // get the non-maximized version, so we have to do it the hard way ) | 385 | // get the non-maximized version, so we have to do it the hard way ) |
386 | int offsetX = w->x() - w->geometry().left(); | 386 | int offsetX = w->x() - w->geometry().left(); |
387 | int offsetY = w->y() - w->geometry().top(); | 387 | int offsetY = w->y() - w->geometry().top(); |
388 | 388 | ||
389 | QRect r; | 389 | QRect r; |
390 | if ( w->isMaximized() ) | 390 | if ( w->isMaximized() ) |
391 | r = ( (HackWidget *) w)->normalGeometry(); | 391 | r = ( (HackWidget *) w)->normalGeometry(); |
392 | else | 392 | else |
393 | r = w->geometry(); | 393 | r = w->geometry(); |
394 | 394 | ||
395 | // Stores the window placement as pos(), size() (due to the offset mapping) | 395 | // Stores the window placement as pos(), size() (due to the offset mapping) |
396 | Config cfg( "qpe" ); | 396 | Config cfg( "qpe" ); |
397 | cfg.setGroup("ApplicationPositions"); | 397 | cfg.setGroup("ApplicationPositions"); |
398 | QString s; | 398 | QString s; |
399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
400 | cfg.writeEntry( app, s ); | 400 | cfg.writeEntry( app, s ); |
401 | } | 401 | } |
402 | 402 | ||
403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
404 | { | 404 | { |
405 | /* | 405 | /* |
406 | // This works but disable it for now until it is safe to apply | 406 | // This works but disable it for now until it is safe to apply |
407 | // What is does is scan the .desktop files of all the apps for | 407 | // What is does is scan the .desktop files of all the apps for |
408 | // the applnk that has the corresponding argv[0] as this program | 408 | // the applnk that has the corresponding argv[0] as this program |
409 | // then it uses the name stored in the .desktop file as the caption | 409 | // then it uses the name stored in the .desktop file as the caption |
410 | // for the main widget. This saves duplicating translations for | 410 | // for the main widget. This saves duplicating translations for |
411 | // the app name in the program and in the .desktop files. | 411 | // the app name in the program and in the .desktop files. |
412 | 412 | ||
413 | AppLnkSet apps( appsPath ); | 413 | AppLnkSet apps( appsPath ); |
414 | 414 | ||
415 | QList<AppLnk> appsList = apps.children(); | 415 | QList<AppLnk> appsList = apps.children(); |
416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
417 | if ( (*it)->exec() == appName ) { | 417 | if ( (*it)->exec() == appName ) { |
418 | mw->setCaption( (*it)->name() ); | 418 | mw->setCaption( (*it)->name() ); |
419 | return TRUE; | 419 | return TRUE; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | */ | 422 | */ |
423 | return FALSE; | 423 | return FALSE; |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | void show(QWidget* mw, bool nomax) | 427 | void show(QWidget* mw, bool nomax) |
428 | { | 428 | { |
429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
430 | nomaximize = nomax; | 430 | nomaximize = nomax; |
431 | qpe_main_widget = mw; | 431 | qpe_main_widget = mw; |
432 | qcopQok = TRUE; | 432 | qcopQok = TRUE; |
433 | #ifndef QT_NO_COP | 433 | #ifndef QT_NO_COP |
434 | 434 | ||
435 | sendQCopQ(); | 435 | sendQCopQ(); |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | if ( preloaded ) { | 438 | if ( preloaded ) { |
439 | if (forceshow) | 439 | if (forceshow) |
440 | show_mx(mw, nomax, appName); | 440 | show_mx(mw, nomax, appName); |
441 | } | 441 | } |
442 | else if ( keep_running ) { | 442 | else if ( keep_running ) { |
443 | show_mx(mw, nomax, appName); | 443 | show_mx(mw, nomax, appName); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | void loadTextCodecs() | 447 | void loadTextCodecs() |
448 | { | 448 | { |
449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
450 | #ifdef Q_OS_MACX | 450 | #ifdef Q_OS_MACX |
451 | QDir dir( path, "lib*.dylib" ); | 451 | QDir dir( path, "lib*.dylib" ); |
452 | #else | 452 | #else |
453 | QDir dir( path, "lib*.so" ); | 453 | QDir dir( path, "lib*.so" ); |
454 | #endif | 454 | #endif |
455 | QStringList list; | 455 | QStringList list; |
456 | if ( dir. exists ( )) | 456 | if ( dir. exists ( )) |
457 | list = dir.entryList(); | 457 | list = dir.entryList(); |
458 | QStringList::Iterator it; | 458 | QStringList::Iterator it; |
459 | for ( it = list.begin(); it != list.end(); ++it ) { | 459 | for ( it = list.begin(); it != list.end(); ++it ) { |
460 | TextCodecInterface *iface = 0; | 460 | TextCodecInterface *iface = 0; |
461 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 461 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
463 | QValueList<int> mibs = iface->mibEnums(); | 463 | QValueList<int> mibs = iface->mibEnums(); |
464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
465 | (void)iface->createForMib(*i); | 465 | (void)iface->createForMib(*i); |
466 | // ### it exists now; need to remember if we can delete it | 466 | // ### it exists now; need to remember if we can delete it |
467 | } | 467 | } |
468 | } | 468 | } |
469 | else { | 469 | else { |
470 | lib->unload(); | 470 | lib->unload(); |
471 | delete lib; | 471 | delete lib; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | void loadImageCodecs() | 476 | void loadImageCodecs() |
477 | { | 477 | { |
478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
479 | #ifdef Q_OS_MACX | 479 | #ifdef Q_OS_MACX |
480 | QDir dir( path, "lib*.dylib" ); | 480 | QDir dir( path, "lib*.dylib" ); |
481 | #else | 481 | #else |
482 | QDir dir( path, "lib*.so" ); | 482 | QDir dir( path, "lib*.so" ); |
483 | #endif | 483 | #endif |
484 | QStringList list; | 484 | QStringList list; |
485 | if ( dir. exists ( )) | 485 | if ( dir. exists ( )) |
486 | list = dir.entryList(); | 486 | list = dir.entryList(); |
487 | QStringList::Iterator it; | 487 | QStringList::Iterator it; |
488 | for ( it = list.begin(); it != list.end(); ++it ) { | 488 | for ( it = list.begin(); it != list.end(); ++it ) { |
489 | ImageCodecInterface *iface = 0; | 489 | ImageCodecInterface *iface = 0; |
490 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 490 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
492 | QStringList formats = iface->keys(); | 492 | QStringList formats = iface->keys(); |
493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
494 | (void)iface->installIOHandler(*i); | 494 | (void)iface->installIOHandler(*i); |
495 | // ### it exists now; need to remember if we can delete it | 495 | // ### it exists now; need to remember if we can delete it |
496 | } | 496 | } |
497 | } | 497 | } |
498 | else { | 498 | else { |
499 | lib->unload(); | 499 | lib->unload(); |
500 | delete lib; | 500 | delete lib; |
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | }; | 505 | }; |
506 | 506 | ||
507 | class ResourceMimeFactory : public QMimeSourceFactory | 507 | class ResourceMimeFactory : public QMimeSourceFactory |
508 | { | 508 | { |
509 | public: | 509 | public: |
510 | ResourceMimeFactory() : resImage( 0 ) | 510 | ResourceMimeFactory() : resImage( 0 ) |
511 | { | 511 | { |
512 | setFilePath( Global::helpPath() ); | 512 | setFilePath( Global::helpPath() ); |
513 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 513 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
514 | } | 514 | } |
515 | ~ResourceMimeFactory() { | 515 | ~ResourceMimeFactory() { |
516 | delete resImage; | 516 | delete resImage; |
517 | } | 517 | } |
518 | 518 | ||
519 | const QMimeSource* data( const QString& abs_name ) const | 519 | const QMimeSource* data( const QString& abs_name ) const |
520 | { | 520 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 522 | if ( !r ) { |
523 | int sl = abs_name.length(); | 523 | int sl = abs_name.length(); |
524 | do { | 524 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 525 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 527 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 528 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 529 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 530 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 531 | if ( !img.isNull() ) { |
532 | delete resImage; | 532 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 533 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 534 | r = resImage; |
535 | } | 535 | } |
536 | } | 536 | } |
537 | while ( !r && sl > 0 ); | 537 | while ( !r && sl > 0 ); |
538 | } | 538 | } |
539 | return r; | 539 | return r; |
540 | } | 540 | } |
541 | private: | 541 | private: |
542 | mutable QImageDrag *resImage; | 542 | mutable QImageDrag *resImage; |
543 | }; | 543 | }; |
544 | 544 | ||
545 | static int& hack(int& i) | 545 | static int& hack(int& i) |
546 | { | 546 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 548 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 549 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 550 | (void)new QUtf16Codec; |
551 | #endif | 551 | #endif |
552 | return i; | 552 | return i; |
553 | } | 553 | } |
554 | 554 | ||
555 | static int muted = 0; | 555 | static int muted = 0; |
556 | static int micMuted = 0; | 556 | static int micMuted = 0; |
557 | 557 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 558 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 559 | { |
560 | switch ( t ) { | 560 | switch ( t ) { |
561 | case 0: { | 561 | case 0: { |
562 | Config cfg( "qpe" ); | 562 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 563 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 564 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 566 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 567 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | ||
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
570 | #else | ||
568 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | ||
569 | int vol = muted ? 0 : percent; | 573 | int vol = muted ? 0 : percent; |
570 | // set both channels to same volume | 574 | // set both channels to same volume |
571 | vol |= vol << 8; | 575 | vol |= vol << 8; |
572 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
573 | ::close( fd ); | 577 | ::close( fd ); |
574 | } | 578 | } |
575 | #endif | 579 | #endif |
576 | } | 580 | } |
577 | break; | 581 | break; |
578 | } | 582 | } |
579 | } | 583 | } |
580 | 584 | ||
581 | static void setMic( int t = 0, int percent = -1 ) | 585 | static void setMic( int t = 0, int percent = -1 ) |
582 | { | 586 | { |
583 | switch ( t ) { | 587 | switch ( t ) { |
584 | case 0: { | 588 | case 0: { |
585 | Config cfg( "qpe" ); | 589 | Config cfg( "qpe" ); |
586 | cfg.setGroup( "Volume" ); | 590 | cfg.setGroup( "Volume" ); |
587 | if ( percent < 0 ) | 591 | if ( percent < 0 ) |
588 | percent = cfg.readNumEntry( "Mic", 50 ); | 592 | percent = cfg.readNumEntry( "Mic", 50 ); |
589 | 593 | ||
590 | #ifndef QT_NO_SOUND | 594 | #ifndef QT_NO_SOUND |
591 | int fd = 0; | 595 | int fd = 0; |
592 | int mic = micMuted ? 0 : percent; | 596 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | ||
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
599 | #else | ||
593 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | ||
594 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
595 | ::close( fd ); | 603 | ::close( fd ); |
596 | } | 604 | } |
597 | #endif | 605 | #endif |
598 | } | 606 | } |
599 | break; | 607 | break; |
600 | } | 608 | } |
601 | } | 609 | } |
602 | 610 | ||
603 | 611 | ||
604 | static void setBass( int t = 0, int percent = -1 ) | 612 | static void setBass( int t = 0, int percent = -1 ) |
605 | { | 613 | { |
606 | switch ( t ) { | 614 | switch ( t ) { |
607 | case 0: { | 615 | case 0: { |
608 | Config cfg( "qpe" ); | 616 | Config cfg( "qpe" ); |
609 | cfg.setGroup( "Volume" ); | 617 | cfg.setGroup( "Volume" ); |
610 | if ( percent < 0 ) | 618 | if ( percent < 0 ) |
611 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 619 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
612 | 620 | ||
613 | #ifndef QT_NO_SOUND | 621 | #ifndef QT_NO_SOUND |
614 | int fd = 0; | 622 | int fd = 0; |
615 | int bass = percent; | 623 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | ||
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
626 | #else | ||
616 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | ||
617 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
618 | ::close( fd ); | 630 | ::close( fd ); |
619 | } | 631 | } |
620 | #endif | 632 | #endif |
621 | } | 633 | } |
622 | break; | 634 | break; |
623 | } | 635 | } |
624 | } | 636 | } |
625 | 637 | ||
626 | 638 | ||
627 | static void setTreble( int t = 0, int percent = -1 ) | 639 | static void setTreble( int t = 0, int percent = -1 ) |
628 | { | 640 | { |
629 | switch ( t ) { | 641 | switch ( t ) { |
630 | case 0: { | 642 | case 0: { |
631 | Config cfg( "qpe" ); | 643 | Config cfg( "qpe" ); |
632 | cfg.setGroup( "Volume" ); | 644 | cfg.setGroup( "Volume" ); |
633 | if ( percent < 0 ) | 645 | if ( percent < 0 ) |
634 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
635 | 647 | ||
636 | #ifndef QT_NO_SOUND | 648 | #ifndef QT_NO_SOUND |
637 | int fd = 0; | 649 | int fd = 0; |
638 | int treble = percent; | 650 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | ||
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
653 | #else | ||
639 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | ||
640 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
641 | ::close( fd ); | 657 | ::close( fd ); |
642 | } | 658 | } |
643 | #endif | 659 | #endif |
644 | } | 660 | } |
645 | break; | 661 | break; |
646 | } | 662 | } |
647 | } | 663 | } |
648 | 664 | ||
649 | 665 | ||
650 | /** | 666 | /** |
651 | \class QPEApplication | 667 | \class QPEApplication |
652 | \brief The QPEApplication class implements various system services | 668 | \brief The QPEApplication class implements various system services |
653 | that are available to all Qtopia applications. | 669 | that are available to all Qtopia applications. |
654 | 670 | ||
655 | Simply by using QPEApplication instead of QApplication, a standard Qt | 671 | Simply by using QPEApplication instead of QApplication, a standard Qt |
656 | application becomes a Qtopia application. It automatically follows | 672 | application becomes a Qtopia application. It automatically follows |
657 | style changes, quits and raises, and in the | 673 | style changes, quits and raises, and in the |
658 | case of \link docwidget.html document-oriented\endlink applications, | 674 | case of \link docwidget.html document-oriented\endlink applications, |
659 | changes the currently displayed document in response to the environment. | 675 | changes the currently displayed document in response to the environment. |
660 | 676 | ||
661 | To create a \link docwidget.html document-oriented\endlink | 677 | To create a \link docwidget.html document-oriented\endlink |
662 | application use showMainDocumentWidget(); to create a | 678 | application use showMainDocumentWidget(); to create a |
663 | non-document-oriented application use showMainWidget(). The | 679 | non-document-oriented application use showMainWidget(). The |
664 | keepRunning() function indicates whether the application will | 680 | keepRunning() function indicates whether the application will |
665 | continue running after it's processed the last \link qcop.html | 681 | continue running after it's processed the last \link qcop.html |
666 | QCop\endlink message. This can be changed using setKeepRunning(). | 682 | QCop\endlink message. This can be changed using setKeepRunning(). |
667 | 683 | ||
668 | A variety of signals are emitted when certain events occur, for | 684 | A variety of signals are emitted when certain events occur, for |
669 | example, timeChanged(), clockChanged(), weekChanged(), | 685 | example, timeChanged(), clockChanged(), weekChanged(), |
670 | dateFormatChanged() and volumeChanged(). If the application receives | 686 | dateFormatChanged() and volumeChanged(). If the application receives |
671 | a \link qcop.html QCop\endlink message on the application's | 687 | a \link qcop.html QCop\endlink message on the application's |
672 | QPE/Application/\e{appname} channel, the appMessage() signal is | 688 | QPE/Application/\e{appname} channel, the appMessage() signal is |
673 | emitted. There are also flush() and reload() signals, which | 689 | emitted. There are also flush() and reload() signals, which |
674 | are emitted when synching begins and ends respectively - upon these | 690 | are emitted when synching begins and ends respectively - upon these |
675 | signals, the application should save and reload any data | 691 | signals, the application should save and reload any data |
676 | files that are involved in synching. Most of these signals will initially | 692 | files that are involved in synching. Most of these signals will initially |
677 | be received and unfiltered through the appMessage() signal. | 693 | be received and unfiltered through the appMessage() signal. |
678 | 694 | ||
679 | This class also provides a set of useful static functions. The | 695 | This class also provides a set of useful static functions. The |
680 | qpeDir() and documentDir() functions return the respective paths. | 696 | qpeDir() and documentDir() functions return the respective paths. |
681 | The grabKeyboard() and ungrabKeyboard() functions are used to | 697 | The grabKeyboard() and ungrabKeyboard() functions are used to |
682 | control whether the application takes control of the device's | 698 | control whether the application takes control of the device's |
683 | physical buttons (e.g. application launch keys). The stylus' mode of | 699 | physical buttons (e.g. application launch keys). The stylus' mode of |
684 | operation is set with setStylusOperation() and retrieved with | 700 | operation is set with setStylusOperation() and retrieved with |
685 | stylusOperation(). There are also setInputMethodHint() and | 701 | stylusOperation(). There are also setInputMethodHint() and |
686 | inputMethodHint() functions. | 702 | inputMethodHint() functions. |
687 | 703 | ||
688 | \ingroup qtopiaemb | 704 | \ingroup qtopiaemb |
689 | */ | 705 | */ |
690 | 706 | ||
691 | /*! | 707 | /*! |
692 | \fn void QPEApplication::clientMoused() | 708 | \fn void QPEApplication::clientMoused() |
693 | 709 | ||
694 | \internal | 710 | \internal |
695 | */ | 711 | */ |
696 | 712 | ||
697 | /*! | 713 | /*! |
698 | \fn void QPEApplication::timeChanged(); | 714 | \fn void QPEApplication::timeChanged(); |
699 | This signal is emitted when the time changes outside the normal | 715 | This signal is emitted when the time changes outside the normal |
700 | passage of time, i.e. if the time is set backwards or forwards. | 716 | passage of time, i.e. if the time is set backwards or forwards. |
701 | */ | 717 | */ |
702 | 718 | ||
703 | /*! | 719 | /*! |
704 | \fn void QPEApplication::clockChanged( bool ampm ); | 720 | \fn void QPEApplication::clockChanged( bool ampm ); |
705 | 721 | ||
706 | This signal is emitted when the user changes the clock's style. If | 722 | This signal is emitted when the user changes the clock's style. If |
707 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 723 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
708 | they want a 24-hour clock. | 724 | they want a 24-hour clock. |
709 | */ | 725 | */ |
710 | 726 | ||
711 | /*! | 727 | /*! |
712 | \fn void QPEApplication::volumeChanged( bool muted ) | 728 | \fn void QPEApplication::volumeChanged( bool muted ) |
713 | 729 | ||
714 | This signal is emitted whenever the mute state is changed. If \a | 730 | This signal is emitted whenever the mute state is changed. If \a |
715 | muted is TRUE, then sound output has been muted. | 731 | muted is TRUE, then sound output has been muted. |
716 | */ | 732 | */ |
717 | 733 | ||
718 | /*! | 734 | /*! |
719 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 735 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
720 | 736 | ||
721 | This signal is emitted if the week start day is changed. If \a | 737 | This signal is emitted if the week start day is changed. If \a |
722 | startOnMonday is TRUE then the first day of the week is Monday; if | 738 | startOnMonday is TRUE then the first day of the week is Monday; if |
723 | \a startOnMonday is FALSE then the first day of the week is | 739 | \a startOnMonday is FALSE then the first day of the week is |
724 | Sunday. | 740 | Sunday. |
725 | */ | 741 | */ |
726 | 742 | ||
727 | /*! | 743 | /*! |
728 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 744 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
729 | 745 | ||
730 | This signal is emitted whenever the date format is changed. | 746 | This signal is emitted whenever the date format is changed. |
731 | */ | 747 | */ |
732 | 748 | ||
733 | /*! | 749 | /*! |
734 | \fn void QPEApplication::flush() | 750 | \fn void QPEApplication::flush() |
735 | 751 | ||
736 | ### | 752 | ### |
737 | */ | 753 | */ |
738 | 754 | ||
739 | /*! | 755 | /*! |
740 | \fn void QPEApplication::reload() | 756 | \fn void QPEApplication::reload() |
741 | 757 | ||
742 | */ | 758 | */ |
743 | 759 | ||
744 | 760 | ||
745 | 761 | ||
746 | void QPEApplication::processQCopFile() | 762 | void QPEApplication::processQCopFile() |
747 | { | 763 | { |
748 | QString qcopfn("/tmp/qcop-msg-"); | 764 | QString qcopfn("/tmp/qcop-msg-"); |
749 | qcopfn += d->appName; // append command name | 765 | qcopfn += d->appName; // append command name |
750 | 766 | ||
751 | QFile f(qcopfn); | 767 | QFile f(qcopfn); |
752 | if ( f.open(IO_ReadWrite) ) { | 768 | if ( f.open(IO_ReadWrite) ) { |
753 | #ifndef Q_OS_WIN32 | 769 | #ifndef Q_OS_WIN32 |
754 | flock(f.handle(), LOCK_EX); | 770 | flock(f.handle(), LOCK_EX); |
755 | #endif | 771 | #endif |
756 | QDataStream ds(&f); | 772 | QDataStream ds(&f); |
757 | QCString channel, message; | 773 | QCString channel, message; |
758 | QByteArray data; | 774 | QByteArray data; |
759 | while(!ds.atEnd()) { | 775 | while(!ds.atEnd()) { |
760 | ds >> channel >> message >> data; | 776 | ds >> channel >> message >> data; |
761 | d->enqueueQCop(channel,message,data); | 777 | d->enqueueQCop(channel,message,data); |
762 | } | 778 | } |
763 | ::ftruncate(f.handle(), 0); | 779 | ::ftruncate(f.handle(), 0); |
764 | #ifndef Q_OS_WIN32 | 780 | #ifndef Q_OS_WIN32 |
765 | f.flush(); | 781 | f.flush(); |
766 | flock(f.handle(), LOCK_UN); | 782 | flock(f.handle(), LOCK_UN); |
767 | #endif | 783 | #endif |
768 | } | 784 | } |
769 | #endif | 785 | #endif |
770 | } | 786 | } |
771 | 787 | ||
772 | 788 | ||
773 | /*! | 789 | /*! |
774 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 790 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
775 | 791 | ||
776 | This signal is emitted when a message is received on this | 792 | This signal is emitted when a message is received on this |
777 | application's QPE/Application/<i>appname</i> \link qcop.html | 793 | application's QPE/Application/<i>appname</i> \link qcop.html |
778 | QCop\endlink channel. | 794 | QCop\endlink channel. |
779 | 795 | ||
780 | The slot to which you connect this signal uses \a msg and \a data | 796 | The slot to which you connect this signal uses \a msg and \a data |
781 | in the following way: | 797 | in the following way: |
782 | 798 | ||
783 | \code | 799 | \code |
784 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 800 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
785 | { | 801 | { |
786 | QDataStream stream( data, IO_ReadOnly ); | 802 | QDataStream stream( data, IO_ReadOnly ); |
787 | if ( msg == "someMessage(int,int,int)" ) { | 803 | if ( msg == "someMessage(int,int,int)" ) { |
788 | int a,b,c; | 804 | int a,b,c; |
789 | stream >> a >> b >> c; | 805 | stream >> a >> b >> c; |
790 | ... | 806 | ... |
791 | } else if ( msg == "otherMessage(QString)" ) { | 807 | } else if ( msg == "otherMessage(QString)" ) { |
792 | ... | 808 | ... |
793 | } | 809 | } |
794 | } | 810 | } |
795 | \endcode | 811 | \endcode |
796 | 812 | ||
797 | \sa qcop.html | 813 | \sa qcop.html |
798 | Note that messages received here may be processed by qpe application | 814 | Note that messages received here may be processed by qpe application |
799 | and emitted as signals, such as flush() and reload(). | 815 | and emitted as signals, such as flush() and reload(). |
800 | */ | 816 | */ |
801 | 817 | ||
802 | /*! | 818 | /*! |
803 | Constructs a QPEApplication just as you would construct | 819 | Constructs a QPEApplication just as you would construct |
804 | a QApplication, passing \a argc, \a argv, and \a t. | 820 | a QApplication, passing \a argc, \a argv, and \a t. |
805 | 821 | ||
806 | For applications, \a t should be the default, GuiClient. Only | 822 | For applications, \a t should be the default, GuiClient. Only |
807 | the Qtopia server passes GuiServer. | 823 | the Qtopia server passes GuiServer. |
808 | */ | 824 | */ |
809 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 825 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
810 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 826 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
811 | { | 827 | { |
812 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 828 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
813 | 829 | ||
814 | d = new QPEApplicationData; | 830 | d = new QPEApplicationData; |
815 | d->loadTextCodecs(); | 831 | d->loadTextCodecs(); |
816 | d->loadImageCodecs(); | 832 | d->loadImageCodecs(); |
817 | 833 | ||
818 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 834 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
819 | AppLnk::setSmallIconSize( d->smallIconSize ); | 835 | AppLnk::setSmallIconSize( d->smallIconSize ); |
820 | AppLnk::setBigIconSize( d->bigIconSize ); | 836 | AppLnk::setBigIconSize( d->bigIconSize ); |
821 | 837 | ||
822 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 838 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
823 | 839 | ||
824 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 840 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
825 | 841 | ||
826 | 842 | ||
827 | sysChannel = new QCopChannel( "QPE/System", this ); | 843 | sysChannel = new QCopChannel( "QPE/System", this ); |
828 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 844 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
829 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 845 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
830 | 846 | ||
831 | /* COde now in initapp */ | 847 | /* COde now in initapp */ |