[vlmc-devel] commit: Settings: Discard changes when clicking cancel ( =?UTF-8?Q?Hugo=20Beauz=C3=A9e=2DLuyssen?==?UTF-8?Q?=20?=)

git at videolan.org git at videolan.org
Sun Dec 5 21:29:14 CET 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Dec  5 21:27:35 2010 +0100| [353534424758dde460a2c77d877deda63205cbb1] | committer: Hugo Beauzée-Luyssen 

Settings: Discard changes when clicking cancel

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=353534424758dde460a2c77d877deda63205cbb1
---

 src/Gui/settings/ISettingsCategoryWidget.h |    2 +-
 src/Gui/settings/PreferenceWidget.cpp      |    7 +++++++
 src/Gui/settings/PreferenceWidget.h        |    1 +
 src/Gui/settings/Settings.cpp              |    5 +++++
 4 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/Gui/settings/ISettingsCategoryWidget.h b/src/Gui/settings/ISettingsCategoryWidget.h
index 75677e8..325073a 100644
--- a/src/Gui/settings/ISettingsCategoryWidget.h
+++ b/src/Gui/settings/ISettingsCategoryWidget.h
@@ -54,7 +54,7 @@ class   ISettingsCategoryWidget : public QWidget
     protected:
         SettingValue            *m_setting;
 
-    protected slots:
+    public slots:
         virtual void            changed( const QVariant& ) = 0;
 };
 
diff --git a/src/Gui/settings/PreferenceWidget.cpp b/src/Gui/settings/PreferenceWidget.cpp
index a9daaf5..560f1be 100644
--- a/src/Gui/settings/PreferenceWidget.cpp
+++ b/src/Gui/settings/PreferenceWidget.cpp
@@ -116,6 +116,13 @@ PreferenceWidget::reset()
     save();
 }
 
+void
+PreferenceWidget::discard()
+{
+    foreach ( ISettingsCategoryWidget* w, m_settings )
+        w->changed( w->setting()->get() );
+}
+
 const char*
 PreferenceWidget::category() const
 {
diff --git a/src/Gui/settings/PreferenceWidget.h b/src/Gui/settings/PreferenceWidget.h
index aae5035..b1059d6 100644
--- a/src/Gui/settings/PreferenceWidget.h
+++ b/src/Gui/settings/PreferenceWidget.h
@@ -46,6 +46,7 @@ class   PreferenceWidget : public QScrollArea
 
         virtual bool    save();
         virtual void    reset();
+        void            discard();
         const char      *category() const;
     protected:
         void            changeEvent( QEvent *e );
diff --git a/src/Gui/settings/Settings.cpp b/src/Gui/settings/Settings.cpp
index a6035ce..77bfeaf 100644
--- a/src/Gui/settings/Settings.cpp
+++ b/src/Gui/settings/Settings.cpp
@@ -133,6 +133,11 @@ Settings::buttonClicked( QAbstractButton *button )
             if ( m_type == SettingsManager::Vlmc )
                 SettingsManager::getInstance()->save();
         }
+    case QDialogButtonBox::Cancel:
+        {
+            for ( int i = 0; i < m_stackedLayout->count(); ++i )
+                qobject_cast<PreferenceWidget*>( m_stackedLayout->widget( i ) )->discard();
+        }
     default:
         break ;
     }



More information about the Vlmc-devel mailing list