Skip to content
Snippets Groups Projects
Commit 05c8063a authored by lat9nq's avatar lat9nq
Browse files

config(qt): Fix generic read setting

Previously was not respecting whether the setting was default.
parent 397333b2
No related branches found
No related tags found
No related merge requests found
......@@ -1256,23 +1256,27 @@ void Config::WriteCategory(Settings::Category category) {
}
void Config::ReadSettingGeneric(Settings::BasicSetting* const setting) {
if (!setting->Save()) {
if (!setting->Save() || (!setting->Switchable() && !global)) {
return;
}
const QString name = QString::fromStdString(setting->GetLabel());
const auto default_value =
QVariant::fromValue<QString>(QString::fromStdString(setting->DefaultToString()));
if (setting->Switchable()) {
const bool use_global =
qt_config->value(name + QStringLiteral("/use_global"), true).value<bool>();
bool use_global = true;
if (setting->Switchable() && !global) {
use_global = qt_config->value(name + QStringLiteral("/use_global"), true).value<bool>();
setting->SetGlobal(use_global);
}
if (global || !use_global) {
if (global || !use_global) {
const bool is_default = ReadSetting(name + QStringLiteral("/default"), true).value<bool>();
if (!is_default) {
setting->LoadString(ReadSetting(name, default_value).value<QString>().toStdString());
} else {
// Empty string resets the Setting to default
setting->LoadString("");
}
} else if (global) {
setting->LoadString(ReadSetting(name, default_value).value<QString>().toStdString());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment