author | zecke <zecke> | 2004-10-15 22:27:30 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-15 22:27:30 (UTC) |
commit | bc127247d5c74f05b58610cbc94ebc8682a16c7f (patch) (side-by-side diff) | |
tree | 433984506aa9b22f916c0ae966956fc53b29197c /library | |
parent | db5e39dbf2e81b3e4e2a7e13fa1a51c34a86e319 (diff) | |
download | opie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.zip opie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.tar.gz opie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.tar.bz2 |
Remove QPEApplication::installTranslator and use qtopia_installTranslator
patch adopted from Qtopia1.7
-rw-r--r-- | library/qpeapplication.cpp | 66 |
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 @@ -135,49 +135,48 @@ public: #endif } int presstimer; QWidget* presswidget; QPoint presspos; #ifdef OPIE_WITHROHFEEDBACK Opie::Internal::RoHFeedback *RoH; #endif bool rightpressed : 1; bool kbgrabbed : 1; 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; }; QWidget* qpe_main_widget; QGuardedPtr<QWidget> lastraised; QQueue<QCopRec> qcopq; QString styleName; QString decorationName; void enqueueQCop( const QCString &ch, const QCString &msg, const QByteArray &data ) { qcopq.enqueue( new QCopRec( ch, msg, data ) ); } void sendQCopQ() @@ -737,48 +736,71 @@ void QPEApplication::processQCopFile() QCop\endlink channel. The slot to which you connect this signal uses \a msg and \a data in the following way: \code void MyWidget::receive( const QCString& msg, const QByteArray& data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "someMessage(int,int,int)" ) { int a,b,c; stream >> a >> b >> c; ... } 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. d = new QPEApplicationData; d->loadTextCodecs(); d->loadImageCodecs(); setFont( QFont( d->fontFamily, d->fontSize ) ); AppLnk::setSmallIconSize( d->smallIconSize ); AppLnk::setBigIconSize( d->bigIconSize ); QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); @@ -831,134 +853,121 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 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 #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(); #ifdef QT_NO_QWS_CURSOR // if we have no cursor, probably don't want tooltips QToolTip::setEnabled( FALSE ); #endif } #ifdef QTOPIA_INTERNAL_INITAPP 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(); d->keep_running = d->qcopq.isEmpty(); 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); - - /* 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>; } /*! Returns the currently set hint to the system as to whether widget \a w has any use for text input methods. \sa setInputMethodHint() InputMethodHint */ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) { if ( inputMethodDict && w ) return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); return Normal; } @@ -2158,59 +2167,48 @@ int QPEApplication::exec() /*! \internal External request for application to quit. Quits if possible without loosing state. */ void QPEApplication::tryQuit() { if ( activeModalWidget() ) 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 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(); // 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 |