Gui: Move reset logic to PreferencePage

This commit is contained in:
Kacper Donat
2023-11-06 19:16:50 +01:00
parent b277b0b0e8
commit 0a8936644e
4 changed files with 23 additions and 15 deletions

View File

@@ -28,6 +28,7 @@
#endif
#include <Base/Console.h>
#include <App/Application.h>
#include "PropertyPage.h"
#include "PrefWidgets.h"
@@ -209,6 +210,24 @@ void PreferenceUiForm::saveSettings()
savePrefWidgets<Gui::PrefQuantitySpinBox*>();
}
void PreferencePage::resetSettingsToDefaults()
{
auto prefs = this->findChildren<QObject*>();
for (const auto& pref : prefs) {
if (!pref->property("prefPath").isNull() && !pref->property("prefEntry").isNull()) {
std::string path = pref->property("prefPath").toString().toStdString();
std::string entry = pref->property("prefEntry").toString().toStdString();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
std::string("User parameter:BaseApp/Preferences/" + path).c_str());
for (const auto& pn : hGrp->GetParameterNames(entry.c_str())) {
hGrp->RemoveAttribute(pn.first, pn.second.c_str());
}
}
}
}
// ----------------------------------------------------------------
/** Construction */