diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-25 17:46:51 +0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-25 17:46:51 +0800 |
commit | dd96b03d225367fcd527c4df0f5c5362d0aed09a (patch) | |
tree | a1db1285374cd38e8fefc529ea0bb861fb4277ac | |
parent | 81b268d4ba48338b6adda0efd011f58c5e44ed88 (diff) | |
download | subsurface-dd96b03d225367fcd527c4df0f5c5362d0aed09a.tar.gz |
Add ability to reset the settings
This may be a bit crude and it doesn't actually FULLY reset the settings
(as for example the column widths will still be maintained), but it's a
good start, I think.
Fixes #552
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/preferences.cpp | 24 | ||||
-rw-r--r-- | qt-ui/preferences.h | 1 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 51 |
3 files changed, 58 insertions, 18 deletions
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 @@ </widget> </item> <item> - <widget class="QLineEdit" name="default_uid"> - </widget> + <widget class="QLineEdit" name="default_uid"/> </item> <item> <widget class="QCheckBox" name="save_uid_local"> @@ -292,6 +291,22 @@ </widget> </item> <item> + <widget class="QGroupBox" name="groupBox_9"> + <property name="title"> + <string>Clear all settings</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7b"> + <item> + <widget class="QPushButton" name="resetSettings"> + <property name="text"> + <string>Reset all settings to their default value</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -538,7 +553,7 @@ </widget> </item> </layout> - </item> + </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> @@ -670,18 +685,18 @@ </widget> </item> </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11d"> - <item> - <widget class="QCheckBox" name="show_average_depth"> - <property name="text"> - <string>show average depth</string> - </property> - </widget> - </item> - </layout> - </item> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_11d"> + <item> + <widget class="QCheckBox" name="show_average_depth"> + <property name="text"> + <string>show average depth</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> @@ -1086,12 +1101,12 @@ </connection> </connections> <buttongroups> - <buttongroup name="buttonGroup_5"/> - <buttongroup name="buttonGroup_6"/> - <buttongroup name="buttonGroup"/> <buttongroup name="verticalSpeed"/> <buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_3"/> + <buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup_4"/> + <buttongroup name="buttonGroup_5"/> + <buttongroup name="buttonGroup_6"/> </buttongroups> </ui> |