Bitcoin-Qt: add a Reset button to the options dialog
- a click on "Reset Options" sets all options to the default values by removing all stored settings (QSettings), loading the defaults and saving them as the new settings - before the reset is executed the user is presented a confirmation dialog - special casing was needed for StartAtStartup
This commit is contained in:
parent
ea9788517b
commit
5fb445b49e
5 changed files with 79 additions and 2 deletions
|
@ -44,7 +44,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_Main">
|
<layout class="QHBoxLayout" name="horizontalLayout_1_Main">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="transactionFeeLabel">
|
<widget class="QLabel" name="transactionFeeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
<widget class="BitcoinAmountField" name="transactionFee"/>
|
<widget class="BitcoinAmountField" name="transactionFee"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_Main">
|
<spacer name="horizontalSpacer_1_Main">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -99,6 +99,36 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2_Main">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2_Main">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="resetButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Reset all client options to default.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Reset Options</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tabNetwork">
|
<widget class="QWidget" name="tabNetwork">
|
||||||
|
|
|
@ -177,6 +177,33 @@ void OptionsDialog::setSaveButtonState(bool fState)
|
||||||
ui->okButton->setEnabled(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.") + "<br><br>" + 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()
|
void OptionsDialog::on_okButton_clicked()
|
||||||
{
|
{
|
||||||
mapper->submit();
|
mapper->submit();
|
||||||
|
|
|
@ -36,6 +36,7 @@ private slots:
|
||||||
void disableSaveButtons();
|
void disableSaveButtons();
|
||||||
/* set apply button and OK button state (enabled / disabled) */
|
/* set apply button and OK button state (enabled / disabled) */
|
||||||
void setSaveButtonState(bool fState);
|
void setSaveButtonState(bool fState);
|
||||||
|
void on_resetButton_clicked();
|
||||||
void on_okButton_clicked();
|
void on_okButton_clicked();
|
||||||
void on_cancelButton_clicked();
|
void on_cancelButton_clicked();
|
||||||
void on_applyButton_clicked();
|
void on_applyButton_clicked();
|
||||||
|
|
|
@ -60,6 +60,24 @@ void OptionsModel::Init()
|
||||||
SoftSetArg("-lang", language.toStdString());
|
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()
|
bool OptionsModel::Upgrade()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
/* Migrate settings from wallet.dat after app initialization */
|
/* Migrate settings from wallet.dat after app initialization */
|
||||||
bool Upgrade(); /* returns true if settings upgraded */
|
bool Upgrade(); /* returns true if settings upgraded */
|
||||||
|
|
Loading…
Reference in a new issue