From 4a0cf12cf3b112a8302a471c8c850fa9de568409 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 24 Oct 2014 13:35:48 +0400 Subject: [PATCH] Emit signal when user resets appication settings to defaults by pressing "Defaults" button in "Preferences" dialog box. Conflicts: src/LightApp/LightApp_PreferencesDlg.cxx --- src/LightApp/LightApp_Application.cxx | 4 +++- src/LightApp/LightApp_Application.h | 1 + src/LightApp/LightApp_Preferences.h | 1 + src/LightApp/LightApp_PreferencesDlg.cxx | 20 +++++++++++--------- src/LightApp/LightApp_PreferencesDlg.h | 3 +++ src/Qtx/QtxResourceMgr.cxx | 4 +++- src/Qtx/QtxResourceMgr.h | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) mode change 100644 => 100755 src/LightApp/LightApp_PreferencesDlg.cxx diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 0e2d4108c..c7d20a8de 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2025,7 +2025,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 598371345..ca125e908 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 old mode 100644 new mode 100755 index e2d29ec6f..87b517871 --- 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,18 +141,19 @@ 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()->workingMode(); + QtxResourceMgr::WorkingMode prev = myPrefs->resourceMgr()->setWorkingMode( QtxResourceMgr::IgnoreUserValues ); myPrefs->resourceMgr()->setWorkingMode( QtxResourceMgr::IgnoreUserValues ); - myPrefs->retrieve(); - myPrefs->resourceMgr()->setWorkingMode( prev ); - } + 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(); diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index d3c2aa098..64931db56 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -1411,9 +1411,11 @@ QtxResourceMgr::WorkingMode QtxResourceMgr::workingMode() const \param mode new working mode \sa workingMode(), value(), hasValue(), hasSection(), setValue() */ -void QtxResourceMgr::setWorkingMode( WorkingMode mode ) +QtxResourceMgr::WorkingMode QtxResourceMgr::setWorkingMode( WorkingMode mode ) { + WorkingMode m = myWorkingMode; myWorkingMode = mode; + return m; } /*! diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 6abab3010..991019660 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -86,7 +86,7 @@ public: void clear(); WorkingMode workingMode() const; - void setWorkingMode( WorkingMode ); + WorkingMode setWorkingMode( WorkingMode ); bool value( const QString&, const QString&, int& ) const; bool value( const QString&, const QString&, double& ) const; -- 2.39.2