author | llornkcor <llornkcor> | 2004-10-21 09:16:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-10-21 09:16:20 (UTC) |
commit | 84b7a20c67226aa4305ad0cb7c05e2507ca0cc0e (patch) (unidiff) | |
tree | f826a49b2875e416b02dec228280c4958f25ac8b | |
parent | 8232b072180742d87a8e543b6968e9c4109c0612 (diff) | |
download | opie-84b7a20c67226aa4305ad0cb7c05e2507ca0cc0e.zip opie-84b7a20c67226aa4305ad0cb7c05e2507ca0cc0e.tar.gz opie-84b7a20c67226aa4305ad0cb7c05e2507ca0cc0e.tar.bz2 |
turn off qDebug and qWarning in release mode. This should also quiet any 3rd party applications outside opie control
-rw-r--r-- | library/qpeapplication.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 1117240..4adfc8f 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -527,523 +527,546 @@ static void setVolume( int t = 0, int percent = -1 ) | |||
527 | static void setMic( int t = 0, int percent = -1 ) | 527 | static void setMic( int t = 0, int percent = -1 ) |
528 | { | 528 | { |
529 | switch ( t ) { | 529 | switch ( t ) { |
530 | case 0: { | 530 | case 0: { |
531 | Config cfg( "qpe" ); | 531 | Config cfg( "qpe" ); |
532 | cfg.setGroup( "Volume" ); | 532 | cfg.setGroup( "Volume" ); |
533 | if ( percent < 0 ) | 533 | if ( percent < 0 ) |
534 | percent = cfg.readNumEntry( "Mic", 50 ); | 534 | percent = cfg.readNumEntry( "Mic", 50 ); |
535 | 535 | ||
536 | #ifndef QT_NO_SOUND | 536 | #ifndef QT_NO_SOUND |
537 | int fd = 0; | 537 | int fd = 0; |
538 | int mic = micMuted ? 0 : percent; | 538 | int mic = micMuted ? 0 : percent; |
539 | #ifdef QT_QWS_DEVFS | 539 | #ifdef QT_QWS_DEVFS |
540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
541 | #else | 541 | #else |
542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
543 | #endif | 543 | #endif |
544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
545 | ::close( fd ); | 545 | ::close( fd ); |
546 | } | 546 | } |
547 | #endif | 547 | #endif |
548 | } | 548 | } |
549 | break; | 549 | break; |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | static void setBass( int t = 0, int percent = -1 ) | 554 | static void setBass( int t = 0, int percent = -1 ) |
555 | { | 555 | { |
556 | switch ( t ) { | 556 | switch ( t ) { |
557 | case 0: { | 557 | case 0: { |
558 | Config cfg( "qpe" ); | 558 | Config cfg( "qpe" ); |
559 | cfg.setGroup( "Volume" ); | 559 | cfg.setGroup( "Volume" ); |
560 | if ( percent < 0 ) | 560 | if ( percent < 0 ) |
561 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 561 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
562 | 562 | ||
563 | #ifndef QT_NO_SOUND | 563 | #ifndef QT_NO_SOUND |
564 | int fd = 0; | 564 | int fd = 0; |
565 | int bass = percent; | 565 | int bass = percent; |
566 | #ifdef QT_QWS_DEVFS | 566 | #ifdef QT_QWS_DEVFS |
567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
568 | #else | 568 | #else |
569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
570 | #endif | 570 | #endif |
571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
572 | ::close( fd ); | 572 | ::close( fd ); |
573 | } | 573 | } |
574 | #endif | 574 | #endif |
575 | } | 575 | } |
576 | break; | 576 | break; |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | 580 | ||
581 | static void setTreble( int t = 0, int percent = -1 ) | 581 | static void setTreble( int t = 0, int percent = -1 ) |
582 | { | 582 | { |
583 | switch ( t ) { | 583 | switch ( t ) { |
584 | case 0: { | 584 | case 0: { |
585 | Config cfg( "qpe" ); | 585 | Config cfg( "qpe" ); |
586 | cfg.setGroup( "Volume" ); | 586 | cfg.setGroup( "Volume" ); |
587 | if ( percent < 0 ) | 587 | if ( percent < 0 ) |
588 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 588 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
589 | 589 | ||
590 | #ifndef QT_NO_SOUND | 590 | #ifndef QT_NO_SOUND |
591 | int fd = 0; | 591 | int fd = 0; |
592 | int treble = percent; | 592 | int treble = percent; |
593 | #ifdef QT_QWS_DEVFS | 593 | #ifdef QT_QWS_DEVFS |
594 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 594 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
595 | #else | 595 | #else |
596 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 596 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
597 | #endif | 597 | #endif |
598 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 598 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
599 | ::close( fd ); | 599 | ::close( fd ); |
600 | } | 600 | } |
601 | #endif | 601 | #endif |
602 | } | 602 | } |
603 | break; | 603 | break; |
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
608 | /** | 608 | /** |
609 | \class QPEApplication | 609 | \class QPEApplication |
610 | \brief The QPEApplication class implements various system services | 610 | \brief The QPEApplication class implements various system services |
611 | that are available to all Qtopia applications. | 611 | that are available to all Qtopia applications. |
612 | 612 | ||
613 | Simply by using QPEApplication instead of QApplication, a standard Qt | 613 | Simply by using QPEApplication instead of QApplication, a standard Qt |
614 | application becomes a Qtopia application. It automatically follows | 614 | application becomes a Qtopia application. It automatically follows |
615 | style changes, quits and raises, and in the | 615 | style changes, quits and raises, and in the |
616 | case of \link docwidget.html document-oriented\endlink applications, | 616 | case of \link docwidget.html document-oriented\endlink applications, |
617 | changes the currently displayed document in response to the environment. | 617 | changes the currently displayed document in response to the environment. |
618 | 618 | ||
619 | To create a \link docwidget.html document-oriented\endlink | 619 | To create a \link docwidget.html document-oriented\endlink |
620 | application use showMainDocumentWidget(); to create a | 620 | application use showMainDocumentWidget(); to create a |
621 | non-document-oriented application use showMainWidget(). The | 621 | non-document-oriented application use showMainWidget(). The |
622 | keepRunning() function indicates whether the application will | 622 | keepRunning() function indicates whether the application will |
623 | continue running after it's processed the last \link qcop.html | 623 | continue running after it's processed the last \link qcop.html |
624 | QCop\endlink message. This can be changed using setKeepRunning(). | 624 | QCop\endlink message. This can be changed using setKeepRunning(). |
625 | 625 | ||
626 | A variety of signals are emitted when certain events occur, for | 626 | A variety of signals are emitted when certain events occur, for |
627 | example, timeChanged(), clockChanged(), weekChanged(), | 627 | example, timeChanged(), clockChanged(), weekChanged(), |
628 | dateFormatChanged() and volumeChanged(). If the application receives | 628 | dateFormatChanged() and volumeChanged(). If the application receives |
629 | a \link qcop.html QCop\endlink message on the application's | 629 | a \link qcop.html QCop\endlink message on the application's |
630 | QPE/Application/\e{appname} channel, the appMessage() signal is | 630 | QPE/Application/\e{appname} channel, the appMessage() signal is |
631 | emitted. There are also flush() and reload() signals, which | 631 | emitted. There are also flush() and reload() signals, which |
632 | are emitted when synching begins and ends respectively - upon these | 632 | are emitted when synching begins and ends respectively - upon these |
633 | signals, the application should save and reload any data | 633 | signals, the application should save and reload any data |
634 | files that are involved in synching. Most of these signals will initially | 634 | files that are involved in synching. Most of these signals will initially |
635 | be received and unfiltered through the appMessage() signal. | 635 | be received and unfiltered through the appMessage() signal. |
636 | 636 | ||
637 | This class also provides a set of useful static functions. The | 637 | This class also provides a set of useful static functions. The |
638 | qpeDir() and documentDir() functions return the respective paths. | 638 | qpeDir() and documentDir() functions return the respective paths. |
639 | The grabKeyboard() and ungrabKeyboard() functions are used to | 639 | The grabKeyboard() and ungrabKeyboard() functions are used to |
640 | control whether the application takes control of the device's | 640 | control whether the application takes control of the device's |
641 | physical buttons (e.g. application launch keys). The stylus' mode of | 641 | physical buttons (e.g. application launch keys). The stylus' mode of |
642 | operation is set with setStylusOperation() and retrieved with | 642 | operation is set with setStylusOperation() and retrieved with |
643 | stylusOperation(). There are also setInputMethodHint() and | 643 | stylusOperation(). There are also setInputMethodHint() and |
644 | inputMethodHint() functions. | 644 | inputMethodHint() functions. |
645 | 645 | ||
646 | \ingroup qtopiaemb | 646 | \ingroup qtopiaemb |
647 | */ | 647 | */ |
648 | 648 | ||
649 | /*! | 649 | /*! |
650 | \fn void QPEApplication::clientMoused() | 650 | \fn void QPEApplication::clientMoused() |
651 | 651 | ||
652 | \internal | 652 | \internal |
653 | */ | 653 | */ |
654 | 654 | ||
655 | /*! | 655 | /*! |
656 | \fn void QPEApplication::timeChanged(); | 656 | \fn void QPEApplication::timeChanged(); |
657 | This signal is emitted when the time changes outside the normal | 657 | This signal is emitted when the time changes outside the normal |
658 | passage of time, i.e. if the time is set backwards or forwards. | 658 | passage of time, i.e. if the time is set backwards or forwards. |
659 | */ | 659 | */ |
660 | 660 | ||
661 | /*! | 661 | /*! |
662 | \fn void QPEApplication::clockChanged( bool ampm ); | 662 | \fn void QPEApplication::clockChanged( bool ampm ); |
663 | 663 | ||
664 | This signal is emitted when the user changes the clock's style. If | 664 | This signal is emitted when the user changes the clock's style. If |
665 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 665 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
666 | they want a 24-hour clock. | 666 | they want a 24-hour clock. |
667 | */ | 667 | */ |
668 | 668 | ||
669 | /*! | 669 | /*! |
670 | \fn void QPEApplication::volumeChanged( bool muted ) | 670 | \fn void QPEApplication::volumeChanged( bool muted ) |
671 | 671 | ||
672 | This signal is emitted whenever the mute state is changed. If \a | 672 | This signal is emitted whenever the mute state is changed. If \a |
673 | muted is TRUE, then sound output has been muted. | 673 | muted is TRUE, then sound output has been muted. |
674 | */ | 674 | */ |
675 | 675 | ||
676 | /*! | 676 | /*! |
677 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 677 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
678 | 678 | ||
679 | This signal is emitted if the week start day is changed. If \a | 679 | This signal is emitted if the week start day is changed. If \a |
680 | startOnMonday is TRUE then the first day of the week is Monday; if | 680 | startOnMonday is TRUE then the first day of the week is Monday; if |
681 | \a startOnMonday is FALSE then the first day of the week is | 681 | \a startOnMonday is FALSE then the first day of the week is |
682 | Sunday. | 682 | Sunday. |
683 | */ | 683 | */ |
684 | 684 | ||
685 | /*! | 685 | /*! |
686 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 686 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
687 | 687 | ||
688 | This signal is emitted whenever the date format is changed. | 688 | This signal is emitted whenever the date format is changed. |
689 | */ | 689 | */ |
690 | 690 | ||
691 | /*! | 691 | /*! |
692 | \fn void QPEApplication::flush() | 692 | \fn void QPEApplication::flush() |
693 | 693 | ||
694 | ### | 694 | ### |
695 | */ | 695 | */ |
696 | 696 | ||
697 | /*! | 697 | /*! |
698 | \fn void QPEApplication::reload() | 698 | \fn void QPEApplication::reload() |
699 | 699 | ||
700 | */ | 700 | */ |
701 | 701 | ||
702 | 702 | ||
703 | 703 | ||
704 | void QPEApplication::processQCopFile() | 704 | void QPEApplication::processQCopFile() |
705 | { | 705 | { |
706 | QString qcopfn("/tmp/qcop-msg-"); | 706 | QString qcopfn("/tmp/qcop-msg-"); |
707 | qcopfn += d->appName; // append command name | 707 | qcopfn += d->appName; // append command name |
708 | 708 | ||
709 | QFile f(qcopfn); | 709 | QFile f(qcopfn); |
710 | if ( f.open(IO_ReadWrite) ) { | 710 | if ( f.open(IO_ReadWrite) ) { |
711 | #ifndef Q_OS_WIN32 | 711 | #ifndef Q_OS_WIN32 |
712 | flock(f.handle(), LOCK_EX); | 712 | flock(f.handle(), LOCK_EX); |
713 | #endif | 713 | #endif |
714 | QDataStream ds(&f); | 714 | QDataStream ds(&f); |
715 | QCString channel, message; | 715 | QCString channel, message; |
716 | QByteArray data; | 716 | QByteArray data; |
717 | while(!ds.atEnd()) { | 717 | while(!ds.atEnd()) { |
718 | ds >> channel >> message >> data; | 718 | ds >> channel >> message >> data; |
719 | d->enqueueQCop(channel,message,data); | 719 | d->enqueueQCop(channel,message,data); |
720 | } | 720 | } |
721 | ::ftruncate(f.handle(), 0); | 721 | ::ftruncate(f.handle(), 0); |
722 | #ifndef Q_OS_WIN32 | 722 | #ifndef Q_OS_WIN32 |
723 | f.flush(); | 723 | f.flush(); |
724 | flock(f.handle(), LOCK_UN); | 724 | flock(f.handle(), LOCK_UN); |
725 | #endif | 725 | #endif |
726 | } | 726 | } |
727 | #endif | 727 | #endif |
728 | } | 728 | } |
729 | 729 | ||
730 | 730 | ||
731 | /*! | 731 | /*! |
732 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 732 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
733 | 733 | ||
734 | This signal is emitted when a message is received on this | 734 | This signal is emitted when a message is received on this |
735 | application's QPE/Application/<i>appname</i> \link qcop.html | 735 | application's QPE/Application/<i>appname</i> \link qcop.html |
736 | QCop\endlink channel. | 736 | QCop\endlink channel. |
737 | 737 | ||
738 | The slot to which you connect this signal uses \a msg and \a data | 738 | The slot to which you connect this signal uses \a msg and \a data |
739 | in the following way: | 739 | in the following way: |
740 | 740 | ||
741 | \code | 741 | \code |
742 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 742 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
743 | { | 743 | { |
744 | QDataStream stream( data, IO_ReadOnly ); | 744 | QDataStream stream( data, IO_ReadOnly ); |
745 | if ( msg == "someMessage(int,int,int)" ) { | 745 | if ( msg == "someMessage(int,int,int)" ) { |
746 | int a,b,c; | 746 | int a,b,c; |
747 | stream >> a >> b >> c; | 747 | stream >> a >> b >> c; |
748 | ... | 748 | ... |
749 | } else if ( msg == "otherMessage(QString)" ) { | 749 | } else if ( msg == "otherMessage(QString)" ) { |
750 | ... | 750 | ... |
751 | } | 751 | } |
752 | } | 752 | } |
753 | \endcode | 753 | \endcode |
754 | 754 | ||
755 | \sa qcop.html | 755 | \sa qcop.html |
756 | Note that messages received here may be processed by qpe application | 756 | Note that messages received here may be processed by qpe application |
757 | and emitted as signals, such as flush() and reload(). | 757 | and emitted as signals, such as flush() and reload(). |
758 | */ | 758 | */ |
759 | 759 | ||
760 | #ifndef QT_NO_TRANSLATION | 760 | #ifndef QT_NO_TRANSLATION |
761 | static void qtopia_loadTranslations( const QStringList& qms ) | 761 | static void qtopia_loadTranslations( const QStringList& qms ) |
762 | { | 762 | { |
763 | QStringList langs = Global::languageList(); | 763 | QStringList langs = Global::languageList(); |
764 | 764 | ||
765 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 765 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
766 | QString lang = *it; | 766 | QString lang = *it; |
767 | 767 | ||
768 | QTranslator * trans; | 768 | QTranslator * trans; |
769 | QString tfn; | 769 | QString tfn; |
770 | 770 | ||
771 | for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { | 771 | for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { |
772 | trans = new QTranslator(qApp); | 772 | trans = new QTranslator(qApp); |
773 | tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; | 773 | tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; |
774 | if ( trans->load( tfn )) | 774 | if ( trans->load( tfn )) |
775 | qApp->installTranslator( trans ); | 775 | qApp->installTranslator( trans ); |
776 | else | 776 | else |
777 | delete trans; | 777 | delete trans; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | } | 780 | } |
781 | #endif | 781 | #endif |
782 | 782 | ||
783 | /* | ||
784 | Turn off qDebug in release mode | ||
785 | */ | ||
786 | static void qtopiaMsgHandler(QtMsgType type, const char* msg) | ||
787 | { | ||
788 | switch ( type ) { | ||
789 | case QtDebugMsg: | ||
790 | #ifdef QT_DEBUG | ||
791 | fprintf( stderr, "Debug: %s\n", msg ); | ||
792 | #endif | ||
793 | break; | ||
794 | case QtWarningMsg: | ||
795 | #ifdef QT_DEBUG | ||
796 | fprintf( stderr, "Warning: %s\n", msg ); | ||
797 | #endif | ||
798 | break; | ||
799 | case QtFatalMsg: | ||
800 | fprintf( stderr, "Fatal: %s\n", msg ); | ||
801 | abort(); | ||
802 | } | ||
803 | } | ||
804 | |||
783 | /*! | 805 | /*! |
784 | Constructs a QPEApplication just as you would construct | 806 | Constructs a QPEApplication just as you would construct |
785 | a QApplication, passing \a argc, \a argv, and \a t. | 807 | a QApplication, passing \a argc, \a argv, and \a t. |
786 | 808 | ||
787 | For applications, \a t should be the default, GuiClient. Only | 809 | For applications, \a t should be the default, GuiClient. Only |
788 | the Qtopia server passes GuiServer. | 810 | the Qtopia server passes GuiServer. |
789 | */ | 811 | */ |
790 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 812 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
791 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 813 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
792 | { | 814 | { |
793 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 815 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
816 | qInstallMsgHandler(qtopiaMsgHandler); | ||
794 | 817 | ||
795 | d = new QPEApplicationData; | 818 | d = new QPEApplicationData; |
796 | d->loadTextCodecs(); | 819 | d->loadTextCodecs(); |
797 | d->loadImageCodecs(); | 820 | d->loadImageCodecs(); |
798 | 821 | ||
799 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 822 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
800 | AppLnk::setSmallIconSize( d->smallIconSize ); | 823 | AppLnk::setSmallIconSize( d->smallIconSize ); |
801 | AppLnk::setBigIconSize( d->bigIconSize ); | 824 | AppLnk::setBigIconSize( d->bigIconSize ); |
802 | 825 | ||
803 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 826 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
804 | 827 | ||
805 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 828 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
806 | 829 | ||
807 | 830 | ||
808 | sysChannel = new QCopChannel( "QPE/System", this ); | 831 | sysChannel = new QCopChannel( "QPE/System", this ); |
809 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 832 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
810 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 833 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
811 | 834 | ||
812 | /* COde now in initapp */ | 835 | /* COde now in initapp */ |
813 | #if 0 | 836 | #if 0 |
814 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 837 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
815 | 838 | ||
816 | QString qcopfn( "/tmp/qcop-msg-" ); | 839 | QString qcopfn( "/tmp/qcop-msg-" ); |
817 | qcopfn += QString( argv[ 0 ] ); // append command name | 840 | qcopfn += QString( argv[ 0 ] ); // append command name |
818 | 841 | ||
819 | QFile f( qcopfn ); | 842 | QFile f( qcopfn ); |
820 | if ( f.open( IO_ReadOnly ) ) { | 843 | if ( f.open( IO_ReadOnly ) ) { |
821 | flock( f.handle(), LOCK_EX ); | 844 | flock( f.handle(), LOCK_EX ); |
822 | } | 845 | } |
823 | 846 | ||
824 | 847 | ||
825 | 848 | ||
826 | QCString channel = QCString( argv[ 0 ] ); | 849 | QCString channel = QCString( argv[ 0 ] ); |
827 | channel.replace( QRegExp( ".*/" ), "" ); | 850 | channel.replace( QRegExp( ".*/" ), "" ); |
828 | d->appName = channel; | 851 | d->appName = channel; |
829 | channel = "QPE/Application/" + channel; | 852 | channel = "QPE/Application/" + channel; |
830 | pidChannel = new QCopChannel( channel, this ); | 853 | pidChannel = new QCopChannel( channel, this ); |
831 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 854 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
832 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 855 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
833 | 856 | ||
834 | if ( f.isOpen() ) { | 857 | if ( f.isOpen() ) { |
835 | d->keep_running = FALSE; | 858 | d->keep_running = FALSE; |
836 | QDataStream ds( &f ); | 859 | QDataStream ds( &f ); |
837 | QCString channel, message; | 860 | QCString channel, message; |
838 | QByteArray data; | 861 | QByteArray data; |
839 | while ( !ds.atEnd() ) { | 862 | while ( !ds.atEnd() ) { |
840 | ds >> channel >> message >> data; | 863 | ds >> channel >> message >> data; |
841 | d->enqueueQCop( channel, message, data ); | 864 | d->enqueueQCop( channel, message, data ); |
842 | } | 865 | } |
843 | 866 | ||
844 | flock( f.handle(), LOCK_UN ); | 867 | flock( f.handle(), LOCK_UN ); |
845 | f.close(); | 868 | f.close(); |
846 | f.remove(); | 869 | f.remove(); |
847 | } | 870 | } |
848 | 871 | ||
849 | for ( int a = 0; a < argc; a++ ) { | 872 | for ( int a = 0; a < argc; a++ ) { |
850 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 873 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
851 | argv[ a ] = argv[ a + 1 ]; | 874 | argv[ a ] = argv[ a + 1 ]; |
852 | a++; | 875 | a++; |
853 | d->preloaded = TRUE; | 876 | d->preloaded = TRUE; |
854 | argc -= 1; | 877 | argc -= 1; |
855 | } | 878 | } |
856 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 879 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
857 | argv[ a ] = argv[ a + 1 ]; | 880 | argv[ a ] = argv[ a + 1 ]; |
858 | a++; | 881 | a++; |
859 | d->preloaded = TRUE; | 882 | d->preloaded = TRUE; |
860 | d->forceshow = TRUE; | 883 | d->forceshow = TRUE; |
861 | argc -= 1; | 884 | argc -= 1; |
862 | } | 885 | } |
863 | } | 886 | } |
864 | 887 | ||
865 | /* overide stored arguments */ | 888 | /* overide stored arguments */ |
866 | setArgs( argc, argv ); | 889 | setArgs( argc, argv ); |
867 | 890 | ||
868 | #endif | 891 | #endif |
869 | #else | 892 | #else |
870 | initApp( argc, argv ); | 893 | initApp( argc, argv ); |
871 | #endif | 894 | #endif |
872 | #ifdef Q_WS_QWS | 895 | #ifdef Q_WS_QWS |
873 | /* load the font renderer factories */ | 896 | /* load the font renderer factories */ |
874 | FontDatabase::loadRenderers(); | 897 | FontDatabase::loadRenderers(); |
875 | #endif | 898 | #endif |
876 | #ifndef QT_NO_TRANSLATION | 899 | #ifndef QT_NO_TRANSLATION |
877 | QStringList qms; | 900 | QStringList qms; |
878 | qms << "libqpe"; | 901 | qms << "libqpe"; |
879 | qms << "libopie"; | 902 | qms << "libopie"; |
880 | qms << d->appName; | 903 | qms << d->appName; |
881 | 904 | ||
882 | qtopia_loadTranslations(qms); | 905 | qtopia_loadTranslations(qms); |
883 | #endif | 906 | #endif |
884 | 907 | ||
885 | applyStyle(); | 908 | applyStyle(); |
886 | 909 | ||
887 | if ( type() == GuiServer ) { | 910 | if ( type() == GuiServer ) { |
888 | setVolume(); | 911 | setVolume(); |
889 | } | 912 | } |
890 | 913 | ||
891 | installEventFilter( this ); | 914 | installEventFilter( this ); |
892 | 915 | ||
893 | QPEMenuToolFocusManager::initialize(); | 916 | QPEMenuToolFocusManager::initialize(); |
894 | 917 | ||
895 | #ifdef QT_NO_QWS_CURSOR | 918 | #ifdef QT_NO_QWS_CURSOR |
896 | // if we have no cursor, probably don't want tooltips | 919 | // if we have no cursor, probably don't want tooltips |
897 | QToolTip::setEnabled( FALSE ); | 920 | QToolTip::setEnabled( FALSE ); |
898 | #endif | 921 | #endif |
899 | } | 922 | } |
900 | 923 | ||
901 | 924 | ||
902 | #ifdef QTOPIA_INTERNAL_INITAPP | 925 | #ifdef QTOPIA_INTERNAL_INITAPP |
903 | void QPEApplication::initApp( int argc, char **argv ) | 926 | void QPEApplication::initApp( int argc, char **argv ) |
904 | { | 927 | { |
905 | delete pidChannel; | 928 | delete pidChannel; |
906 | d->keep_running = TRUE; | 929 | d->keep_running = TRUE; |
907 | d->preloaded = FALSE; | 930 | d->preloaded = FALSE; |
908 | d->forceshow = FALSE; | 931 | d->forceshow = FALSE; |
909 | 932 | ||
910 | QCString channel = QCString(argv[0]); | 933 | QCString channel = QCString(argv[0]); |
911 | 934 | ||
912 | channel.replace(QRegExp(".*/"),""); | 935 | channel.replace(QRegExp(".*/"),""); |
913 | d->appName = channel; | 936 | d->appName = channel; |
914 | 937 | ||
915 | #ifndef QT_NO_TRANSLATION | 938 | #ifndef QT_NO_TRANSLATION |
916 | qtopia_loadTranslations( QStringList()<<channel ); | 939 | qtopia_loadTranslations( QStringList()<<channel ); |
917 | #endif | 940 | #endif |
918 | 941 | ||
919 | #if QT_VERSION > 235 | 942 | #if QT_VERSION > 235 |
920 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 943 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
921 | #endif | 944 | #endif |
922 | 945 | ||
923 | channel = "QPE/Application/" + channel; | 946 | channel = "QPE/Application/" + channel; |
924 | pidChannel = new QCopChannel( channel, this); | 947 | pidChannel = new QCopChannel( channel, this); |
925 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 948 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
926 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 949 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
927 | 950 | ||
928 | 951 | ||
929 | 952 | ||
930 | processQCopFile(); | 953 | processQCopFile(); |
931 | d->keep_running = d->qcopq.isEmpty(); | 954 | d->keep_running = d->qcopq.isEmpty(); |
932 | 955 | ||
933 | for (int a=0; a<argc; a++) { | 956 | for (int a=0; a<argc; a++) { |
934 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 957 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
935 | argv[a] = argv[a+1]; | 958 | argv[a] = argv[a+1]; |
936 | a++; | 959 | a++; |
937 | d->preloaded = TRUE; | 960 | d->preloaded = TRUE; |
938 | argc-=1; | 961 | argc-=1; |
939 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 962 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
940 | argv[a] = argv[a+1]; | 963 | argv[a] = argv[a+1]; |
941 | a++; | 964 | a++; |
942 | d->preloaded = TRUE; | 965 | d->preloaded = TRUE; |
943 | d->forceshow = TRUE; | 966 | d->forceshow = TRUE; |
944 | argc-=1; | 967 | argc-=1; |
945 | } | 968 | } |
946 | } | 969 | } |
947 | 970 | ||
948 | /* overide stored arguments */ | 971 | /* overide stored arguments */ |
949 | setArgs(argc, argv); | 972 | setArgs(argc, argv); |
950 | } | 973 | } |
951 | #endif | 974 | #endif |
952 | 975 | ||
953 | 976 | ||
954 | static QPtrDict<void>* inputMethodDict = 0; | 977 | static QPtrDict<void>* inputMethodDict = 0; |
955 | static void createInputMethodDict() | 978 | static void createInputMethodDict() |
956 | { | 979 | { |
957 | if ( !inputMethodDict ) | 980 | if ( !inputMethodDict ) |
958 | inputMethodDict = new QPtrDict<void>; | 981 | inputMethodDict = new QPtrDict<void>; |
959 | } | 982 | } |
960 | 983 | ||
961 | /*! | 984 | /*! |
962 | Returns the currently set hint to the system as to whether | 985 | Returns the currently set hint to the system as to whether |
963 | widget \a w has any use for text input methods. | 986 | widget \a w has any use for text input methods. |
964 | 987 | ||
965 | 988 | ||
966 | \sa setInputMethodHint() InputMethodHint | 989 | \sa setInputMethodHint() InputMethodHint |
967 | */ | 990 | */ |
968 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 991 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
969 | { | 992 | { |
970 | if ( inputMethodDict && w ) | 993 | if ( inputMethodDict && w ) |
971 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 994 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
972 | return Normal; | 995 | return Normal; |
973 | } | 996 | } |
974 | 997 | ||
975 | /*! | 998 | /*! |
976 | \enum QPEApplication::InputMethodHint | 999 | \enum QPEApplication::InputMethodHint |
977 | 1000 | ||
978 | \value Normal the application sometimes needs text input (the default). | 1001 | \value Normal the application sometimes needs text input (the default). |
979 | \value AlwaysOff the application never needs text input. | 1002 | \value AlwaysOff the application never needs text input. |
980 | \value AlwaysOn the application always needs text input. | 1003 | \value AlwaysOn the application always needs text input. |
981 | */ | 1004 | */ |
982 | 1005 | ||
983 | /*! | 1006 | /*! |
984 | Hints to the system that widget \a w has use for text input methods | 1007 | Hints to the system that widget \a w has use for text input methods |
985 | as specified by \a mode. | 1008 | as specified by \a mode. |
986 | 1009 | ||
987 | \sa inputMethodHint() InputMethodHint | 1010 | \sa inputMethodHint() InputMethodHint |
988 | */ | 1011 | */ |
989 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1012 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
990 | { | 1013 | { |
991 | createInputMethodDict(); | 1014 | createInputMethodDict(); |
992 | if ( mode == Normal ) { | 1015 | if ( mode == Normal ) { |
993 | inputMethodDict->remove | 1016 | inputMethodDict->remove |
994 | ( w ); | 1017 | ( w ); |
995 | } | 1018 | } |
996 | else { | 1019 | else { |
997 | inputMethodDict->insert( w, ( void* ) mode ); | 1020 | inputMethodDict->insert( w, ( void* ) mode ); |
998 | } | 1021 | } |
999 | } | 1022 | } |
1000 | 1023 | ||
1001 | class HackDialog : public QDialog | 1024 | class HackDialog : public QDialog |
1002 | { | 1025 | { |
1003 | public: | 1026 | public: |
1004 | void acceptIt() | 1027 | void acceptIt() |
1005 | { | 1028 | { |
1006 | accept(); | 1029 | accept(); |
1007 | } | 1030 | } |
1008 | void rejectIt() | 1031 | void rejectIt() |
1009 | { | 1032 | { |
1010 | reject(); | 1033 | reject(); |
1011 | } | 1034 | } |
1012 | }; | 1035 | }; |
1013 | 1036 | ||
1014 | 1037 | ||
1015 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1038 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1016 | { | 1039 | { |
1017 | // specialised actions for certain widgets. May want to | 1040 | // specialised actions for certain widgets. May want to |
1018 | // add more stuff here. | 1041 | // add more stuff here. |
1019 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1042 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1020 | && activePopupWidget() ->parentWidget() | 1043 | && activePopupWidget() ->parentWidget() |
1021 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1044 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1022 | key = Qt::Key_Return; | 1045 | key = Qt::Key_Return; |
1023 | 1046 | ||
1024 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1047 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1025 | key = Qt::Key_Return; | 1048 | key = Qt::Key_Return; |
1026 | 1049 | ||
1027 | #ifdef QWS | 1050 | #ifdef QWS |
1028 | 1051 | ||
1029 | ke->simpleData.keycode = key; | 1052 | ke->simpleData.keycode = key; |
1030 | #endif | 1053 | #endif |
1031 | } | 1054 | } |
1032 | 1055 | ||
1033 | 1056 | ||
1034 | /*! | 1057 | /*! |
1035 | \internal | 1058 | \internal |
1036 | */ | 1059 | */ |
1037 | 1060 | ||
1038 | #ifdef QWS | 1061 | #ifdef QWS |
1039 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1062 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1040 | { | 1063 | { |
1041 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1064 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1042 | if ( qApp->type() != QApplication::GuiServer ) { | 1065 | if ( qApp->type() != QApplication::GuiServer ) { |
1043 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1066 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1044 | e << d->appName; | 1067 | e << d->appName; |
1045 | } | 1068 | } |
1046 | d->notbusysent = TRUE; | 1069 | d->notbusysent = TRUE; |
1047 | } | 1070 | } |
1048 | if ( type() == GuiServer ) { | 1071 | if ( type() == GuiServer ) { |
1049 | switch ( e->type ) { | 1072 | switch ( e->type ) { |