Manager: Implement defaults for manager config

Enable update checker by default
This commit is contained in:
Alexander Babikov
2025-12-17 00:30:29 +05:00
parent 242d272c1a
commit b8d3714edb
4 changed files with 18 additions and 4 deletions

View File

@@ -18,8 +18,18 @@
extern "C" {
#include <86box/plat.h>
#include <86box/version.h>
}
QVariantHash VMManagerConfig::generalDefaults = {
{ "hide_tool_bar", 0 },
{ "regex_search", 0 },
#if EMU_BUILD_NUM != 0
{ "update_check", 1 },
#endif
{ "window_remember", 0 }
};
VMManagerConfig::VMManagerConfig(const ConfigType type, const QString &section)
{
char BUF[256];
@@ -36,6 +46,8 @@ VMManagerConfig::VMManagerConfig(const ConfigType type, const QString &section)
settings->setFallbacksEnabled(false);
if (type == ConfigType::System && !section.isEmpty()) {
settings->beginGroup(section);
} else {
settings->beginGroup("");
}
}
@@ -47,7 +59,10 @@ VMManagerConfig::~VMManagerConfig()
QString
VMManagerConfig::getStringValue(const QString &key) const
{
const auto value = settings->value(key);
auto defaultValue = QVariant();
if ((config_type == ConfigType::General) && (generalDefaults.contains(key)))
defaultValue = generalDefaults[key];
const auto value = settings->value(key, defaultValue);
// An invalid QVariant with toString will give a default QString value which is blank.
// Therefore any variables that do not exist will return blank strings
return value.toString();