[vlmc-devel] commit: Settings: Adding a "reset" button. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sun Aug 22 22:54:24 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Aug 22 22:10:12 2010 +0200| [4320665387185f3b4618a8d2db24fec515319750] | committer: Hugo Beauzée-Luyssen
Settings: Adding a "reset" button.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=4320665387185f3b4618a8d2db24fec515319750
---
src/Gui/settings/PreferenceWidget.cpp | 8 ++++++++
src/Gui/settings/PreferenceWidget.h | 1 +
src/Gui/settings/Settings.cpp | 17 +++++++++++++++--
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/Gui/settings/PreferenceWidget.cpp b/src/Gui/settings/PreferenceWidget.cpp
index 2735903..d51a2e0 100644
--- a/src/Gui/settings/PreferenceWidget.cpp
+++ b/src/Gui/settings/PreferenceWidget.cpp
@@ -104,6 +104,14 @@ PreferenceWidget::save()
w->save();
}
+void
+PreferenceWidget::reset()
+{
+ foreach ( ISettingsCategoryWidget* w, m_settings )
+ w->setting()->restoreDefault();
+ save();
+}
+
const char*
PreferenceWidget::category() const
{
diff --git a/src/Gui/settings/PreferenceWidget.h b/src/Gui/settings/PreferenceWidget.h
index 39f9263..78ba8f9 100644
--- a/src/Gui/settings/PreferenceWidget.h
+++ b/src/Gui/settings/PreferenceWidget.h
@@ -45,6 +45,7 @@ class PreferenceWidget : public QScrollArea
virtual ~PreferenceWidget() {}
virtual void save();
+ virtual void reset();
const char *category() const;
protected:
void changeEvent( QEvent *e );
diff --git a/src/Gui/settings/Settings.cpp b/src/Gui/settings/Settings.cpp
index ce1a62b..ab98d16 100644
--- a/src/Gui/settings/Settings.cpp
+++ b/src/Gui/settings/Settings.cpp
@@ -30,10 +30,11 @@
#include <QAbstractButton>
#include <QApplication>
+#include <QMessageBox>
#include <QDialogButtonBox>
+#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
-#include <QHBoxLayout>
#include <QStackedLayout>
Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
@@ -46,7 +47,8 @@ Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
m_buttons = new QDialogButtonBox( Qt::Horizontal, this );
m_buttons->setStandardButtons( QDialogButtonBox::Ok |
QDialogButtonBox::Cancel |
- QDialogButtonBox::Apply );
+ QDialogButtonBox::Apply |
+ QDialogButtonBox::Reset );
// Create the layout
buildLayout();
@@ -105,6 +107,17 @@ Settings::buttonClicked( QAbstractButton *button )
{
switch ( m_buttons->standardButton( button ) )
{
+ case QDialogButtonBox::Reset:
+ {
+ if ( QMessageBox::question( NULL, tr( "Restore default?" ),
+ tr( "This will restore all settings default value.\nAre you sure you want to continue?" ),
+ QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Ok )
+ {
+ for ( int i = 0; i < m_stackedLayout->count(); ++i )
+ qobject_cast<PreferenceWidget*>( m_stackedLayout->widget( i ) )->reset();
+ }
+ break ;
+ }
case QDialogButtonBox::Ok:
case QDialogButtonBox::Apply:
{
More information about the Vlmc-devel
mailing list