fixed custom rtc and rng seed overwriting the global value

This commit is contained in:
lat9nq
2020-06-25 19:28:39 -04:00
parent 59aef94c94
commit f1640df97c
2 changed files with 25 additions and 15 deletions

View File

@@ -698,23 +698,27 @@ void Config::ReadSystemValues() {
bool rng_seed_enabled;
ReadSettingGlobal(rng_seed_enabled, QStringLiteral("rng_seed_enabled"), false);
Settings::values.rng_seed.SetGlobal(
global || qt_config->value(QStringLiteral("rng_seed/use_global"), true).toBool());
if (rng_seed_enabled) {
Settings::values.rng_seed = ReadSetting(QStringLiteral("rng_seed"), 0).toULongLong();
} else {
Settings::values.rng_seed = std::nullopt;
bool rng_seed_global = global || qt_config->value(QStringLiteral("rng_seed/use_global"), true).toBool();
Settings::values.rng_seed.SetGlobal(rng_seed_global);
if (global || !rng_seed_global) {
if (rng_seed_enabled) {
Settings::values.rng_seed = ReadSetting(QStringLiteral("rng_seed"), 0).toULongLong();
} else {
Settings::values.rng_seed = std::nullopt;
}
}
bool custom_rtc_enabled;
ReadSettingGlobal(custom_rtc_enabled, QStringLiteral("custom_rtc_enabled"), false);
Settings::values.custom_rtc.SetGlobal(
global || qt_config->value(QStringLiteral("custom_rtc/use_global"), true).toBool());
if (custom_rtc_enabled) {
Settings::values.custom_rtc =
std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong());
} else {
Settings::values.custom_rtc = std::nullopt;
bool custom_rtc_global = global || qt_config->value(QStringLiteral("custom_rtc/use_global"), true).toBool();
Settings::values.custom_rtc.SetGlobal(custom_rtc_global);
if (global || !custom_rtc_global) {
if (custom_rtc_enabled) {
Settings::values.custom_rtc =
std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong());
} else {
Settings::values.custom_rtc = std::nullopt;
}
}
ReadSettingGlobal(Settings::values.sound_index, QStringLiteral("sound_index"), 1);

View File

@@ -136,7 +136,7 @@ void ConfigureSystem::ApplyConfiguration() {
Settings::values.sound_index = ui->combo_sound->currentIndex();
}
if (!Settings::values.rng_seed.UsingGlobal()) {
if (Settings::values.rng_seed.UsingGlobal()) {
if (ui->rng_seed_checkbox->isChecked()) {
Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16);
} else {
@@ -144,7 +144,7 @@ void ConfigureSystem::ApplyConfiguration() {
}
}
if (!Settings::values.custom_rtc.UsingGlobal()) {
if (Settings::values.custom_rtc.UsingGlobal()) {
if (ui->custom_rtc_checkbox->isChecked()) {
Settings::values.custom_rtc =
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
@@ -170,7 +170,10 @@ void ConfigureSystem::ApplyConfiguration() {
Settings::values.rng_seed = std::nullopt;
break;
case Qt::PartiallyChecked:
Settings::values.rng_seed.SetGlobal(false);
Settings::values.rng_seed = std::nullopt;
Settings::values.rng_seed.SetGlobal(true);
break;
}
switch (ui->custom_rtc_checkbox->checkState()) {
@@ -184,7 +187,10 @@ void ConfigureSystem::ApplyConfiguration() {
Settings::values.custom_rtc = std::nullopt;
break;
case Qt::PartiallyChecked:
Settings::values.custom_rtc.SetGlobal(false);
Settings::values.custom_rtc = std::nullopt;
Settings::values.custom_rtc.SetGlobal(true);
break;
}
}