diff --git a/src/Gui/DlgPreferences.ui b/src/Gui/DlgPreferences.ui index 213932203..acf9bd085 100644 --- a/src/Gui/DlgPreferences.ui +++ b/src/Gui/DlgPreferences.ui @@ -88,7 +88,7 @@ - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Reset diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index d11ad2d32..6f4fa500b 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -206,6 +206,40 @@ void DlgPreferencesImp::on_buttonBox_clicked(QAbstractButton* btn) { if (ui->buttonBox->standardButton(btn) == QDialogButtonBox::Apply) applyChanges(); + else if (ui->buttonBox->standardButton(btn) == QDialogButtonBox::Reset) + restoreDefaults(); +} + +void DlgPreferencesImp::restoreDefaults() +{ + QMessageBox box(this); + box.setIcon(QMessageBox::Question); + box.setWindowTitle(tr("Clear user settings")); + box.setText(tr("Do you want to clear all your user settings?")); + box.setInformativeText(tr("If you agree all your settings will be cleared.")); + box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + box.setDefaultButton(QMessageBox::No); + + if (box.exec() == QMessageBox::Yes) { + // keep this parameter + bool saveParameter = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> + GetBool("SaveUserParameter", true); + + ParameterManager* mgr = App::GetApplication().GetParameterSet("User parameter"); + mgr->Clear(); + + App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> + SetBool("SaveUserParameter", saveParameter); + +#if 0 + QList pages = this->findChildren(); + for (QList::iterator it = pages.begin(); it != pages.end(); ++it) { + (*it)->loadSettings(); + } +#else + reject(); +#endif + } } void DlgPreferencesImp::applyChanges() diff --git a/src/Gui/DlgPreferencesImp.h b/src/Gui/DlgPreferencesImp.h index 5757daf6f..39fbfc1fc 100644 --- a/src/Gui/DlgPreferencesImp.h +++ b/src/Gui/DlgPreferencesImp.h @@ -133,6 +133,7 @@ private: //@{ void setupPages(); void applyChanges(); + void restoreDefaults(); //@} private: