From: vsr Date: Thu, 18 Jun 2015 07:47:51 +0000 (+0300) Subject: 0023084: [CEA 1431] To choose in the preferences of the type Paravis trace Paraview X-Git-Tag: V7_7_0a1~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f841671bf96dff390a082db725d4788326cd58c7;p=modules%2Fgui.git 0023084: [CEA 1431] To choose in the preferences of the type Paravis trace Paraview - Show single warning messages if Preferences dialog box if any option that requires application restart has been changed --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index cfd135861..0f580e8d5 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2180,9 +2180,11 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) } pref->setItemProperty( "strings", aLangs, curLang ); pref->setItemProperty( "icons", aIcons, curLang ); + pref->setItemProperty( "restart", true, curLang ); int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup, LightApp_Preferences::Bool, "language", "locale" ); + pref->setItemProperty( "restart", true, curLocale ); // ... "Language" group <> // ... "Look and feel" group <> @@ -3192,11 +3194,13 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } if ( sec == "language" && param == "language" ) { - SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) ); + // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg + //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" ) ); + // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg + //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) ); } if ( sec == "desktop" && param == "opaque_resize" ) { bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false ); diff --git a/src/LightApp/LightApp_Preferences.cxx b/src/LightApp/LightApp_Preferences.cxx index f1b34fdea..06bd500c9 100644 --- a/src/LightApp/LightApp_Preferences.cxx +++ b/src/LightApp/LightApp_Preferences.cxx @@ -22,7 +22,7 @@ // File: LightApp_Preferences.cxx // Author: Sergey TELKOV -// + #include "LightApp_Preferences.h" /*! @@ -97,6 +97,7 @@ void LightApp_Preferences::onApply() /*!Emit preference changed.*/ void LightApp_Preferences::changedResources( const ResourceMap& map ) { + bool toRestart = false; for ( ResourceMap::ConstIterator it = map.begin(); it != map.end(); ++it ) { @@ -104,6 +105,10 @@ void LightApp_Preferences::changedResources( const ResourceMap& map ) it.key()->resource( sec, param ); QString mod = module( it.key()->id() ); emit preferenceChanged( mod, sec, param ); + toRestart = toRestart || it.key()->isRestartRequired(); + } + if ( toRestart ) { + emit restartRequired(); } } diff --git a/src/LightApp/LightApp_Preferences.h b/src/LightApp/LightApp_Preferences.h index 932eb7660..234a81c2d 100644 --- a/src/LightApp/LightApp_Preferences.h +++ b/src/LightApp/LightApp_Preferences.h @@ -61,6 +61,7 @@ protected: signals: void preferenceChanged( QString&, QString&, QString& ); void resetToDefaults(); + void restartRequired(); private slots: void onHelp(); diff --git a/src/LightApp/LightApp_PreferencesDlg.cxx b/src/LightApp/LightApp_PreferencesDlg.cxx index be387c4cb..b4d8fc957 100644 --- a/src/LightApp/LightApp_PreferencesDlg.cxx +++ b/src/LightApp/LightApp_PreferencesDlg.cxx @@ -70,6 +70,8 @@ myPrefs( prefs ), mySaved ( false ) connect( impBtn, SIGNAL( clicked() ), this, SLOT( onImportPref() ) ); connect( this, SIGNAL( defaultPressed() ), prefs, SIGNAL( resetToDefaults() ) ); + connect( prefs, SIGNAL( restartRequired() ), this, SLOT( onRestartRequired() ) ); + setMinimumSize( 800, 600 ); } @@ -173,3 +175,9 @@ void LightApp_PreferencesDlg::onImportPref() myPrefs->toBackup(); } } + +/*! Called if some preferences that will come in force only after application restart are changed */ +void LightApp_PreferencesDlg::onRestartRequired() +{ + SUIT_MessageBox::information( this, tr( "WRN_WARNING" ), tr( "PREF_NEED_RESTART" ) ); +} diff --git a/src/LightApp/LightApp_PreferencesDlg.h b/src/LightApp/LightApp_PreferencesDlg.h index f7d49e6f8..e9ad61662 100644 --- a/src/LightApp/LightApp_PreferencesDlg.h +++ b/src/LightApp/LightApp_PreferencesDlg.h @@ -59,6 +59,7 @@ private slots: void onApply(); void onDefault(); void onImportPref(); + void onRestartRequired(); private: LightApp_Preferences* myPrefs; diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index be7ea9b40..e146f8654 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -1053,6 +1053,10 @@ File does not exist DEFAULT_BTN_TEXT Defaults + + PREF_NEED_RESTART + Some changes will take effect only after application restart + LightApp_ModuleAction diff --git a/src/Qtx/QtxPreferenceMgr.cxx b/src/Qtx/QtxPreferenceMgr.cxx index bd296750d..db5c0f9aa 100644 --- a/src/Qtx/QtxPreferenceMgr.cxx +++ b/src/Qtx/QtxPreferenceMgr.cxx @@ -132,7 +132,8 @@ void QtxPreferenceItem::Updater::customEvent( QEvent* /*e*/ ) */ QtxPreferenceItem::QtxPreferenceItem( QtxPreferenceItem* parent ) : myParent( 0 ), -myEval( true ) + myEval( true ), + myRestartNeeded( false ) { myId = generateId(); @@ -147,6 +148,8 @@ myEval( true ) */ QtxPreferenceItem::QtxPreferenceItem( const QString& title, QtxPreferenceItem* parent ) : myParent( 0 ), + myEval( true ), + myRestartNeeded( false ), myTitle( title ) { myId = generateId(); @@ -165,6 +168,8 @@ QtxPreferenceItem::QtxPreferenceItem( const QString& title, QtxPreferenceItem* p QtxPreferenceItem::QtxPreferenceItem( const QString& title, const QString& sect, const QString& param, QtxPreferenceItem* parent ) : myParent( 0 ), + myEval( true ), + myRestartNeeded( false ), myTitle( title ), mySection( sect ), myParameter( param ) @@ -452,16 +457,42 @@ void QtxPreferenceItem::setOption( const QString& name, const QVariant& val ) sendItemChanges(); } +/*! + \brief Get variables auto-conversion option value + \return option value +*/ bool QtxPreferenceItem::isEvaluateValues() const { return myEval; } +/*! + \brief Switch variables auto-conversion option on/off + \param on option value +*/ void QtxPreferenceItem::setEvaluateValues( const bool on ) { myEval = on; } +/*! + \brief Get restart needed option value + \return option value +*/ +bool QtxPreferenceItem::isRestartRequired() const +{ + return myRestartNeeded; +} + +/*! + \brief Switch restart needed option on/off + \param on option value +*/ +void QtxPreferenceItem::setRestartRequired( const bool on ) +{ + myRestartNeeded = on; +} + /*! \fn void QtxPreferenceItem::store(); \brief Save preference item (for example, to the resource file). @@ -807,6 +838,8 @@ QVariant QtxPreferenceItem::optionValue( const QString& name ) const QVariant val; if ( name == "eval" || name == "evaluation" || name == "subst" || name == "substitution" ) val = isEvaluateValues(); + else if ( name == "restart" ) + val = isRestartRequired(); else if ( name == "title" ) val = title(); return val; @@ -829,6 +862,11 @@ void QtxPreferenceItem::setOptionValue( const QString& name, const QVariant& val if ( val.canConvert( QVariant::Bool ) ) setEvaluateValues( val.toBool() ); } + if ( name == "restart" ) + { + if ( val.canConvert( QVariant::Bool ) ) + setRestartRequired( val.toBool() ); + } else if ( name == "title" ) { if ( val.canConvert( QVariant::String ) ) diff --git a/src/Qtx/QtxPreferenceMgr.h b/src/Qtx/QtxPreferenceMgr.h index b9c89a49f..ee13092cf 100644 --- a/src/Qtx/QtxPreferenceMgr.h +++ b/src/Qtx/QtxPreferenceMgr.h @@ -78,6 +78,9 @@ public: bool isEvaluateValues() const; void setEvaluateValues( const bool ); + bool isRestartRequired() const; + void setRestartRequired( const bool ); + virtual void store() = 0; virtual void retrieve() = 0; @@ -136,6 +139,7 @@ private: ItemList myChildren; bool myEval; + bool myRestartNeeded; QIcon myIcon; QString myTitle; QString mySection;