+QString salomeVersion()
+{
+ return GUI_VERSION_STR;
+}
+
+class SALOME_ResourceMgr : public SUIT_ResourceMgr
+{
+public:
+ SALOME_ResourceMgr( const QString& app, const QString& resVarTemplate ) : SUIT_ResourceMgr( app, resVarTemplate )
+ {
+ setCurrentFormat( "xml" );
+ setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
+ }
+ static void initResourceMgr()
+ {
+ if ( myExtAppName.isNull() || myExtAppVersion.isNull() ) {
+ SALOME_ResourceMgr resMgr( "SalomeApp", QString( "%1Config" ) );
+ resMgr.loadLanguage( "LightApp", "en" );
+ resMgr.loadLanguage( "SalomeApp", "en" );
+
+ myExtAppName = QObject::tr( "APP_NAME" ).trimmed();
+ if ( myExtAppName == "APP_NAME" || myExtAppName.toLower() == "salome" )
+ myExtAppName = "SalomeApp";
+ myExtAppVersion = QObject::tr( "APP_VERSION" );
+ if ( myExtAppVersion == "APP_VERSION" ) {
+ if ( myExtAppName != "SalomeApp" )
+ myExtAppVersion = "";
+ else myExtAppVersion = salomeVersion();
+ }
+ }
+ }
+ QString version() const { return myExtAppVersion; }
+
+protected:
+ QString userFileName( const QString& appName, const bool for_load ) const
+ {
+ if ( version().isEmpty() ) return "";
+ return SUIT_ResourceMgr::userFileName( myExtAppName, for_load );
+ }
+
+ virtual long userFileId( const QString& _fname ) const
+ {
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ // In SALOME and SALOME-based applications the user preferences file is named as
+ // - <AppName>.xml.<AppVersion> on Windows
+ // - <AppName>rc.<AppVersion> on Linux
+ // where
+ // * AppName is application name, default SalomeApp (can be customized in SALOME-based
+ // applications
+ // * AppVersion is application version
+ //
+ // Since version 6.5.0 of SALOME, user file is situated in the ~/.config/salome
+ // directory. For backward compatibility, when user preferences from nearest
+ // version of application is searched, user home directory is also looked through,
+ // with lower priority.
+ //
+ // Since version 6.6.0 of SALOME, user file name on Linux is no more prefixed by dot
+ // symbol since it is situated in hidden ~/.config/salome directory. Files with dot
+ // prefix also though taken into account (with lower priority) for backward compatibility.
+ //
+ // Notes:
+ // - Currently the following format of version number is supported:
+ // <major>[.<minor>[.<release>[<type><dev>]]]
+ // Parts in square brackets are considered optional. Here:
+ // * major - major version id
+ // * minor - minor version id
+ // * release - maintenance version id
+ // * type - dev or patch marker; it can be either one alphabetical symbol (from 'a' to 'z')
+ // or 'rc' to point release candidate (case-insensitive)
+ // * dev - dev version or patch number
+ // All numerical values must be of range [1-99].
+ // Examples: 1.0, 6.5.0, 1.2.0a1, 3.3.3rc3 (release candidate 3), 11.0.0p1 (patch 1)
+ //
+ // - Versioning approach can be customized by implementing and using own resource manager class,
+ // see QtxResurceMgr, SUIT_ResourceMgr classes.
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ long id = -1;
+ if ( !myExtAppName.isEmpty() ) {
+#ifdef WIN32
+ // On Windows, user file name is something like SalomeApp.xml.6.5.0 where
+ // - SalomeApp is an application name (can be customized)
+ // - xml is a file format (xml or ini)
+ // - 6.5.0 is an application version, can include alfa/beta/rc marks, e.g. 6.5.0a3, 6.5.0rc1
+ QRegExp exp( QString( "%1\\.%2\\.([a-zA-Z0-9.]+)" ).arg( myExtAppName ).arg( currentFormat() ) );
+#else
+ // On Linux, user file name is something like SalomeApprc.6.5.0 where
+ // - SalomeApp is an application name (can be customized)
+ // - 6.5.0 is an application version, can include alfa/beta/rc marks, e.g. 6.5.0a3, 6.5.0rc1
+
+ // VSR 24/09/2012: issue 0021781: since version 6.6.0 user filename is not prepended with "."
+ // when it is stored in the ~/.config/<appname> directory;
+ // for backward compatibility we also check files prepended with "." with lower priority
+ QRegExp exp( QString( "\\.?%1rc\\.([a-zA-Z0-9.]+)" ).arg( myExtAppName ) );
+#endif
+ QString fname = QFileInfo( _fname ).fileName();
+ if ( exp.exactMatch( fname ) ) {
+ long fid = Qtx::versionToId( exp.cap( 1 ) );
+ if ( fid > 0 ) id = fid;
+ }
+ }
+ return id;
+ }
+
+public:
+ static QString myExtAppName;
+ static QString myExtAppVersion;
+};
+
+QString SALOME_ResourceMgr::myExtAppName = QString();
+QString SALOME_ResourceMgr::myExtAppVersion = QString();
+