-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 | |||
@@ -735,107 +735,130 @@ void QPEApplication::processQCopFile() | |||
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 ); |