+ 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">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -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<PreferencePage*> pages = this->findChildren<PreferencePage*>();
|
||||
for (QList<PreferencePage*>::iterator it = pages.begin(); it != pages.end(); ++it) {
|
||||
(*it)->loadSettings();
|
||||
}
|
||||
#else
|
||||
reject();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void DlgPreferencesImp::applyChanges()
|
||||
|
|
|
@ -133,6 +133,7 @@ private:
|
|||
//@{
|
||||
void setupPages();
|
||||
void applyChanges();
|
||||
void restoreDefaults();
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user