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 )
*/
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<QChar, QString> substMap;
substMap.insert( 'A', appName() );
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& );
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<QChar, QString>& ) const;
private:
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 );
}
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 );