diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 034d1be6f..fe4c87247 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -350,6 +350,30 @@ void PreferencesDialog::on_chooseFile_clicked() ui.defaultfilename->setText(choosenFileName); } +void PreferencesDialog::on_resetSettings_clicked() +{ + QSettings s; + + QMessageBox response(this); + response.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + response.setDefaultButton(QMessageBox::Cancel); + response.setWindowTitle(tr("Warning")); + response.setText(tr("If you click OK, all settings of Subsurface are reset to their default values. This will be applied immediately.")); + response.setWindowModality(Qt::WindowModal); + + int result = response.exec(); + if (result == QMessageBox::Ok) { + prefs = default_prefs; + setUiFromPrefs(); + QStringList keys = s.allKeys(); + Q_FOREACH (QString key, keys) { + s.remove(key); + } + syncSettings(); + close(); + } +} + void PreferencesDialog::emitSettingsChanged() { emit settingsChanged(); diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h index 9c384acd6..474064b10 100644 --- a/qt-ui/preferences.h +++ b/qt-ui/preferences.h @@ -21,6 +21,7 @@ public slots: void buttonClicked(QAbstractButton *button); void on_chooseFile_clicked(); + void on_resetSettings_clicked(); void syncSettings(); void loadSettings(); void restorePrefs(); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index db99ff1fc..37bcb7766 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -278,8 +278,7 @@ - - + @@ -291,6 +290,22 @@ + + + + Clear all settings + + + + + + Reset all settings to their default value + + + + + + @@ -538,7 +553,7 @@ - + @@ -670,18 +685,18 @@ - - - - - - - show average depth - - - - - + + + + + + + show average depth + + + + + @@ -1086,12 +1101,12 @@ - - - + + +