Commit 43206653 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Settings: Adding a "reset" button.

parent 9acf6659
......@@ -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
{
......
......@@ -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 );
......
......@@ -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:
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment