summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp66
1 files changed, 32 insertions, 34 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:
bool notbusysent : 1;
bool preloaded : 1;
bool forceshow : 1;
bool nomaximize : 1;
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 )
{ }
QCString channel;
QCString message;
QByteArray data;
};
@@ -749,24 +748,47 @@ void QPEApplication::processQCopFile()
...
} else if ( msg == "otherMessage(QString)" ) {
...
}
}
\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 )
: QApplication( hack(argc), argv, t ), pidChannel( 0 )
{
QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
@@ -843,43 +865,30 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
/* overide stored arguments */
setArgs( argc, argv );
#endif
#else
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();
}
installEventFilter( this );
QPEMenuToolFocusManager::initialize();
@@ -894,24 +903,28 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
void QPEApplication::initApp( int argc, char **argv )
{
delete pidChannel;
d->keep_running = TRUE;
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&)));
processQCopFile();
@@ -925,28 +938,24 @@ void QPEApplication::initApp( int argc, char **argv )
argc-=1;
} else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
argv[a] = argv[a+1];
a++;
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 )
inputMethodDict = new QPtrDict<void>;
}
/*!
@@ -2170,35 +2179,24 @@ void QPEApplication::tryQuit()
{
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << d->appName;
}
#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()
{
if ( d->keep_running )
d->store_widget_rect(d->qpe_main_widget, d->appName);
processEvents();