]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Emit signal when user resets appication settings to defaults by pressing "Defaults...
authorvsr <vsr@opencascade.com>
Thu, 23 Oct 2014 14:43:52 +0000 (18:43 +0400)
committervsr <vsr@opencascade.com>
Thu, 23 Oct 2014 14:43:52 +0000 (18:43 +0400)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_Preferences.h
src/LightApp/LightApp_PreferencesDlg.cxx
src/LightApp/LightApp_PreferencesDlg.h

index dac8913c910133c4f5746d004dfdc0f92d16a339..3017896cfafb27abbaaf4cc235cd83743b3dd3db 100644 (file)
@@ -1983,7 +1983,9 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
   that->myPrefs = _prefs_;
 
   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
-           this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
+           this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
+  connect( myPrefs, SIGNAL( resetToDefaults() ),
+           this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
 
   if ( !crt )
     return myPrefs;
index 51c6f3486e35f44a0b62ce4de2492ac7ecc60b40..3ea6cb1ddfa5535887b921069f39c8459ab65feb 100644 (file)
@@ -187,6 +187,7 @@ signals:
   void                                studySaved();
   void                                studyClosed();
   void                                preferenceChanged( const QString&, const QString&, const QString& );
+  void                                preferenceResetToDefaults();
   void                                operationFinished( const QString&, const QString&, const QStringList& );
 
 public slots:
index cda80799ebf078d84de5e0370e52afd08d8f764a..f6568fac75c8d4981bfc2f50fec3bcd9cf80d014 100644 (file)
@@ -60,6 +60,7 @@ protected:
 
 signals:
   void                 preferenceChanged( QString&, QString&, QString& );
+  void                 resetToDefaults();
 
 private slots:
   void                 onHelp();
index 991cf27236775311b6bf98c16837e80a84908d37..147370675a032b56742899094b85e099c1770dea 100644 (file)
@@ -68,6 +68,7 @@ myPrefs( prefs ), mySaved ( false )
   QAbstractButton* impBtn = userButton( insertButton( tr( "IMPORT_BTN_TEXT" ) ) );
   if( impBtn )
     connect( impBtn, SIGNAL( clicked() ), this, SLOT( onImportPref() ) );
+  connect( this, SIGNAL( defaultPressed() ), prefs, SIGNAL( resetToDefaults() ) );
 
   setMinimumSize( 800, 600 );
 }
@@ -140,17 +141,18 @@ void LightApp_PreferencesDlg::onApply()
 /*! Restore default preferences*/
 void LightApp_PreferencesDlg::onDefault()
 {
-  if( SUIT_MessageBox::Ok == SUIT_MessageBox::question( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ),
-                                                        SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
-                                                        SUIT_MessageBox::Ok ) )
+  if ( SUIT_MessageBox::Ok == SUIT_MessageBox::question( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ),
+                                                        SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
+                                                        SUIT_MessageBox::Ok ) )
+  {
+    if ( myPrefs && myPrefs->resourceMgr() )
     {
-      if ( myPrefs && myPrefs->resourceMgr() )
-        {
-          QtxResourceMgr::WorkingMode prev = myPrefs->resourceMgr()->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
-          myPrefs->retrieve();
-          myPrefs->resourceMgr()->setWorkingMode( prev );
-        }
+      QtxResourceMgr::WorkingMode prev = myPrefs->resourceMgr()->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
+      myPrefs->retrieve();
+      myPrefs->resourceMgr()->setWorkingMode( prev );
     }
+    emit defaultPressed();
+  }
 }
 
 /*! Import preferences from some file */
index 6ed946817e858f52df4ec0ce533162b727f1642f..3953530e5b2d23e3f9dfc220beee6e53e6b7387d 100644 (file)
@@ -51,6 +51,9 @@ public:
   bool                  isSaved() { return mySaved; }
   void                  setSaved( bool saved ) { mySaved = saved; } 
 
+signals:
+  void                  defaultPressed();
+
 private slots:
   void                  onHelp();
   void                  onApply();