summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Side-by-side diff
Diffstat (limited to 'library/qpeapplication.cpp') (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
@@ -151,17 +151,16 @@ public:
bool keep_running : 1;
bool qcopQok : 1;
QCString fontFamily;
int fontSize;
int smallIconSize;
int bigIconSize;
- QStringList langs;
QString appName;
struct QCopRec
{
QCopRec( const QCString &ch, const QCString &msg,
const QByteArray &d ) :
channel( ch ), message( msg ), data( d )
{ }
@@ -753,16 +752,39 @@ void QPEApplication::processQCopFile()
}
\endcode
\sa qcop.html
Note that messages received here may be processed by qpe application
and emitted as signals, such as flush() and reload().
*/
+#ifndef QT_NO_TRANSLATION
+static void qtopia_loadTranslations( const QStringList& qms )
+{
+ QStringList langs = Global::languageList();
+
+ for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
+ QString lang = *it;
+
+ QTranslator * trans;
+ QString tfn;
+
+ for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
+ trans = new QTranslator(qApp);
+ tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
+ if ( trans->load( tfn ))
+ qApp->installTranslator( trans );
+ else
+ delete trans;
+ }
+ }
+}
+#endif
+
/*!
Constructs a QPEApplication just as you would construct
a QApplication, passing \a argc, \a argv, and \a t.
For applications, \a t should be the default, GuiClient. Only
the Qtopia server passes GuiServer.
*/
QPEApplication::QPEApplication( int & argc, char **argv, Type t )
@@ -840,42 +862,29 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
}
}
/* overide stored arguments */
setArgs( argc, argv );
#endif
#else
- initApp( argc, argv );
+ initApp( argc, argv );
#endif
#ifdef Q_WS_QWS
/* load the font renderer factories */
FontDatabase::loadRenderers();
#endif
#ifndef QT_NO_TRANSLATION
+ QStringList qms;
+ qms << "libqpe";
+ qms << "libopie";
+ qms << d->appName;
- d->langs = Global::languageList();
- for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
- QString lang = *it;
-
- installTranslation( lang + "/libopie.qm");
- installTranslation( lang + "/libqpe.qm" );
- installTranslation( lang + "/" + d->appName + ".qm" );
-
-
- //###language/font hack; should look it up somewhere
-#ifdef QWS
-
- if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
- QFont fn = FontManager::unicodeFont( FontManager::Proportional );
- setFont( fn );
- }
-#endif
- }
+ qtopia_loadTranslations(qms);
#endif
applyStyle();
if ( type() == GuiServer ) {
setVolume();
}
@@ -898,16 +907,20 @@ void QPEApplication::initApp( int argc, char **argv )
d->preloaded = FALSE;
d->forceshow = FALSE;
QCString channel = QCString(argv[0]);
channel.replace(QRegExp(".*/"),"");
d->appName = channel;
+#ifndef QT_NO_TRANSLATION
+ qtopia_loadTranslations( QStringList()<<channel );
+#endif
+
#if QT_VERSION > 235
qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
#endif
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this);
connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
this, SLOT(pidMessage(const QCString&,const QByteArray&)));
@@ -929,20 +942,16 @@ void QPEApplication::initApp( int argc, char **argv )
d->preloaded = TRUE;
d->forceshow = TRUE;
argc-=1;
}
}
/* overide stored arguments */
setArgs(argc, argv);
-
- /* install translation here */
- for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
- installTranslation( (*it) + "/" + d->appName + ".qm" );
}
#endif
static QPtrDict<void>* inputMethodDict = 0;
static void createInputMethodDict()
{
if ( !inputMethodDict )
@@ -2174,27 +2183,16 @@ void QPEApplication::tryQuit()
#endif
if ( d->keep_running )
d->store_widget_rect(d->qpe_main_widget, d->appName);
processEvents();
quit();
}
-/*!
- \internal
-*/
-void QPEApplication::installTranslation( const QString& baseName ) {
- QTranslator* trans = new QTranslator(this);
- QString tfn = qpeDir() + "/i18n/"+baseName;
- if ( trans->load( tfn ) )
- installTranslator( trans );
- else
- delete trans;
-}
/*!
\internal
User initiated quit. Makes the window 'Go Away'. If preloaded this means
hiding the window. If not it means quitting the application.
As this is user initiated we don't need to check state.
*/
void QPEApplication::hideOrQuit()