From: vsr Date: Thu, 23 Oct 2014 14:43:52 +0000 (+0400) Subject: Emit signal when user resets appication settings to defaults by pressing "Defaults... X-Git-Tag: V7_5_0b1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ec94f64d66139c87f83dbb14ba6b96f3345c8fc3;p=modules%2Fgui.git Emit signal when user resets appication settings to defaults by pressing "Defaults" button in "Preferences" dialog box. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index dac8913c9..3017896cf 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -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; diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 51c6f3486..3ea6cb1dd 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -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: diff --git a/src/LightApp/LightApp_Preferences.h b/src/LightApp/LightApp_Preferences.h index cda80799e..f6568fac7 100644 --- a/src/LightApp/LightApp_Preferences.h +++ b/src/LightApp/LightApp_Preferences.h @@ -60,6 +60,7 @@ protected: signals: void preferenceChanged( QString&, QString&, QString& ); + void resetToDefaults(); private slots: void onHelp(); diff --git a/src/LightApp/LightApp_PreferencesDlg.cxx b/src/LightApp/LightApp_PreferencesDlg.cxx index 991cf2723..147370675 100644 --- a/src/LightApp/LightApp_PreferencesDlg.cxx +++ b/src/LightApp/LightApp_PreferencesDlg.cxx @@ -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 */ diff --git a/src/LightApp/LightApp_PreferencesDlg.h b/src/LightApp/LightApp_PreferencesDlg.h index 6ed946817..3953530e5 100644 --- a/src/LightApp/LightApp_PreferencesDlg.h +++ b/src/LightApp/LightApp_PreferencesDlg.h @@ -51,6 +51,9 @@ public: bool isSaved() { return mySaved; } void setSaved( bool saved ) { mySaved = saved; } +signals: + void defaultPressed(); + private slots: void onHelp(); void onApply();