From: rnv Date: Thu, 24 Apr 2014 06:48:40 +0000 (+0400) Subject: Implementation of the ACTION 61.7 from the COTECH61: Add preference to X-Git-Tag: V7_4_0rc1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3fa1ef373fd166fa5edfcd9f984ade0b9dad15e8;p=modules%2Fgui.git Implementation of the ACTION 61.7 from the COTECH61: Add preference to set C locale for the application by default. --- diff --git a/doc/salome/gui/images/pref_salome_general.png b/doc/salome/gui/images/pref_salome_general.png index a9506accf..6dade45e1 100644 Binary files a/doc/salome/gui/images/pref_salome_general.png and b/doc/salome/gui/images/pref_salome_general.png differ diff --git a/doc/salome/gui/input/setting_preferences.doc b/doc/salome/gui/input/setting_preferences.doc index 99d478271..9fabab109 100644 --- a/doc/salome/gui/input/setting_preferences.doc +++ b/doc/salome/gui/input/setting_preferences.doc @@ -35,6 +35,9 @@ the whole GUI SALOME session. - Language - Current language - the language used by the application GUI. The language change will come in force only after the application is restarted. + - Use C locale - when checked, the C locale will be set for the application, + otherwise a system locale will be used. The locale change will come in force only after + the application is restarted. - Look and feel - Opaque resize - force opaque resize mode for viewers area (tabbed workspace). Clear this checkbox for less perfomant workstations. diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 15c0e9aa4..976f9c803 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2124,6 +2124,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) } pref->setItemProperty( "strings", aLangs, curLang ); pref->setItemProperty( "icons", aIcons, curLang ); + + int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup, + LightApp_Preferences::Bool, "language", "locale" ); // ... "Language" group <> // ... "Look and feel" group <> @@ -2994,6 +2997,10 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString { SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) ); } + if ( sec == "language" && param == "locale") + { + SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) ); + } if ( sec == "desktop" && param == "opaque_resize" ) { bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false ); QMainWindow::DockOptions dopts = desktop()->dockOptions(); diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index ff874775a..4588f9ae9 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -35,6 +35,7 @@ +
diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index c9ccbaf8b..8e44f37f9 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -92,6 +92,11 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS LANG_CHANGED Application language has been changed. +The changes will be applied on the next application session. + + + LOCALE_CHANGED + Application locale has been changed. The changes will be applied on the next application session. @@ -590,6 +595,10 @@ The changes will be applied on the next application session. PREF_CURRENT_LANGUAGE Current language + + PREF_CURRENT_LOCALE + Use C locale + PREF_GROUP_LOOK_AND_FEEL Look and feel diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 31cb87fc4..0e74d6a8d 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -43,6 +43,31 @@ #include +/* XPM for the default pixmap */ +static const char* pixmap_not_found_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #A80000", +" ", +" ", +" . . ", +" .+. .+. ", +" .+++. .+++. ", +" .+++.+++. ", +" .+++++. ", +" .+++. ", +" .+++++. ", +" .+++.+++. ", +" .+++. .+++. ", +" .+. .+. ", +" . . ", +" ", +" ", +" "}; + +QPixmap* QtxResourceMgr::myDefaultPix = NULL; + /*! \class QtxResourceMgr::Resources \internal @@ -1214,7 +1239,6 @@ bool QtxResourceMgr::Format::save( Resources* res ) QtxResourceMgr::QtxResourceMgr( const QString& appName, const QString& resVarTemplate ) : myAppName( appName ), myCheckExist( true ), - myDefaultPix( 0 ), myIsPixmapCached( true ), myHasUserValues( true ), myWorkingMode( AllowUserValues ) @@ -1252,8 +1276,6 @@ QtxResourceMgr::~QtxResourceMgr() qDeleteAll( myResources ); qDeleteAll( myFormats ); - - delete myDefaultPix; } /*! @@ -2521,9 +2543,12 @@ QString QtxResourceMgr::sectionsToken() const \return default pixmap \sa setDefaultPixmap(), loadPixmap() */ -QPixmap QtxResourceMgr::defaultPixmap() const +QPixmap QtxResourceMgr::defaultPixmap() { QPixmap res; + if(!myDefaultPix) + myDefaultPix = new QPixmap( pixmap_not_found_xpm ); + if ( myDefaultPix && !myDefaultPix->isNull() ) res = *myDefaultPix; return res; @@ -2543,7 +2568,7 @@ void QtxResourceMgr::setDefaultPixmap( const QPixmap& pix ) if ( pix.isNull() ) myDefaultPix = 0; else - myDefaultPix = new QPixmap( pix ); + myDefaultPix = new QPixmap( pix ); } /*! @@ -2863,7 +2888,6 @@ QString QtxResourceMgr::userFileName( const QString& appName, const bool /*for_l { QString fileName; QString pathName = QDir::homePath(); - QString cfgAppName = QApplication::applicationName(); if ( !cfgAppName.isEmpty() ) pathName = Qtx::addSlash( Qtx::addSlash( pathName ) + QString( ".config" ) ) + cfgAppName; diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 6abab3010..11eab4a4a 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -141,8 +141,8 @@ public: QString option( const QString& ) const; void setOption( const QString&, const QString& ); - QPixmap defaultPixmap() const; - virtual void setDefaultPixmap( const QPixmap& ); + static QPixmap defaultPixmap(); + static void setDefaultPixmap( const QPixmap& ); QString resSection() const; QString langSection() const; @@ -201,7 +201,7 @@ private: ResList myResources; //!< resources list bool myCheckExist; //!< "check existance" flag TransListMap myTranslator; //!< map of loaded translators - QPixmap* myDefaultPix; //!< default icon + static QPixmap* myDefaultPix; //!< default icon bool myIsPixmapCached; //!< "cached pixmaps" flag bool myHasUserValues; //!< \c true if user preferences has been read diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 9340f4d00..ee301cb25 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -97,29 +97,6 @@ static QString getAppName( const QString& libName ) // } // } -/* XPM */ -static const char* pixmap_not_found_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #A80000", -" ", -" ", -" . . ", -" .+. .+. ", -" .+++. .+++. ", -" .+++.+++. ", -" .+++++. ", -" .+++. ", -" .+++++. ", -" .+++.+++. ", -" .+++. .+++. ", -" .+. .+. ", -" . . ", -" ", -" ", -" "}; - class SUITApp_Session: public SUIT_Session { public: @@ -143,8 +120,6 @@ public: if ( resMgr ) { - static QPixmap defaultPixmap( pixmap_not_found_xpm ); - resMgr->setDefaultPixmap( defaultPixmap ); resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) ); } return resMgr; diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 3f78ea2a0..42770dbfc 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -110,29 +110,6 @@ void MessageOutput( QtMsgType type, const char* msg ) } } -/* XPM */ -static const char* pixmap_not_found_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #A80000", -" ", -" ", -" . . ", -" .+. .+. ", -" .+++. .+++. ", -" .+++.+++. ", -" .+++++. ", -" .+++. ", -" .+++++. ", -" .+++.+++. ", -" .+++. .+++. ", -" .+. .+. ", -" . . ", -" ", -" ", -" "}; - QString salomeVersion() { return GUI_VERSION_STR; @@ -145,7 +122,6 @@ public: { setCurrentFormat( "xml" ); setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) ); - setDefaultPixmap( QPixmap( pixmap_not_found_xpm ) ); } static void initResourceMgr() { @@ -277,7 +253,7 @@ public: SALOME_Session() : SUIT_Session() {} virtual ~SALOME_Session() {} -protected: +public: virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const { SALOME_ResourceMgr::initResourceMgr(); @@ -414,6 +390,19 @@ int main( int argc, char **argv ) if ( !qtdir.isEmpty() ) QApplication::addLibraryPath( QDir( qtdir ).absoluteFilePath( "plugins" ) ); + { + SALOME_Session s; + QApplication::setApplicationName( "salome" ); + SUIT_ResourceMgr* resMgr = s.createResourceMgr( "SalomeApp" ); + bool isCloc = resMgr->booleanValue( "language", "locale", true ); + if ( isCloc ) { + QLocale::setDefault( QLocale::c() ); + } + else { + QLocale::setDefault( QLocale::system() ); + } + } + // Create Qt application instance; // this should be done the very first! SALOME_QApplication _qappl( argc, argv );