mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Merge pull request #6567 from lemondrops/manager-config-defaults
Manager: Implement defaults for manager config
This commit is contained in:
@@ -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 §ion)
|
||||
{
|
||||
char BUF[256];
|
||||
@@ -36,6 +46,8 @@ VMManagerConfig::VMManagerConfig(const ConfigType type, const QString §ion)
|
||||
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();
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
void sync() const;
|
||||
|
||||
static QVariantHash generalDefaults;
|
||||
|
||||
QSettings *settings;
|
||||
ConfigType config_type;
|
||||
QString system_name;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user