Skip to content

Commit

Permalink
Reset added to options
Browse files Browse the repository at this point in the history
  • Loading branch information
iamunick committed May 20, 2014
1 parent aa49ca1 commit 9a86f3a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,36 @@
</property>
</spacer>
</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>&amp;Reset Options</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabNetwork">
Expand Down
29 changes: 28 additions & 1 deletion src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void OptionsDialog::setModel(OptionsModel *model)
mapper->toFirst();
}

/* update the display unit, to not use the default ("BTC") */
/* update the display unit, to not use the default ("GRW") */
updateDisplayUnit();

/* warn only when language selection changes by user action (placed here so init via mapper doesn't trigger this) */
Expand Down Expand Up @@ -178,6 +178,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.") + "<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()
{
mapper->submit();
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 18 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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;
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OptionsModel : public QAbstractListModel
};

void Init();
void Reset();

/* Migrate settings from wallet.dat after app initialization */
bool Upgrade(); /* returns true if settings upgraded */
Expand Down

0 comments on commit 9a86f3a

Please sign in to comment.