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();

View File

@@ -35,6 +35,8 @@ public:
void sync() const;
static QVariantHash generalDefaults;
QSettings *settings;
ConfigType config_type;
QString system_name;

View File

@@ -109,8 +109,6 @@ VMManagerMainWindow::
ui->actionHide_tool_bar->setChecked(!!config->getStringValue("hide_tool_bar").toInt());
if (ui->actionHide_tool_bar->isChecked())
ui->toolBar->setVisible(false);
else
config->setStringValue("hide_tool_bar", "0");
if (!!config->getStringValue("window_remember").toInt()) {
QString coords = config->getStringValue("window_coordinates");
if (!coords.isEmpty()) {

View File

@@ -59,7 +59,6 @@ VMManagerPreferences::
}
ui->comboBoxLanguage->model()->sort(Qt::AscendingOrder);
// TODO: Defaults
#if EMU_BUILD_NUM != 0
const auto configUpdateCheck = config->getStringValue("update_check").toInt();
ui->updateCheckBox->setChecked(configUpdateCheck);