diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 6a1336197..3771f9de6 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -44,7 +44,7 @@ - + @@ -62,7 +62,7 @@ - + Qt::Horizontal @@ -99,6 +99,36 @@ + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Reset all client options to default. + + + &Reset Options + + + false + + + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 03dcb0b53..6b98ab192 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -177,6 +177,33 @@ void OptionsDialog::setSaveButtonState(bool fState) ui->okButton->setEnabled(fState); } +void OptionsDialog::on_resetButton_clicked() +{ + if(model) + { + // confirmation dialog + QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"), + tr("Some settings may require a client restart to take effect.") + "

" + tr("Do you want to proceed?"), + QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + + if(btnRetVal == QMessageBox::Cancel) + return; + + disableApplyButton(); + + /* disable restart warning messages display */ + fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = true; + + /* reset all options and save the default values (QSettings) */ + model->Reset(); + mapper->toFirst(); + mapper->submit(); + + /* re-enable restart warning messages display */ + fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = false; + } +} + void OptionsDialog::on_okButton_clicked() { mapper->submit(); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 18469f509..d64ed0b57 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -36,6 +36,7 @@ private slots: void disableSaveButtons(); /* set apply button and OK button state (enabled / disabled) */ void setSaveButtonState(bool fState); + void on_resetButton_clicked(); void on_okButton_clicked(); void on_cancelButton_clicked(); void on_applyButton_clicked(); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 5dac5a6c4..2457e3874 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -60,6 +60,24 @@ void OptionsModel::Init() SoftSetArg("-lang", language.toStdString()); } +void OptionsModel::Reset() +{ + QSettings settings; + + // Remove all entries in this QSettings object + settings.clear(); + + // default setting for OptionsModel::StartAtStartup - disabled + if (GUIUtil::GetStartOnSystemStartup()) + GUIUtil::SetStartOnSystemStartup(false); + + // Re-Init to get default values + Init(); + + // Ensure Upgrade() is not running again by setting the bImportFinished flag + settings.setValue("bImportFinished", true); +} + bool OptionsModel::Upgrade() { QSettings settings; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 4f893bb44..d25d898d9 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -33,6 +33,7 @@ public: }; void Init(); + void Reset(); /* Migrate settings from wallet.dat after app initialization */ bool Upgrade(); /* returns true if settings upgraded */