From: vsr Date: Wed, 16 Jan 2008 14:57:08 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_0_0a1~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=199af78b5040cc73afcc13824741d277a63e2522;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 45f5a2609..22a716742 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -1213,16 +1213,17 @@ QStringList QtxResourceMgr::dirList() const Prepare the resources containers and load resources (if \a autoLoad is \c true). - \param autoLoad if \c true then all resources are loaded + \param autoLoad if \c true (default) then all resources are loaded + \param loadUser if \c true (default) then user settings are also loaded */ -void QtxResourceMgr::initialize( const bool autoLoad ) const +void QtxResourceMgr::initialize( const bool autoLoad, const bool loadUser ) const { if ( !myResources.isEmpty() ) return; QtxResourceMgr* that = (QtxResourceMgr*)this; - if ( !userFileName( appName() ).isEmpty() ) + if ( loadUser && !userFileName( appName() ).isEmpty() ) that->myResources.append( new Resources( that, userFileName( appName() ) ) ); for ( QStringList::const_iterator it = myDirList.begin(); it != myDirList.end(); ++it ) @@ -2348,7 +2349,36 @@ QPixmap QtxResourceMgr::loadPixmap( const QString& prefix, const QString& name, */ void QtxResourceMgr::loadLanguage( const QString& pref, const QString& l ) { - initialize(); + loadLanguage( true, pref, l ); +} + +/*! + \brief Load translation files according to the specified language. + + Names of the translation files are calculated according to the pattern specified + by the "translators" option (this option is read from the section "language" of resources files). + By default, "%P_msg_%L.qm" pattern is used. + Keywords \%A, \%P, \%L in the pattern are substituted by the application name, prefix and language name + correspondingly. + For example, for prefix "SUIT" an language "en", all translation files "SUIT_msg_en.qm" are searched and + loaded. + + If prefix is empty or null string, all translation files specified in the "resources" section of resources + files are loaded (actually, the section is retrieved from resSection() method). + If language is not specified, it is retrieved from the langSection() method, and if the latest is also empty, + by default "en" (English) language is used. + By default, settings from the user preferences file are also loaded (if user resource file is valid, + see userFileName()). To avoid loading user settings, pass \c false as first parameter. + + \param loadUser if \c true then user settings are also loaded + \param pref parameter which defines translation context (for example, package name) + \param l language name + + \sa resSection(), langSection(), loadTranslators() +*/ +void QtxResourceMgr::loadLanguage( const bool loadUser, const QString& pref, const QString& l ) +{ + initialize( true, loadUser ); QMap substMap; substMap.insert( 'A', appName() ); diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 9e5ba1716..550c14e30 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -138,6 +138,7 @@ public: QPixmap loadPixmap( const QString&, const QString&, const bool ) const; QPixmap loadPixmap( const QString&, const QString&, const QPixmap& ) const; void loadLanguage( const QString& = QString(), const QString& = QString() ); + void loadLanguage( const bool, const QString& = QString(), const QString& = QString() ); void raiseTranslators( const QString& ); void removeTranslators( const QString& ); @@ -163,7 +164,7 @@ protected: virtual QString globalFileName( const QString& ) const; private: - void initialize( const bool = true ) const; + void initialize( const bool = true, const bool = true ) const; QString substMacro( const QString&, const QMap& ) const; private: diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 81bab394b..7f29296a7 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -191,7 +191,7 @@ int main( int args, char* argv[] ) SUIT_ResourceMgr* resMgr = aSession->createResourceMgr( argList.first() ); if ( resMgr ) { - resMgr->loadLanguage(); + resMgr->loadLanguage( false ); splash = QtxSplash::splash( QPixmap() ); splash->readSettings( resMgr ); diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 18a313b96..243abbdd4 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -179,7 +179,7 @@ public: protected: QString userFileName( const QString& appName, const bool for_load ) const { - if ( version().isNull() ) return ""; + if ( version().isEmpty() ) return ""; return SUIT_ResourceMgr::userFileName( myExtAppName, for_load ); } @@ -315,12 +315,14 @@ int main( int argc, char **argv ) bool isGUI = isFound( "GUI", argc, argv ); bool isSplash = isFound( "SPLASH", argc, argv ); // Show splash screen (only if both the "GUI" and "SPLASH" parameters are set) + // Note, that user preferences are not taken into account for splash settings - + // it is a property of the application! QtxSplash* splash = 0; if ( isGUI && isSplash ) { // ...create resource manager SUIT_ResourceMgr resMgr( "SalomeApp", QString( "%1Config" ) ); resMgr.setCurrentFormat( "xml" ); - resMgr.loadLanguage( "LightApp", "en" ); + resMgr.loadLanguage( false, "LightApp", "en" ); // splash = QtxSplash::splash( QPixmap() ); splash->readSettings( &resMgr );