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>
This commit is contained in:
Dirk Hohndel 2014-06-25 17:46:51 +08:00
parent 81b268d4ba
commit dd96b03d22
3 changed files with 58 additions and 18 deletions

View file

@ -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();

View file

@ -21,6 +21,7 @@ public
slots:
void buttonClicked(QAbstractButton *button);
void on_chooseFile_clicked();
void on_resetSettings_clicked();
void syncSettings();
void loadSettings();
void restorePrefs();

View file

@ -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">
@ -291,6 +290,22 @@
</layout>
</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">
@ -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>