+ fixes #0002106: Add 'Default' option in Preferences
This commit is contained in:
parent
60cd098ae9
commit
a7012575d4
|
@ -88,7 +88,7 @@
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -206,6 +206,40 @@ void DlgPreferencesImp::on_buttonBox_clicked(QAbstractButton* btn)
|
||||||
{
|
{
|
||||||
if (ui->buttonBox->standardButton(btn) == QDialogButtonBox::Apply)
|
if (ui->buttonBox->standardButton(btn) == QDialogButtonBox::Apply)
|
||||||
applyChanges();
|
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<PreferencePage*> pages = this->findChildren<PreferencePage*>();
|
||||||
|
for (QList<PreferencePage*>::iterator it = pages.begin(); it != pages.end(); ++it) {
|
||||||
|
(*it)->loadSettings();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
reject();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgPreferencesImp::applyChanges()
|
void DlgPreferencesImp::applyChanges()
|
||||||
|
|
|
@ -133,6 +133,7 @@ private:
|
||||||
//@{
|
//@{
|
||||||
void setupPages();
|
void setupPages();
|
||||||
void applyChanges();
|
void applyChanges();
|
||||||
|
void restoreDefaults();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user