Salome HOME
0023084: [CEA 1431] To choose in the preferences of the type Paravis trace Paraview
authorvsr <vsr@opencascade.com>
Thu, 18 Jun 2015 07:47:51 +0000 (10:47 +0300)
committervsr <vsr@opencascade.com>
Thu, 18 Jun 2015 07:47:51 +0000 (10:47 +0300)
- Show single warning messages if Preferences dialog box if any option that requires application restart has been changed

src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Preferences.cxx
src/LightApp/LightApp_Preferences.h
src/LightApp/LightApp_PreferencesDlg.cxx
src/LightApp/LightApp_PreferencesDlg.h
src/LightApp/resources/LightApp_msg_en.ts
src/Qtx/QtxPreferenceMgr.cxx
src/Qtx/QtxPreferenceMgr.h

index cfd1358618c56132330a2186cd08dd3bdba31c45..0f580e8d5bc2d2f82353a14938422dc09539e6a5 100644 (file)
@@ -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 <<end>>
 
   // ... "Look and feel" group <<start>>
@@ -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 );
index f1b34fdeaf36943bfdfdfecf54b1f96622b896ee..06bd500c9f480b44d5f3e3478cce11ce58e40945 100644 (file)
@@ -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();
   }
 }
 
index 932eb7660c83b6bf379dda58d7d1803a887fca0c..234a81c2df1b7443cccab4989c20fae7e7779ffe 100644 (file)
@@ -61,6 +61,7 @@ protected:
 signals:
   void                 preferenceChanged( QString&, QString&, QString& );
   void                 resetToDefaults();
+  void                 restartRequired();
 
 private slots:
   void                 onHelp();
index be387c4cb22c87bb671a4045738ea5882c85611b..b4d8fc95761cbeda794f582292dfec41eee4e5ba 100644 (file)
@@ -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" ) );
+}
index f7d49e6f832cfe8612323f1e8a263bc494455bf3..e9ad61662571c79dadaf2bac26b26afe1d064f31 100644 (file)
@@ -59,6 +59,7 @@ private slots:
   void                  onApply();
   void                  onDefault();
   void                  onImportPref();
+  void                  onRestartRequired();
 
 private:
   LightApp_Preferences* myPrefs;
index be7ea9b40c7aba33d13ee34ffc684f15fda72086..e146f865467d68e474991b38941e322c7c104d35 100644 (file)
@@ -1053,6 +1053,10 @@ File does not exist</translation>
         <source>DEFAULT_BTN_TEXT</source>
         <translation>Defaults</translation>
     </message>
+    <message>
+        <source>PREF_NEED_RESTART</source>
+        <translation>Some changes will take effect only after application restart</translation>
+    </message>
 </context>
 <context>
     <name>LightApp_ModuleAction</name>
index bd296750dacbb176cab5150da56eb833181612d9..db5c0f9aa3af3f65e110f35694a577d60cb8a064 100644 (file)
@@ -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 ) )
index b9c89a49f5f7af76505d9d6a08be627de4060994..ee13092cf4327068f21c8504750ccbe297d8cb4d 100644 (file)
@@ -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;