summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 551d7965a..7e2f5c999 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -13,12 +13,22 @@ PreferencesDialog* PreferencesDialog::instance()
#define D(V, P) s.value(#V, default_prefs.P).toDouble()
#define I(V, P) s.value(#V, default_prefs.P).toInt()
-PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
-, ui(new Ui::PreferencesDialog())
+PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f),
+ ui(new Ui::PreferencesDialog())
{
ui->setupUi(this);
- connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(syncSettings()));
- connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(resetSettings()));
+ connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ reloadPrefs();
+}
+
+void PreferencesDialog::showEvent(QShowEvent *event)
+{
+ reloadPrefs();
+ QDialog::showEvent(event);
+}
+
+void PreferencesDialog::reloadPrefs()
+{
oldPrefs = prefs;
@@ -140,8 +150,30 @@ void PreferencesDialog::syncSettings()
s.endGroup();
s.sync();
- oldPrefs = prefs;
emit settingsChanged();
}
+void PreferencesDialog::buttonClicked(QAbstractButton* button)
+{
+ switch(ui->buttonBox->standardButton(button)){
+ case QDialogButtonBox::Discard:
+ prefs = oldPrefs;
+ close();
+ break;
+ case QDialogButtonBox::Apply:
+ syncSettings();
+ emit settingsChanged();
+ break;
+ case QDialogButtonBox::FirstButton:
+ syncSettings();
+ oldPrefs = prefs;
+ emit settingsChanged();
+ close();
+ break;
+ default:
+ break; // ignore warnings.
+ }
+}
+
+
#undef SB