summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp68
1 files changed, 33 insertions, 35 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 0b6d56d..1117240 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -147,25 +147,24 @@ public:
147 bool notbusysent : 1; 147 bool notbusysent : 1;
148 bool preloaded : 1; 148 bool preloaded : 1;
149 bool forceshow : 1; 149 bool forceshow : 1;
150 bool nomaximize : 1; 150 bool nomaximize : 1;
151 bool keep_running : 1; 151 bool keep_running : 1;
152 bool qcopQok : 1; 152 bool qcopQok : 1;
153 153
154 QCString fontFamily; 154 QCString fontFamily;
155 int fontSize; 155 int fontSize;
156 int smallIconSize; 156 int smallIconSize;
157 int bigIconSize; 157 int bigIconSize;
158 158
159 QStringList langs;
160 QString appName; 159 QString appName;
161 struct QCopRec 160 struct QCopRec
162 { 161 {
163 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 163 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
166 { } 165 { }
167 166
168 QCString channel; 167 QCString channel;
169 QCString message; 168 QCString message;
170 QByteArray data; 169 QByteArray data;
171 }; 170 };
@@ -749,24 +748,47 @@ void QPEApplication::processQCopFile()
749 ... 748 ...
750 } else if ( msg == "otherMessage(QString)" ) { 749 } else if ( msg == "otherMessage(QString)" ) {
751 ... 750 ...
752 } 751 }
753 } 752 }
754\endcode 753\endcode
755 754
756 \sa qcop.html 755 \sa qcop.html
757 Note that messages received here may be processed by qpe application 756 Note that messages received here may be processed by qpe application
758 and emitted as signals, such as flush() and reload(). 757 and emitted as signals, such as flush() and reload().
759*/ 758*/
760 759
760#ifndef QT_NO_TRANSLATION
761static void qtopia_loadTranslations( const QStringList& qms )
762{
763 QStringList langs = Global::languageList();
764
765 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
766 QString lang = *it;
767
768 QTranslator * trans;
769 QString tfn;
770
771 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
772 trans = new QTranslator(qApp);
773 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
774 if ( trans->load( tfn ))
775 qApp->installTranslator( trans );
776 else
777 delete trans;
778 }
779 }
780}
781#endif
782
761/*! 783/*!
762 Constructs a QPEApplication just as you would construct 784 Constructs a QPEApplication just as you would construct
763 a QApplication, passing \a argc, \a argv, and \a t. 785 a QApplication, passing \a argc, \a argv, and \a t.
764 786
765 For applications, \a t should be the default, GuiClient. Only 787 For applications, \a t should be the default, GuiClient. Only
766 the Qtopia server passes GuiServer. 788 the Qtopia server passes GuiServer.
767*/ 789*/
768QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 790QPEApplication::QPEApplication( int & argc, char **argv, Type t )
769 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 791 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
770{ 792{
771 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 793 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
772 794
@@ -836,50 +858,37 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
836 a++; 858 a++;
837 d->preloaded = TRUE; 859 d->preloaded = TRUE;
838 d->forceshow = TRUE; 860 d->forceshow = TRUE;
839 argc -= 1; 861 argc -= 1;
840 } 862 }
841 } 863 }
842 864
843 /* overide stored arguments */ 865 /* overide stored arguments */
844 setArgs( argc, argv ); 866 setArgs( argc, argv );
845 867
846#endif 868#endif
847#else 869#else
848 initApp( argc, argv ); 870 initApp( argc, argv );
849#endif 871#endif
850#ifdef Q_WS_QWS 872#ifdef Q_WS_QWS
851 /* load the font renderer factories */ 873 /* load the font renderer factories */
852 FontDatabase::loadRenderers(); 874 FontDatabase::loadRenderers();
853#endif 875#endif
854#ifndef QT_NO_TRANSLATION 876#ifndef QT_NO_TRANSLATION
877 QStringList qms;
878 qms << "libqpe";
879 qms << "libopie";
880 qms << d->appName;
855 881
856 d->langs = Global::languageList(); 882 qtopia_loadTranslations(qms);
857 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
858 QString lang = *it;
859
860 installTranslation( lang + "/libopie.qm");
861 installTranslation( lang + "/libqpe.qm" );
862 installTranslation( lang + "/" + d->appName + ".qm" );
863
864
865 //###language/font hack; should look it up somewhere
866#ifdef QWS
867
868 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
869 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
870 setFont( fn );
871 }
872#endif
873 }
874#endif 883#endif
875 884
876 applyStyle(); 885 applyStyle();
877 886
878 if ( type() == GuiServer ) { 887 if ( type() == GuiServer ) {
879 setVolume(); 888 setVolume();
880 } 889 }
881 890
882 installEventFilter( this ); 891 installEventFilter( this );
883 892
884 QPEMenuToolFocusManager::initialize(); 893 QPEMenuToolFocusManager::initialize();
885 894
@@ -894,24 +903,28 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
894void QPEApplication::initApp( int argc, char **argv ) 903void QPEApplication::initApp( int argc, char **argv )
895{ 904{
896 delete pidChannel; 905 delete pidChannel;
897 d->keep_running = TRUE; 906 d->keep_running = TRUE;
898 d->preloaded = FALSE; 907 d->preloaded = FALSE;
899 d->forceshow = FALSE; 908 d->forceshow = FALSE;
900 909
901 QCString channel = QCString(argv[0]); 910 QCString channel = QCString(argv[0]);
902 911
903 channel.replace(QRegExp(".*/"),""); 912 channel.replace(QRegExp(".*/"),"");
904 d->appName = channel; 913 d->appName = channel;
905 914
915#ifndef QT_NO_TRANSLATION
916 qtopia_loadTranslations( QStringList()<<channel );
917#endif
918
906 #if QT_VERSION > 235 919 #if QT_VERSION > 235
907 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 920 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
908 #endif 921 #endif
909 922
910 channel = "QPE/Application/" + channel; 923 channel = "QPE/Application/" + channel;
911 pidChannel = new QCopChannel( channel, this); 924 pidChannel = new QCopChannel( channel, this);
912 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 925 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
913 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 926 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
914 927
915 928
916 929
917 processQCopFile(); 930 processQCopFile();
@@ -925,28 +938,24 @@ void QPEApplication::initApp( int argc, char **argv )
925 argc-=1; 938 argc-=1;
926 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 939 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
927 argv[a] = argv[a+1]; 940 argv[a] = argv[a+1];
928 a++; 941 a++;
929 d->preloaded = TRUE; 942 d->preloaded = TRUE;
930 d->forceshow = TRUE; 943 d->forceshow = TRUE;
931 argc-=1; 944 argc-=1;
932 } 945 }
933 } 946 }
934 947
935 /* overide stored arguments */ 948 /* overide stored arguments */
936 setArgs(argc, argv); 949 setArgs(argc, argv);
937
938 /* install translation here */
939 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
940 installTranslation( (*it) + "/" + d->appName + ".qm" );
941} 950}
942#endif 951#endif
943 952
944 953
945static QPtrDict<void>* inputMethodDict = 0; 954static QPtrDict<void>* inputMethodDict = 0;
946static void createInputMethodDict() 955static void createInputMethodDict()
947{ 956{
948 if ( !inputMethodDict ) 957 if ( !inputMethodDict )
949 inputMethodDict = new QPtrDict<void>; 958 inputMethodDict = new QPtrDict<void>;
950} 959}
951 960
952/*! 961/*!
@@ -2170,35 +2179,24 @@ void QPEApplication::tryQuit()
2170 { 2179 {
2171 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2180 QCopEnvelope e( "QPE/System", "closing(QString)" );
2172 e << d->appName; 2181 e << d->appName;
2173 } 2182 }
2174#endif 2183#endif
2175 if ( d->keep_running ) 2184 if ( d->keep_running )
2176 d->store_widget_rect(d->qpe_main_widget, d->appName); 2185 d->store_widget_rect(d->qpe_main_widget, d->appName);
2177 processEvents(); 2186 processEvents();
2178 2187
2179 quit(); 2188 quit();
2180} 2189}
2181 2190
2182/*!
2183 \internal
2184*/
2185void QPEApplication::installTranslation( const QString& baseName ) {
2186 QTranslator* trans = new QTranslator(this);
2187 QString tfn = qpeDir() + "/i18n/"+baseName;
2188 if ( trans->load( tfn ) )
2189 installTranslator( trans );
2190 else
2191 delete trans;
2192}
2193 2191
2194/*! 2192/*!
2195 \internal 2193 \internal
2196 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2194 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2197 hiding the window. If not it means quitting the application. 2195 hiding the window. If not it means quitting the application.
2198 As this is user initiated we don't need to check state. 2196 As this is user initiated we don't need to check state.
2199*/ 2197*/
2200void QPEApplication::hideOrQuit() 2198void QPEApplication::hideOrQuit()
2201{ 2199{
2202 if ( d->keep_running ) 2200 if ( d->keep_running )
2203 d->store_widget_rect(d->qpe_main_widget, d->appName); 2201 d->store_widget_rect(d->qpe_main_widget, d->appName);
2204 processEvents(); 2202 processEvents();