author | zecke <zecke> | 2003-05-12 13:07:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-12 13:07:37 (UTC) |
commit | 4765c92ba3dcbd829cb2adde4a097dfe6283d7cc (patch) (side-by-side diff) | |
tree | 7a13062058737af1564863f9caec692f145fdfaa /library | |
parent | 65a043f4ac4b43967947c1e8d99c629bb993f065 (diff) | |
download | opie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.zip opie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.tar.gz opie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.tar.bz2 |
Hospital Hacking Session
Install libopie.qm make apps fully translatable...
refactor installing trans into a method instead of having the same code copy
and pasted three times
-rw-r--r-- | library/qpeapplication.cpp | 30 | ||||
-rw-r--r-- | library/qpeapplication.h | 3 |
2 files changed, 18 insertions, 15 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index e5da48c..f4db1ab 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -574,80 +574,68 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) f.remove(); } for ( int a = 0; a < argc; a++ ) { if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { argv[ a ] = argv[ a + 1 ]; a++; d->preloaded = TRUE; 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 ); #endif // qwsSetDecoration( new QPEDecoration() ); #ifndef QT_NO_TRANSLATION QStringList langs = Global::languageList(); for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { QString lang = *it; - QTranslator * trans; - QString tfn; + installTranslation( lang + "/libopie.qm"); + installTranslation( lang + "/libqpe.qm" ); + installTranslation( lang + "/" + d->appName + ".qm" ); - trans = new QTranslator( this ); - tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; - if ( trans->load( tfn ) ) - installTranslator( trans ); - else - delete trans; - - trans = new QTranslator( this ); - tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; - if ( trans->load( tfn ) ) - installTranslator( trans ); - else - delete trans; //###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 } #endif applyStyle(); if ( type() == GuiServer ) { setVolume(); } installEventFilter( this ); QPEMenuToolFocusManager::initialize(); #ifdef QT_NO_QWS_CURSOR // if we have no cursor, probably don't want tooltips QToolTip::setEnabled( FALSE ); #endif } static QPtrDict<void>* inputMethodDict = 0; static void createInputMethodDict() { @@ -1698,64 +1686,76 @@ int QPEApplication::exec() { QCopEnvelope e( "QPE/System", "closing(QString)" ); e << d->appName; } #endif processEvents(); return 0; } /*! \internal External request for application to quit. Quits if possible without loosing state. */ void QPEApplication::tryQuit() { if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) return ; // Inside modal loop or konsole. Too hard to save state. #ifndef QT_NO_COP { QCopEnvelope e( "QPE/System", "closing(QString)" ); e << d->appName; } #endif 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() { processEvents(); // If we are a preloaded application we don't actually quit, so emit // a System message indicating we're quasi-closing. if ( d->preloaded && d->qpe_main_widget ) #ifndef QT_NO_COP { QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); e << d->appName; d->qpe_main_widget->hide(); } #endif else quit(); } #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // The libraries with the skiff package (and possibly others) have // completely useless implementations of builtin new and delete that // use about 50% of your CPU. Here we revert to the simple libc // functions. void* operator new[]( size_t size ) diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 0bad8b7..e35c008 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h @@ -93,64 +93,67 @@ public: signals: void clientMoused(); void timeChanged(); void clockChanged( bool pm ); void micChanged( bool muted ); void volumeChanged( bool muted ); void appMessage( const QCString& msg, const QByteArray& data); void weekChanged( bool startOnMonday ); void dateFormatChanged( DateFormat ); void flush(); void reload(); private slots: void systemMessage( const QCString &msg, const QByteArray &data ); void pidMessage( const QCString &msg, const QByteArray &data ); void removeSenderFromStylusDict(); void hideOrQuit(); protected: bool qwsEventFilter( QWSEvent * ); void internalSetStyle( const QString &style ); void prepareForTermination(bool willrestart); virtual void restart(); virtual void shutdown(); bool eventFilter( QObject *, QEvent * ); void timerEvent( QTimerEvent * ); bool raiseAppropriateWindow(); virtual void tryQuit(); virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) private: +#ifndef QT_NO_TRANSLATION + void installTranslation( const QString& baseName ); +#endif void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel *sysChannel; QCopChannel *pidChannel; #endif QPEApplicationData *d; bool reserved_sh; }; inline void QPEApplication::showDialog( QDialog* d, bool nomax ) { QSize sh = d->sizeHint(); int w = QMAX(sh.width(),d->width()); int h = QMAX(sh.height(),d->height()); if ( !nomax && ( w > qApp->desktop()->width()*3/4 || h > qApp->desktop()->height()*3/4 ) ) { d->showMaximized(); } else { d->resize(w,h); d->show(); } } inline int QPEApplication::execDialog( QDialog* d, bool nomax ) { |