mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
Qt: Replace QtSettingsInterface with INISettingsInterface
This commit is contained in:
parent
9b2740b395
commit
4e2b3189b0
|
@ -47,8 +47,6 @@ add_executable(duckstation-qt
|
|||
qthostinterface.h
|
||||
qtprogresscallback.cpp
|
||||
qtprogresscallback.h
|
||||
qtsettingsinterface.cpp
|
||||
qtsettingsinterface.h
|
||||
qtutils.cpp
|
||||
qtutils.h
|
||||
settingsdialog.cpp
|
||||
|
|
|
@ -9,25 +9,29 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QtHostInterface* host_interface,
|
|||
for (u32 i = 0; i < static_cast<u32>(LOGLEVEL_COUNT); i++)
|
||||
m_ui.logLevel->addItem(tr(Settings::GetLogLevelDisplayName(static_cast<LOGLEVEL>(i))));
|
||||
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.logLevel, QStringLiteral("Logging/LogLevel"),
|
||||
&Settings::ParseLogLevelName, &Settings::GetLogLevelName,
|
||||
Settings::DEFAULT_LOG_LEVEL);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.logFilter, QStringLiteral("Logging/LogFilter"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToConsole,
|
||||
QStringLiteral("Logging/LogToConsole"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToDebug, QStringLiteral("Logging/LogToDebug"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToWindow,
|
||||
QStringLiteral("Logging/LogToWindow"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToFile, QStringLiteral("Logging/LogToFile"));
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.logLevel, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogLevel"), &Settings::ParseLogLevelName,
|
||||
&Settings::GetLogLevelName, Settings::DEFAULT_LOG_LEVEL);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.logFilter, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogFilter"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToConsole, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogToConsole"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToDebug, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogToDebug"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToWindow, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogToWindow"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToFile, QStringLiteral("Logging"),
|
||||
QStringLiteral("LogToFile"));
|
||||
|
||||
// Tweaks/Hacks section
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaMaxSliceTicks,
|
||||
QStringLiteral("Hacks/DMAMaxSliceTicks"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaHaltTicks,
|
||||
QStringLiteral("Hacks/DMAHaltTicks"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuFIFOSize, QStringLiteral("Hacks/GPUFIFOSize"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuMaxRunAhead,
|
||||
QStringLiteral("Hacks/GPUMaxRunAhead"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaMaxSliceTicks, QStringLiteral("Hacks"),
|
||||
QStringLiteral("DMAMaxSliceTicks"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaHaltTicks, QStringLiteral("Hacks"),
|
||||
QStringLiteral("DMAHaltTicks"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuFIFOSize, QStringLiteral("Hacks"),
|
||||
QStringLiteral("GPUFIFOSize"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuMaxRunAhead, QStringLiteral("Hacks"),
|
||||
QStringLiteral("GPUMaxRunAhead"));
|
||||
|
||||
connect(m_ui.resetToDefaultButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::onResetToDefaultClicked);
|
||||
}
|
||||
|
|
|
@ -11,14 +11,19 @@ AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidge
|
|||
for (u32 i = 0; i < static_cast<u32>(AudioBackend::Count); i++)
|
||||
m_ui.audioBackend->addItem(tr(Settings::GetAudioBackendDisplayName(static_cast<AudioBackend>(i))));
|
||||
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.audioBackend, "Audio/Backend",
|
||||
&Settings::ParseAudioBackend, &Settings::GetAudioBackendName,
|
||||
Settings::DEFAULT_AUDIO_BACKEND);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToOutput, "Audio/Sync");
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.bufferSize, "Audio/BufferSize");
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.volume, "Audio/OutputVolume");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.muted, "Audio/OutputMuted");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, "Audio/DumpOnBoot");
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.audioBackend, QStringLiteral("Audio"),
|
||||
QStringLiteral("Backend"), &Settings::ParseAudioBackend,
|
||||
&Settings::GetAudioBackendName, Settings::DEFAULT_AUDIO_BACKEND);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToOutput, QStringLiteral("Audio"),
|
||||
QStringLiteral("Sync"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.bufferSize, QStringLiteral("Audio"),
|
||||
QStringLiteral("BufferSize"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.volume, QStringLiteral("Audio"),
|
||||
QStringLiteral("OutputVolume"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.muted, QStringLiteral("Audio"),
|
||||
QStringLiteral("OutputMuted"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, QStringLiteral("Audio"),
|
||||
QStringLiteral("DumpOnBoot"));
|
||||
|
||||
connect(m_ui.bufferSize, &QSlider::valueChanged, this, &AudioSettingsWidget::updateBufferingLabel);
|
||||
connect(m_ui.volume, &QSlider::valueChanged, this, &AudioSettingsWidget::updateVolumeLabel);
|
||||
|
|
|
@ -15,17 +15,22 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
|
|||
for (u32 i = 0; i < static_cast<u32>(CPUExecutionMode::Count); i++)
|
||||
m_ui.cpuExecutionMode->addItem(tr(Settings::GetCPUExecutionModeDisplayName(static_cast<CPUExecutionMode>(i))));
|
||||
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console/Region",
|
||||
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName,
|
||||
Settings::DEFAULT_CONSOLE_REGION);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableTTYOutput, "BIOS/PatchTTYEnable");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot");
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode",
|
||||
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName,
|
||||
Settings::DEFAULT_CPU_EXECUTION_MODE);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromReadThread, "CDROM/ReadThread");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromRegionCheck, "CDROM/RegionCheck");
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, QStringLiteral("Console"),
|
||||
QStringLiteral("Region"), &Settings::ParseConsoleRegionName,
|
||||
&Settings::GetConsoleRegionName, Settings::DEFAULT_CONSOLE_REGION);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, QStringLiteral("BIOS"),
|
||||
QStringLiteral("Path"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableTTYOutput, QStringLiteral("BIOS"),
|
||||
QStringLiteral("PatchTTYEnable"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, QStringLiteral("BIOS"),
|
||||
QStringLiteral("PatchFastBoot"));
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(
|
||||
m_host_interface, m_ui.cpuExecutionMode, QStringLiteral("CPU"), QStringLiteral("ExecutionMode"),
|
||||
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName, Settings::DEFAULT_CPU_EXECUTION_MODE);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromReadThread, QStringLiteral("CDROM"),
|
||||
QStringLiteral("ReadThread"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromRegionCheck, QStringLiteral("CDROM"),
|
||||
QStringLiteral("RegionCheck"));
|
||||
|
||||
connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked);
|
||||
}
|
||||
|
@ -40,6 +45,6 @@ void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked()
|
|||
|
||||
m_ui.biosPath->setText(path);
|
||||
|
||||
m_host_interface->putSettingValue("BIOS/Path", path);
|
||||
m_host_interface->putSettingValue(QStringLiteral("BIOS"), QStringLiteral("Path"), path);
|
||||
m_host_interface->applySettings();
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ void ControllerSettingsWidget::onProfileLoaded()
|
|||
for (int i = 0; i < static_cast<int>(m_port_ui.size()); i++)
|
||||
{
|
||||
ControllerType ctype = Settings::ParseControllerTypeName(
|
||||
m_host_interface->getSettingValue(QStringLiteral("Controller%1/Type").arg(i + 1))
|
||||
.toString()
|
||||
.toStdString()
|
||||
m_host_interface
|
||||
->GetSettingValue(QStringLiteral("Controller%1").arg(i + 1).toStdString().c_str(),
|
||||
QStringLiteral("Type").toStdString().c_str())
|
||||
.c_str())
|
||||
.value_or(ControllerType::None);
|
||||
|
||||
|
@ -88,9 +88,9 @@ void ControllerSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* u
|
|||
QString::fromUtf8(Settings::GetControllerTypeDisplayName(static_cast<ControllerType>(i))));
|
||||
}
|
||||
ControllerType ctype = Settings::ParseControllerTypeName(
|
||||
m_host_interface->getSettingValue(QStringLiteral("Controller%1/Type").arg(index + 1))
|
||||
.toString()
|
||||
.toStdString()
|
||||
m_host_interface
|
||||
->GetSettingValue(QStringLiteral("Controller%1").arg(index + 1).toStdString().c_str(),
|
||||
QStringLiteral("Type").toStdString().c_str())
|
||||
.c_str())
|
||||
.value_or(ControllerType::None);
|
||||
ui->controller_type->setCurrentIndex(static_cast<int>(ctype));
|
||||
|
@ -195,10 +195,11 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
}
|
||||
|
||||
const QString button_name_q = QString::fromStdString(button_name);
|
||||
const QString setting_name = QStringLiteral("Controller%1/Button%2").arg(index + 1).arg(button_name_q);
|
||||
const QString section_name = QStringLiteral("Controller%1").arg(index + 1);
|
||||
const QString key_name = QStringLiteral("Button%1").arg(button_name_q);
|
||||
QLabel* label = new QLabel(button_name_q, ui->bindings_container);
|
||||
InputButtonBindingWidget* button =
|
||||
new InputButtonBindingWidget(m_host_interface, setting_name, ui->bindings_container);
|
||||
new InputButtonBindingWidget(m_host_interface, section_name, key_name, ui->bindings_container);
|
||||
layout->addWidget(label, start_row + current_row, current_column);
|
||||
layout->addWidget(button, start_row + current_row, current_column + 1);
|
||||
|
||||
|
@ -232,10 +233,11 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
}
|
||||
|
||||
const QString axis_name_q = QString::fromStdString(axis_name);
|
||||
const QString setting_name = QStringLiteral("Controller%1/Axis%2").arg(index + 1).arg(axis_name_q);
|
||||
const QString section_name = QStringLiteral("Controller%1").arg(index + 1);
|
||||
const QString key_name = QStringLiteral("Axis%1").arg(axis_name_q);
|
||||
QLabel* label = new QLabel(axis_name_q, ui->bindings_container);
|
||||
InputAxisBindingWidget* button =
|
||||
new InputAxisBindingWidget(m_host_interface, setting_name, ui->bindings_container);
|
||||
new InputAxisBindingWidget(m_host_interface, section_name, key_name, ui->bindings_container);
|
||||
layout->addWidget(label, start_row + current_row, current_column);
|
||||
layout->addWidget(button, start_row + current_row, current_column + 1);
|
||||
|
||||
|
@ -256,10 +258,11 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
{
|
||||
layout->addWidget(QtUtils::CreateHorizontalLine(ui->widget), start_row++, 0, 1, 4);
|
||||
|
||||
const QString setting_name = QStringLiteral("Controller%1/Rumble").arg(index + 1);
|
||||
const QString section_name = QStringLiteral("Controller%1").arg(index + 1);
|
||||
const QString key_name = QStringLiteral("Rumble");
|
||||
QLabel* label = new QLabel(tr("Rumble"), ui->bindings_container);
|
||||
InputRumbleBindingWidget* button =
|
||||
new InputRumbleBindingWidget(m_host_interface, setting_name, ui->bindings_container);
|
||||
new InputRumbleBindingWidget(m_host_interface, section_name, key_name, ui->bindings_container);
|
||||
|
||||
layout->addWidget(label, start_row, 0);
|
||||
layout->addWidget(button, start_row, 1);
|
||||
|
@ -280,7 +283,8 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
|
||||
for (const SettingInfo& si : settings)
|
||||
{
|
||||
const QString setting_name = QStringLiteral("Controller%1/%2").arg(index + 1).arg(si.key);
|
||||
const QString section_name = QStringLiteral("Controller%1").arg(index + 1);
|
||||
const QString key_name = QStringLiteral("%1").arg(si.key);
|
||||
const QString setting_tooltip = si.description ? QString::fromUtf8(si.description) : "";
|
||||
|
||||
switch (si.type)
|
||||
|
@ -289,7 +293,8 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
{
|
||||
QCheckBox* cb = new QCheckBox(tr(si.visible_name), ui->bindings_container);
|
||||
cb->setToolTip(setting_tooltip);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, cb, setting_name, si.BooleanDefaultValue());
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, cb, section_name, key_name,
|
||||
si.BooleanDefaultValue());
|
||||
layout->addWidget(cb, start_row, 0, 1, 4);
|
||||
start_row++;
|
||||
}
|
||||
|
@ -302,7 +307,8 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
sb->setMinimum(si.IntegerMinValue());
|
||||
sb->setMaximum(si.IntegerMaxValue());
|
||||
sb->setSingleStep(si.IntegerStepValue());
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, sb, setting_name, si.IntegerDefaultValue());
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, sb, section_name, key_name,
|
||||
si.IntegerDefaultValue());
|
||||
layout->addWidget(new QLabel(tr(si.visible_name), ui->bindings_container), start_row, 0);
|
||||
layout->addWidget(sb, start_row, 1, 1, 3);
|
||||
start_row++;
|
||||
|
@ -316,7 +322,8 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
sb->setMinimum(si.FloatMinValue());
|
||||
sb->setMaximum(si.FloatMaxValue());
|
||||
sb->setSingleStep(si.FloatStepValue());
|
||||
SettingWidgetBinder::BindWidgetToFloatSetting(m_host_interface, sb, setting_name, si.FloatDefaultValue());
|
||||
SettingWidgetBinder::BindWidgetToFloatSetting(m_host_interface, sb, section_name, key_name,
|
||||
si.FloatDefaultValue());
|
||||
layout->addWidget(new QLabel(tr(si.visible_name), ui->bindings_container), start_row, 0);
|
||||
layout->addWidget(sb, start_row, 1, 1, 3);
|
||||
start_row++;
|
||||
|
@ -327,7 +334,7 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
{
|
||||
QLineEdit* le = new QLineEdit(ui->bindings_container);
|
||||
le->setToolTip(setting_tooltip);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, le, setting_name,
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, le, section_name, key_name,
|
||||
QString::fromUtf8(si.StringDefaultValue()));
|
||||
layout->addWidget(new QLabel(tr(si.visible_name), ui->bindings_container), start_row, 0);
|
||||
layout->addWidget(le, start_row, 1, 1, 3);
|
||||
|
@ -340,9 +347,9 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
|||
QLineEdit* le = new QLineEdit(ui->bindings_container);
|
||||
le->setToolTip(setting_tooltip);
|
||||
QPushButton* browse_button = new QPushButton(tr("Browse..."), ui->bindings_container);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, le, setting_name,
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, le, section_name, key_name,
|
||||
QString::fromUtf8(si.StringDefaultValue()));
|
||||
connect(browse_button, &QPushButton::clicked, [this, index, le, setting_name]() {
|
||||
connect(browse_button, &QPushButton::clicked, [this, le]() {
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select File"));
|
||||
if (!path.isEmpty())
|
||||
le->setText(path);
|
||||
|
@ -376,8 +383,9 @@ void ControllerSettingsWidget::onControllerTypeChanged(int index)
|
|||
return;
|
||||
|
||||
m_host_interface->putSettingValue(
|
||||
QStringLiteral("Controller%1/Type").arg(index + 1),
|
||||
QStringLiteral("Controller%1").arg(index + 1), QStringLiteral("Type"),
|
||||
QString::fromStdString(Settings::GetControllerTypeName(static_cast<ControllerType>(type_index))));
|
||||
|
||||
m_host_interface->applySettings();
|
||||
createPortBindingSettingsUi(index, &m_port_ui[index], static_cast<ControllerType>(type_index));
|
||||
}
|
||||
|
|
|
@ -154,13 +154,13 @@ public:
|
|||
|
||||
void loadFromSettings()
|
||||
{
|
||||
QStringList path_list = m_host_interface->getSettingValue(QStringLiteral("GameList/Paths")).toStringList();
|
||||
for (QString& entry : path_list)
|
||||
m_entries.push_back({std::move(entry), false});
|
||||
std::vector<std::string> path_list = m_host_interface->GetStringList("GameList", "Paths");
|
||||
for (std::string& entry : path_list)
|
||||
m_entries.push_back({QString::fromStdString(entry), false});
|
||||
|
||||
path_list = m_host_interface->getSettingValue(QStringLiteral("GameList/RecursivePaths")).toStringList();
|
||||
for (QString& entry : path_list)
|
||||
m_entries.push_back({std::move(entry), true});
|
||||
path_list = m_host_interface->GetStringList("GameList", "RecursivePaths");
|
||||
for (std::string& entry : path_list)
|
||||
m_entries.push_back({QString::fromStdString(entry), true});
|
||||
}
|
||||
|
||||
void saveToSettings()
|
||||
|
@ -177,14 +177,14 @@ public:
|
|||
}
|
||||
|
||||
if (paths.empty())
|
||||
m_host_interface->removeSettingValue(QStringLiteral("GameList/Paths"));
|
||||
m_host_interface->removeSettingValue("GameList", "Paths");
|
||||
else
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameList/Paths"), paths);
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameList"), QStringLiteral("Paths"), paths);
|
||||
|
||||
if (recursive_paths.empty())
|
||||
m_host_interface->removeSettingValue(QStringLiteral("GameList/RecursivePaths"));
|
||||
m_host_interface->removeSettingValue("GameList", "RecursivePaths");
|
||||
else
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameList/RecursivePaths"), recursive_paths);
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameList"), QStringLiteral("RecursivePaths"), recursive_paths);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -380,7 +380,7 @@ void GameListWidget::resizeTableViewColumnsToFit()
|
|||
|
||||
static QString getColumnVisibilitySettingsKeyName(int column)
|
||||
{
|
||||
return QStringLiteral("GameListTableView/Show%1").arg(GameListModel::s_column_names[column]);
|
||||
return QStringLiteral("Show%1").arg(GameListModel::s_column_names[column]);
|
||||
}
|
||||
|
||||
void GameListWidget::loadTableViewColumnVisibilitySettings()
|
||||
|
@ -390,9 +390,9 @@ void GameListWidget::loadTableViewColumnVisibilitySettings()
|
|||
|
||||
for (int column = 0; column < GameListModel::Column_Count; column++)
|
||||
{
|
||||
const bool visible =
|
||||
m_host_interface->getSettingValue(getColumnVisibilitySettingsKeyName(column), DEFAULT_VISIBILITY[column])
|
||||
.toBool();
|
||||
const bool visible = m_host_interface->GetBooleanSettingValue(
|
||||
"GameListTableView", getColumnVisibilitySettingsKeyName(column).toStdString().c_str(),
|
||||
DEFAULT_VISIBILITY[column]);
|
||||
m_table_view->setColumnHidden(column, !visible);
|
||||
}
|
||||
}
|
||||
|
@ -402,14 +402,14 @@ void GameListWidget::saveTableViewColumnVisibilitySettings()
|
|||
for (int column = 0; column < GameListModel::Column_Count; column++)
|
||||
{
|
||||
const bool visible = !m_table_view->isColumnHidden(column);
|
||||
m_host_interface->putSettingValue(getColumnVisibilitySettingsKeyName(column), visible);
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView"), getColumnVisibilitySettingsKeyName(column), visible);
|
||||
}
|
||||
}
|
||||
|
||||
void GameListWidget::saveTableViewColumnVisibilitySettings(int column)
|
||||
{
|
||||
const bool visible = !m_table_view->isColumnHidden(column);
|
||||
m_host_interface->putSettingValue(getColumnVisibilitySettingsKeyName(column), visible);
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView"), getColumnVisibilitySettingsKeyName(column), visible);
|
||||
}
|
||||
|
||||
void GameListWidget::loadTableViewColumnSortSettings()
|
||||
|
@ -418,12 +418,10 @@ void GameListWidget::loadTableViewColumnSortSettings()
|
|||
const bool DEFAULT_SORT_DESCENDING = false;
|
||||
|
||||
const GameListModel::Column sort_column =
|
||||
GameListModel::getColumnIdForName(
|
||||
m_host_interface->getSettingValue(QStringLiteral("GameListTableView/SortColumn")).toString().toStdString())
|
||||
GameListModel::getColumnIdForName(m_host_interface->GetSettingValue("GameListTableView", "SortColumn"))
|
||||
.value_or(DEFAULT_SORT_COLUMN);
|
||||
const bool sort_descending =
|
||||
m_host_interface->getSettingValue(QStringLiteral("GameListTableView/SortDescending"), DEFAULT_SORT_DESCENDING)
|
||||
.toBool();
|
||||
m_host_interface->GetBooleanSettingValue("GameListTableView", "SortDescending", DEFAULT_SORT_DESCENDING);
|
||||
m_table_sort_model->sort(sort_column, sort_descending ? Qt::DescendingOrder : Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
|
@ -434,11 +432,11 @@ void GameListWidget::saveTableViewColumnSortSettings()
|
|||
|
||||
if (sort_column >= 0 && sort_column < GameListModel::Column_Count)
|
||||
{
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView/SortColumn"),
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView"), QStringLiteral("SortColumn"),
|
||||
QString::fromUtf8(GameListModel::s_column_names[sort_column]));
|
||||
}
|
||||
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView/SortDescending"), sort_descending);
|
||||
m_host_interface->putSettingValue(QStringLiteral("GameListTableView"), QStringLiteral("SortDescending"), sort_descending);
|
||||
}
|
||||
|
||||
const GameListEntry* GameListWidget::getSelectedEntry() const
|
||||
|
|
|
@ -7,23 +7,33 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
|
|||
{
|
||||
m_ui.setupUi(this);
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "Main/StartPaused");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, "Main/StartFullscreen");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.renderToMain, "Main/RenderToMainWindow");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "Main/SaveStateOnExit");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "Main/ConfirmPowerOff");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.loadDevicesFromSaveStates,
|
||||
"Main/LoadDevicesFromSaveStates");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showOSDMessages, "Display/ShowOSDMessages");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showFPS, "Display/ShowFPS");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showVPS, "Display/ShowVPS");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showSpeed, "Display/ShowSpeed");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, QStringLiteral("Main"),
|
||||
QStringLiteral("StartPaused"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, QStringLiteral("Main"),
|
||||
QStringLiteral("StartFullscreen"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.renderToMain, QStringLiteral("Main"),
|
||||
QStringLiteral("RenderToMainWindow"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, QStringLiteral("Main"),
|
||||
QStringLiteral("SaveStateOnExit"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, QStringLiteral("Main"),
|
||||
QStringLiteral("ConfirmPowerOff"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.loadDevicesFromSaveStates, QStringLiteral("Main"),
|
||||
QStringLiteral("LoadDevicesFromSaveStates"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showOSDMessages, QStringLiteral("Display"),
|
||||
QStringLiteral("ShowOSDMessages"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showFPS, QStringLiteral("Display"),
|
||||
QStringLiteral("ShowFPS"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showVPS, QStringLiteral("Display"),
|
||||
QStringLiteral("ShowVPS"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showSpeed, QStringLiteral("Display"),
|
||||
QStringLiteral("ShowSpeed"));
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "Main/SpeedLimiterEnabled");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.increaseTimerResolution,
|
||||
"Main/IncreaseTimerResolution");
|
||||
SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, "Main/EmulationSpeed",
|
||||
100.0f);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, QStringLiteral("Main"),
|
||||
QStringLiteral("SpeedLimiterEnabled"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.increaseTimerResolution, QStringLiteral("Main"),
|
||||
QStringLiteral("IncreaseTimerResolution"));
|
||||
SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, QStringLiteral("Main"),
|
||||
QStringLiteral("EmulationSpeed"), 100.0f);
|
||||
|
||||
connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this,
|
||||
&GeneralSettingsWidget::onEnableSpeedLimiterStateChanged);
|
||||
|
@ -75,8 +85,8 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
|
|||
#ifdef WITH_DISCORD_PRESENCE
|
||||
{
|
||||
QCheckBox* enableDiscordPresence = new QCheckBox(tr("Enable Discord Presence"), m_ui.groupBox_4);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, enableDiscordPresence,
|
||||
QStringLiteral("Main/EnableDiscordPresence"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, enableDiscordPresence, QStringLiteral("Main"),
|
||||
QStringLiteral("EnableDiscordPresence"));
|
||||
m_ui.formLayout_4->addWidget(enableDiscordPresence, m_ui.formLayout_4->rowCount(), 0);
|
||||
dialog->registerWidgetHelp(enableDiscordPresence, "Enable Discord Presence", "Unchecked",
|
||||
"Shows the game you are currently playing as part of your profile in Discord.");
|
||||
|
|
|
@ -16,33 +16,35 @@ GPUSettingsWidget::GPUSettingsWidget(QtHostInterface* host_interface, QWidget* p
|
|||
m_ui.setupUi(this);
|
||||
setupAdditionalUi();
|
||||
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.renderer, QStringLiteral("GPU/Renderer"),
|
||||
&Settings::ParseRendererName, &Settings::GetRendererName,
|
||||
Settings::DEFAULT_GPU_RENDERER);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.useDebugDevice,
|
||||
QStringLiteral("GPU/UseDebugDevice"));
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.renderer, QStringLiteral("GPU"),
|
||||
QStringLiteral("Renderer"), &Settings::ParseRendererName,
|
||||
&Settings::GetRendererName, Settings::DEFAULT_GPU_RENDERER);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.useDebugDevice, QStringLiteral("GPU"),
|
||||
QStringLiteral("UseDebugDevice"));
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(
|
||||
m_host_interface, m_ui.displayAspectRatio, QStringLiteral("Display/AspectRatio"),
|
||||
m_host_interface, m_ui.displayAspectRatio, QStringLiteral("Display"), QStringLiteral("AspectRatio"),
|
||||
&Settings::ParseDisplayAspectRatio, &Settings::GetDisplayAspectRatioName, Settings::DEFAULT_DISPLAY_ASPECT_RATIO);
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.displayCropMode,
|
||||
QStringLiteral("Display/CropMode"), &Settings::ParseDisplayCropMode,
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.displayCropMode, QStringLiteral("Display"),
|
||||
QStringLiteral("CropMode"), &Settings::ParseDisplayCropMode,
|
||||
&Settings::GetDisplayCropModeName, Settings::DEFAULT_DISPLAY_CROP_MODE);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayLinearFiltering,
|
||||
QStringLiteral("Display/LinearFiltering"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayIntegerScaling,
|
||||
QStringLiteral("Display/IntegerScaling"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, QStringLiteral("Display/VSync"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.resolutionScale,
|
||||
QStringLiteral("GPU/ResolutionScale"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.trueColor, QStringLiteral("GPU/TrueColor"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.scaledDithering,
|
||||
QStringLiteral("GPU/ScaledDithering"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.disableInterlacing,
|
||||
QStringLiteral("GPU/DisableInterlacing"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.forceNTSCTimings,
|
||||
QStringLiteral("GPU/ForceNTSCTimings"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.linearTextureFiltering,
|
||||
QStringLiteral("GPU/TextureFiltering"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayLinearFiltering, QStringLiteral("Display"),
|
||||
QStringLiteral("LinearFiltering"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayIntegerScaling, QStringLiteral("Display"),
|
||||
QStringLiteral("IntegerScaling"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, QStringLiteral("Display"),
|
||||
QStringLiteral("VSync"));
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.resolutionScale, QStringLiteral("GPU"),
|
||||
QStringLiteral("ResolutionScale"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.trueColor, QStringLiteral("GPU"),
|
||||
QStringLiteral("TrueColor"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.scaledDithering, QStringLiteral("GPU"),
|
||||
QStringLiteral("ScaledDithering"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.disableInterlacing, QStringLiteral("GPU"),
|
||||
QStringLiteral("DisableInterlacing"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.forceNTSCTimings, QStringLiteral("GPU"),
|
||||
QStringLiteral("ForceNTSCTimings"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.linearTextureFiltering, QStringLiteral("GPU"),
|
||||
QStringLiteral("TextureFiltering"));
|
||||
|
||||
connect(m_ui.resolutionScale, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&GPUSettingsWidget::updateScaledDitheringEnabled);
|
||||
|
@ -166,7 +168,8 @@ void GPUSettingsWidget::populateGPUAdapters()
|
|||
break;
|
||||
}
|
||||
|
||||
QString current_value = m_host_interface->getSettingValue(QStringLiteral("GPU/Adapter")).toString();
|
||||
QString current_value = QString::fromStdString(m_host_interface->GetSettingValue("GPU", "Adapter"));
|
||||
|
||||
QSignalBlocker blocker(m_ui.adapter);
|
||||
|
||||
// add the default entry - we'll fall back to this if the GPU no longer exists, or there's no options
|
||||
|
@ -192,9 +195,9 @@ void GPUSettingsWidget::onGPUAdapterIndexChanged()
|
|||
if (m_ui.adapter->currentIndex() == 0)
|
||||
{
|
||||
// default
|
||||
m_host_interface->removeSettingValue(QStringLiteral("GPU/Adapter"));
|
||||
m_host_interface->removeSettingValue("GPU", "Adapter");
|
||||
return;
|
||||
}
|
||||
|
||||
m_host_interface->putSettingValue(QStringLiteral("GPU/Adapter"), m_ui.adapter->currentText());
|
||||
m_host_interface->putSettingValue(QStringLiteral("GPU"), QStringLiteral("Adapter"), m_ui.adapter->currentText());
|
||||
}
|
||||
|
|
|
@ -61,8 +61,9 @@ void HotkeySettingsWidget::createButtons()
|
|||
QGridLayout* layout = iter->layout;
|
||||
const int target_row = layout->count() / 2;
|
||||
|
||||
const QString setting_name = QStringLiteral("Hotkeys/%1").arg(hi.name.GetCharArray());
|
||||
const QString section_name = QStringLiteral("Hotkeys");
|
||||
const QString key_name = QStringLiteral("%1").arg(hi.name.GetCharArray());
|
||||
layout->addWidget(new QLabel(QString::fromUtf8(hi.display_name), container), target_row, 0);
|
||||
layout->addWidget(new InputButtonBindingWidget(m_host_interface, setting_name, container), target_row, 1);
|
||||
layout->addWidget(new InputButtonBindingWidget(m_host_interface, section_name, key_name, container), target_row, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,13 @@
|
|||
#include <QtGui/QMouseEvent>
|
||||
#include <cmath>
|
||||
|
||||
InputBindingWidget::InputBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent)
|
||||
: QPushButton(parent), m_host_interface(host_interface), m_setting_name(std::move(setting_name))
|
||||
InputBindingWidget::InputBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name,
|
||||
QWidget* parent)
|
||||
: QPushButton(parent), m_host_interface(host_interface),
|
||||
m_section_name(std::move(section_name)), m_key_name(std::move(key_name))
|
||||
{
|
||||
m_current_binding_value = m_host_interface->getSettingValue(m_setting_name).toString();
|
||||
m_current_binding_value = QString::fromStdString(
|
||||
m_host_interface->GetSettingValue(m_section_name.toStdString().c_str(), m_key_name.toStdString().c_str()));
|
||||
setText(m_current_binding_value);
|
||||
setMinimumWidth(150);
|
||||
setMaximumWidth(150);
|
||||
|
@ -63,7 +66,7 @@ void InputBindingWidget::setNewBinding()
|
|||
if (m_new_binding_value.isEmpty())
|
||||
return;
|
||||
|
||||
m_host_interface->putSettingValue(m_setting_name, m_new_binding_value);
|
||||
m_host_interface->putSettingValue(m_section_name, m_key_name, m_new_binding_value);
|
||||
m_host_interface->updateInputMap();
|
||||
|
||||
m_current_binding_value = std::move(m_new_binding_value);
|
||||
|
@ -73,14 +76,15 @@ void InputBindingWidget::setNewBinding()
|
|||
void InputBindingWidget::clearBinding()
|
||||
{
|
||||
m_current_binding_value.clear();
|
||||
m_host_interface->removeSettingValue(m_setting_name);
|
||||
m_host_interface->removeSettingValue(m_section_name.toStdString().c_str(), m_key_name.toStdString().c_str());
|
||||
m_host_interface->updateInputMap();
|
||||
setText(m_current_binding_value);
|
||||
}
|
||||
|
||||
void InputBindingWidget::reloadBinding()
|
||||
{
|
||||
m_current_binding_value = m_host_interface->getSettingValue(m_setting_name).toString();
|
||||
m_current_binding_value = QString::fromStdString(m_host_interface->GetSettingValue(m_section_name.toStdString().c_str(),
|
||||
m_key_name.toStdString().c_str()));
|
||||
setText(m_current_binding_value);
|
||||
}
|
||||
|
||||
|
@ -135,9 +139,9 @@ void InputBindingWidget::stopListeningForInput()
|
|||
m_is_binding_all = false;
|
||||
}
|
||||
|
||||
InputButtonBindingWidget::InputButtonBindingWidget(QtHostInterface* host_interface, QString setting_name,
|
||||
QWidget* parent)
|
||||
: InputBindingWidget(host_interface, setting_name, parent)
|
||||
InputButtonBindingWidget::InputButtonBindingWidget(QtHostInterface* host_interface, QString section_name,
|
||||
QString key_name, QWidget* parent)
|
||||
: InputBindingWidget(host_interface, section_name, key_name, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -244,8 +248,9 @@ void InputButtonBindingWidget::stopListeningForInput()
|
|||
InputBindingWidget::stopListeningForInput();
|
||||
}
|
||||
|
||||
InputAxisBindingWidget::InputAxisBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent)
|
||||
: InputBindingWidget(host_interface, setting_name, parent)
|
||||
InputAxisBindingWidget::InputAxisBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name,
|
||||
QWidget* parent)
|
||||
: InputBindingWidget(host_interface, section_name, key_name, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -305,9 +310,9 @@ void InputAxisBindingWidget::stopListeningForInput()
|
|||
InputBindingWidget::stopListeningForInput();
|
||||
}
|
||||
|
||||
InputRumbleBindingWidget::InputRumbleBindingWidget(QtHostInterface* host_interface, QString setting_name,
|
||||
QWidget* parent)
|
||||
: InputBindingWidget(host_interface, setting_name, parent)
|
||||
InputRumbleBindingWidget::InputRumbleBindingWidget(QtHostInterface* host_interface, QString section_name,
|
||||
QString key_name, QWidget* parent)
|
||||
: InputBindingWidget(host_interface, section_name, key_name, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class InputBindingWidget : public QPushButton
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent);
|
||||
InputBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name, QWidget* parent);
|
||||
~InputBindingWidget();
|
||||
|
||||
ALWAYS_INLINE InputBindingWidget* getNextWidget() const { return m_next_widget; }
|
||||
|
@ -43,7 +43,8 @@ protected:
|
|||
void setNewBinding();
|
||||
|
||||
QtHostInterface* m_host_interface;
|
||||
QString m_setting_name;
|
||||
QString m_section_name;
|
||||
QString m_key_name;
|
||||
QString m_current_binding_value;
|
||||
QString m_new_binding_value;
|
||||
QTimer* m_input_listen_timer = nullptr;
|
||||
|
@ -58,7 +59,7 @@ class InputButtonBindingWidget : public InputBindingWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputButtonBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent);
|
||||
InputButtonBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name, QWidget* parent);
|
||||
~InputButtonBindingWidget();
|
||||
|
||||
protected:
|
||||
|
@ -80,7 +81,7 @@ class InputAxisBindingWidget : public InputBindingWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputAxisBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent);
|
||||
InputAxisBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name, QWidget* parent);
|
||||
~InputAxisBindingWidget();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
@ -98,7 +99,7 @@ class InputRumbleBindingWidget : public InputBindingWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputRumbleBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent);
|
||||
InputRumbleBindingWidget(QtHostInterface* host_interface, QString section_name, QString key_name, QWidget* parent);
|
||||
~InputRumbleBindingWidget();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "gamepropertiesdialog.h"
|
||||
#include "qtdisplaywidget.h"
|
||||
#include "qthostinterface.h"
|
||||
#include "qtsettingsinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include "scmversion/scmversion.h"
|
||||
#include "settingsdialog.h"
|
||||
|
@ -338,7 +337,7 @@ void MainWindow::onGameListEntryDoubleClicked(const GameListEntry* entry)
|
|||
QString path = QString::fromStdString(entry->path);
|
||||
if (!m_emulation_running)
|
||||
{
|
||||
if (!entry->code.empty() && m_host_interface->getSettingValue("General/SaveStateOnExit", true).toBool())
|
||||
if (!entry->code.empty() && m_host_interface->GetBooleanSettingValue("General", "SaveStateOnExit", true))
|
||||
{
|
||||
m_host_interface->resumeSystemFromState(path, true);
|
||||
}
|
||||
|
@ -434,7 +433,7 @@ void MainWindow::setupAdditionalUi()
|
|||
QAction* action = m_ui.menuCPUExecutionMode->addAction(tr(Settings::GetCPUExecutionModeDisplayName(mode)));
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, mode]() {
|
||||
m_host_interface->putSettingValue(QStringLiteral("CPU/ExecutionMode"),
|
||||
m_host_interface->putSettingValue(QStringLiteral("CPU"), QStringLiteral("ExecutionMode"),
|
||||
QString(Settings::GetCPUExecutionModeName(mode)));
|
||||
m_host_interface->applySettings();
|
||||
updateDebugMenuCPUExecutionMode();
|
||||
|
@ -448,7 +447,8 @@ void MainWindow::setupAdditionalUi()
|
|||
QAction* action = m_ui.menuRenderer->addAction(tr(Settings::GetRendererDisplayName(renderer)));
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, renderer]() {
|
||||
m_host_interface->putSettingValue(QStringLiteral("GPU/Renderer"), QString(Settings::GetRendererName(renderer)));
|
||||
m_host_interface->putSettingValue(QStringLiteral("GPU"), QStringLiteral("Renderer"),
|
||||
QString(Settings::GetRendererName(renderer)));
|
||||
m_host_interface->applySettings();
|
||||
updateDebugMenuGPURenderer();
|
||||
});
|
||||
|
@ -608,23 +608,27 @@ void MainWindow::connectSignals()
|
|||
m_host_interface->populateSaveStateMenus(nullptr, m_ui.menuLoadState, m_ui.menuSaveState);
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugDumpCPUtoVRAMCopies,
|
||||
"Debug/DumpCPUToVRAMCopies");
|
||||
QStringLiteral("Debug"), QStringLiteral("DumpCPUToVRAMCopies"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugDumpVRAMtoCPUCopies,
|
||||
"Debug/DumpVRAMToCPUCopies");
|
||||
QStringLiteral("Debug"), QStringLiteral("DumpVRAMToCPUCopies"));
|
||||
connect(m_ui.actionDumpAudio, &QAction::toggled, [this](bool checked) {
|
||||
if (checked)
|
||||
m_host_interface->startDumpingAudio();
|
||||
else
|
||||
m_host_interface->stopDumpingAudio();
|
||||
});
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowVRAM, "Debug/ShowVRAM");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowGPUState, "Debug/ShowGPUState");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowVRAM, QStringLiteral("Debug"),
|
||||
QStringLiteral("ShowVRAM"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowGPUState, QStringLiteral("Debug"),
|
||||
QStringLiteral("ShowGPUState"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowCDROMState,
|
||||
"Debug/ShowCDROMState");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowSPUState, "Debug/ShowSPUState");
|
||||
QStringLiteral("Debug"), QStringLiteral("ShowCDROMState"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowSPUState, QStringLiteral("Debug"),
|
||||
QStringLiteral("ShowSPUState"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowTimersState,
|
||||
"Debug/ShowTimersState");
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowMDECState, "Debug/ShowMDECState");
|
||||
QStringLiteral("Debug"), QStringLiteral("ShowTimersState"));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowMDECState, QStringLiteral("Debug"),
|
||||
QStringLiteral("ShowMDECState"));
|
||||
|
||||
addThemeToMenu(tr("Default"), QStringLiteral("default"));
|
||||
addThemeToMenu(tr("DarkFusion"), QStringLiteral("darkfusion"));
|
||||
|
@ -641,13 +645,13 @@ void MainWindow::addThemeToMenu(const QString& name, const QString& key)
|
|||
|
||||
void MainWindow::setTheme(const QString& theme)
|
||||
{
|
||||
m_host_interface->putSettingValue(QStringLiteral("UI/Theme"), theme);
|
||||
m_host_interface->putSettingValue(QStringLiteral("UI"), QStringLiteral("Theme"), theme);
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
void MainWindow::updateTheme()
|
||||
{
|
||||
QString theme = m_host_interface->getSettingValue(QStringLiteral("UI/Theme"), QStringLiteral("default")).toString();
|
||||
QString theme = QString::fromStdString(m_host_interface->GetSettingValue("UI", "Theme", "default"));
|
||||
if (theme == QStringLiteral("qdarkstyle"))
|
||||
{
|
||||
qApp->setStyle(m_unthemed_style_name);
|
||||
|
@ -737,8 +741,8 @@ void MainWindow::doSettings(SettingsDialog::Category category)
|
|||
|
||||
void MainWindow::updateDebugMenuCPUExecutionMode()
|
||||
{
|
||||
std::optional<CPUExecutionMode> current_mode = Settings::ParseCPUExecutionMode(
|
||||
m_host_interface->getSettingValue(QStringLiteral("CPU/ExecutionMode")).toString().toStdString().c_str());
|
||||
std::optional<CPUExecutionMode> current_mode =
|
||||
Settings::ParseCPUExecutionMode(m_host_interface->GetSettingValue("CPU", "ExecutionMode").c_str());
|
||||
if (!current_mode.has_value())
|
||||
return;
|
||||
|
||||
|
@ -754,8 +758,8 @@ void MainWindow::updateDebugMenuCPUExecutionMode()
|
|||
void MainWindow::updateDebugMenuGPURenderer()
|
||||
{
|
||||
// update the menu with the new selected renderer
|
||||
std::optional<GPURenderer> current_renderer = Settings::ParseRendererName(
|
||||
m_host_interface->getSettingValue(QStringLiteral("GPU/Renderer")).toString().toStdString().c_str());
|
||||
std::optional<GPURenderer> current_renderer =
|
||||
Settings::ParseRendererName(m_host_interface->GetSettingValue("GPU", "Renderer").c_str());
|
||||
if (!current_renderer.has_value())
|
||||
return;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ void MemoryCardSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* u
|
|||
|
||||
const MemoryCardType default_value = (index == 0) ? MemoryCardType::PerGameTitle : MemoryCardType::None;
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(
|
||||
m_host_interface, ui->memory_card_type, QStringLiteral("MemoryCards/Card%1Type").arg(index + 1),
|
||||
m_host_interface, ui->memory_card_type, QStringLiteral("MemoryCards"), QStringLiteral("Card%1Type").arg(index + 1),
|
||||
&Settings::ParseMemoryCardTypeName, &Settings::GetMemoryCardTypeName, default_value);
|
||||
ui->layout->addWidget(new QLabel(tr("Memory Card Type:"), ui->container));
|
||||
ui->layout->addWidget(ui->memory_card_type);
|
||||
|
@ -73,7 +73,7 @@ void MemoryCardSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* u
|
|||
QHBoxLayout* memory_card_layout = new QHBoxLayout();
|
||||
ui->memory_card_path = new QLineEdit(ui->container);
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, ui->memory_card_path,
|
||||
QStringLiteral("MemoryCards/Card%1Path").arg(index + 1));
|
||||
QStringLiteral("MemoryCards"), QStringLiteral("Card%1Path").arg(index + 1));
|
||||
memory_card_layout->addWidget(ui->memory_card_path);
|
||||
|
||||
QPushButton* memory_card_path_browse = new QPushButton(tr("Browse..."), ui->container);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "core/gpu.h"
|
||||
#include "core/system.h"
|
||||
#include "frontend-common/imgui_styles.h"
|
||||
#include "frontend-common/ini_settings_interface.h"
|
||||
#include "frontend-common/opengl_host_display.h"
|
||||
#include "frontend-common/sdl_audio_stream.h"
|
||||
#include "frontend-common/sdl_controller_interface.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "qtdisplaywidget.h"
|
||||
#include "qtprogresscallback.h"
|
||||
#include "qtsettingsinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include <QtCore/QTimer>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
Log_SetChannel(QtHostInterface);
|
||||
|
||||
|
@ -122,29 +123,62 @@ bool QtHostInterface::parseCommandLineParameters(int argc, char* argv[],
|
|||
return CommonHostInterface::ParseCommandLineParameters(argc, argv, out_boot_params);
|
||||
}
|
||||
|
||||
std::string QtHostInterface::GetSettingValue(const char* section, const char* key, const char* default_value)
|
||||
std::string QtHostInterface::GetSettingValue(const char* section, const char* key, const char* default_value /*= ""*/)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
QVariant value = m_qsettings->value(QStringLiteral("%1/%2").arg(section).arg(key), QString(default_value));
|
||||
return value.toString().toStdString();
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
return m_settings_interface->GetStringValue(section, key, default_value);
|
||||
}
|
||||
|
||||
QVariant QtHostInterface::getSettingValue(const QString& name, const QVariant& default_value)
|
||||
std::vector<std::string> QtHostInterface::GetStringList(const char* section, const char* key)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
return m_qsettings->value(name, default_value);
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
return m_settings_interface->GetStringList(section, key);
|
||||
}
|
||||
|
||||
void QtHostInterface::putSettingValue(const QString& name, const QVariant& value)
|
||||
void QtHostInterface::putSettingValue(const QString& section, const QString& key, const bool& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
m_qsettings->setValue(name, value);
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
m_settings_interface->SetBoolValue(section.toStdString().c_str(), key.toStdString().c_str(), value);
|
||||
}
|
||||
|
||||
void QtHostInterface::removeSettingValue(const QString& name)
|
||||
void QtHostInterface::putSettingValue(const QString& section, const QString& key, const int& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
m_qsettings->remove(name);
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
m_settings_interface->SetIntValue(section.toStdString().c_str(), key.toStdString().c_str(), value);
|
||||
}
|
||||
|
||||
void QtHostInterface::putSettingValue(const QString& section, const QString& key, const float& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
m_settings_interface->SetFloatValue(section.toStdString().c_str(), key.toStdString().c_str(), value);
|
||||
}
|
||||
|
||||
void QtHostInterface::putSettingValue(const QString& section, const QString& key, const QString& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
m_settings_interface->SetStringValue(section.toStdString().c_str(), key.toStdString().c_str(),
|
||||
value.toStdString().c_str());
|
||||
}
|
||||
|
||||
void QtHostInterface::putSettingValue(const QString& section, const QString& key, const QStringList& list)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
|
||||
std::vector<std::string> str_list;
|
||||
for (const QString& qstr : list)
|
||||
str_list.push_back(qstr.toStdString());
|
||||
|
||||
std::vector<std::string_view> strview_list;
|
||||
for (const std::string& str : str_list)
|
||||
strview_list.push_back(str);
|
||||
|
||||
m_settings_interface->SetStringList(section.toStdString().c_str(), key.toStdString().c_str(), strview_list);
|
||||
}
|
||||
|
||||
void QtHostInterface::removeSettingValue(const char* section, const char* key)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
m_settings_interface->DeleteValue(section, key);
|
||||
}
|
||||
|
||||
void QtHostInterface::setDefaultSettings()
|
||||
|
@ -157,10 +191,9 @@ void QtHostInterface::setDefaultSettings()
|
|||
|
||||
Settings old_settings(std::move(m_settings));
|
||||
{
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
SetDefaultSettings(si);
|
||||
CommonHostInterface::LoadSettings(si);
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
SetDefaultSettings(*m_settings_interface.get());
|
||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||
}
|
||||
|
||||
CheckForSettingsChanges(old_settings);
|
||||
|
@ -176,9 +209,8 @@ void QtHostInterface::applySettings()
|
|||
|
||||
Settings old_settings(std::move(m_settings));
|
||||
{
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
std::lock_guard<std::recursive_mutex> guard(m_qsettings_mutex);
|
||||
CommonHostInterface::LoadSettings(si);
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||
}
|
||||
|
||||
CheckForSettingsChanges(old_settings);
|
||||
|
@ -186,7 +218,7 @@ void QtHostInterface::applySettings()
|
|||
// detect when render-to-main flag changes
|
||||
if (m_system)
|
||||
{
|
||||
const bool render_to_main = getSettingValue("Main/RenderToMainWindow", true).toBool();
|
||||
const bool render_to_main = m_settings_interface->GetBoolValue("Main", "RenderToMainWindow", true);
|
||||
if (m_display && !m_is_fullscreen && render_to_main != m_is_rendering_to_main)
|
||||
{
|
||||
m_is_rendering_to_main = render_to_main;
|
||||
|
@ -203,9 +235,8 @@ void QtHostInterface::refreshGameList(bool invalidate_cache /* = false */, bool
|
|||
{
|
||||
Assert(!isOnWorkerThread());
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(m_qsettings_mutex);
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
m_game_list->SetSearchDirectoriesFromSettings(si);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||
m_game_list->SetSearchDirectoriesFromSettings(*m_settings_interface.get());
|
||||
|
||||
QtProgressCallback progress(m_main_window);
|
||||
m_game_list->Refresh(invalidate_cache, invalidate_database, &progress);
|
||||
|
@ -342,7 +373,7 @@ bool QtHostInterface::AcquireHostDisplay()
|
|||
{
|
||||
Assert(!m_display);
|
||||
|
||||
m_is_rendering_to_main = getSettingValue("Main/RenderToMainWindow", true).toBool();
|
||||
m_is_rendering_to_main = m_settings_interface->GetBoolValue("Main", "RenderToMainWindow", true);
|
||||
|
||||
QtDisplayWidget* display_widget =
|
||||
createDisplayRequested(m_worker_thread, QString::fromStdString(m_settings.gpu_adapter),
|
||||
|
@ -542,21 +573,10 @@ void QtHostInterface::OnSystemStateSaved(bool global, s32 slot)
|
|||
|
||||
void QtHostInterface::LoadSettings()
|
||||
{
|
||||
// no need to lock here because the main thread is waiting for us
|
||||
m_qsettings = std::make_unique<QSettings>(QString::fromStdString(GetSettingsFileName()), QSettings::IniFormat);
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
m_settings_interface = std::make_unique<INISettingsInterface>(CommonHostInterface::GetSettingsFileName());
|
||||
|
||||
// check settings validity
|
||||
const QSettings::Status settings_status = m_qsettings->status();
|
||||
if (settings_status != QSettings::NoError)
|
||||
{
|
||||
m_qsettings->clear();
|
||||
SetDefaultSettings(si);
|
||||
}
|
||||
|
||||
// load in settings
|
||||
CommonHostInterface::CheckSettings(si);
|
||||
CommonHostInterface::LoadSettings(si);
|
||||
CommonHostInterface::CheckSettings(*m_settings_interface.get());
|
||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||
}
|
||||
|
||||
void QtHostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||
|
@ -579,9 +599,8 @@ void QtHostInterface::updateInputMap()
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(m_qsettings_mutex);
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
CommonHostInterface::UpdateInputMap(si);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||
CommonHostInterface::UpdateInputMap(*m_settings_interface.get());
|
||||
}
|
||||
|
||||
void QtHostInterface::applyInputProfile(const QString& profile_path)
|
||||
|
@ -592,17 +611,15 @@ void QtHostInterface::applyInputProfile(const QString& profile_path)
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(m_qsettings_mutex);
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
ApplyInputProfile(profile_path.toUtf8().data(), si);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||
ApplyInputProfile(profile_path.toUtf8().data(), *m_settings_interface.get());
|
||||
emit inputProfileLoaded();
|
||||
}
|
||||
|
||||
void QtHostInterface::saveInputProfile(const QString& profile_name)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_qsettings_mutex);
|
||||
QtSettingsInterface si(m_qsettings.get());
|
||||
SaveInputProfile(profile_name.toUtf8().data(), si);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||
SaveInputProfile(profile_name.toUtf8().data(), *m_settings_interface.get());
|
||||
}
|
||||
|
||||
QString QtHostInterface::getUserDirectoryRelativePath(const QString& arg) const
|
||||
|
|
|
@ -24,13 +24,14 @@ class QWidget;
|
|||
class QTimer;
|
||||
|
||||
class GameList;
|
||||
class INISettingsInterface;
|
||||
|
||||
class MainWindow;
|
||||
class QtDisplayWidget;
|
||||
|
||||
Q_DECLARE_METATYPE(SystemBootParameters);
|
||||
|
||||
class QtHostInterface final : public QObject, private CommonHostInterface
|
||||
class QtHostInterface final : public QObject, public CommonHostInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -49,11 +50,15 @@ public:
|
|||
|
||||
bool parseCommandLineParameters(int argc, char* argv[], std::unique_ptr<SystemBootParameters>* out_boot_params);
|
||||
|
||||
/// Thread-safe QSettings access.
|
||||
/// Thread-safe settings access.
|
||||
std::string GetSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
||||
QVariant getSettingValue(const QString& name, const QVariant& default_value = QVariant());
|
||||
void putSettingValue(const QString& name, const QVariant& value);
|
||||
void removeSettingValue(const QString& name);
|
||||
std::vector<std::string> GetStringList(const char* section, const char* key);
|
||||
void putSettingValue(const QString& section, const QString& key, const bool& value);
|
||||
void putSettingValue(const QString& section, const QString& key, const int& value);
|
||||
void putSettingValue(const QString& section, const QString& key, const float& value);
|
||||
void putSettingValue(const QString& section, const QString& key, const QString& value);
|
||||
void putSettingValue(const QString& section, const QString& key, const QStringList& list);
|
||||
void removeSettingValue(const char* section, const char* key);
|
||||
|
||||
ALWAYS_INLINE const GameList* getGameList() const { return m_game_list.get(); }
|
||||
ALWAYS_INLINE GameList* getGameList() { return m_game_list.get(); }
|
||||
|
@ -205,8 +210,8 @@ private:
|
|||
void updateDisplayState();
|
||||
void wakeThread();
|
||||
|
||||
std::unique_ptr<QSettings> m_qsettings;
|
||||
std::recursive_mutex m_qsettings_mutex;
|
||||
std::unique_ptr<INISettingsInterface> m_settings_interface;
|
||||
std::recursive_mutex m_settings_mutex;
|
||||
|
||||
MainWindow* m_main_window = nullptr;
|
||||
QThread* m_original_thread = nullptr;
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
#include "qtsettingsinterface.h"
|
||||
#include <QtCore/QSettings>
|
||||
#include <algorithm>
|
||||
|
||||
static QString GetFullKey(const char* section, const char* key)
|
||||
{
|
||||
return QStringLiteral("%1/%2").arg(section, key);
|
||||
}
|
||||
|
||||
QtSettingsInterface::QtSettingsInterface(QSettings* settings) : m_settings(settings) {}
|
||||
|
||||
QtSettingsInterface::~QtSettingsInterface() = default;
|
||||
|
||||
void QtSettingsInterface::Clear()
|
||||
{
|
||||
m_settings->clear();
|
||||
}
|
||||
|
||||
int QtSettingsInterface::GetIntValue(const char* section, const char* key, int default_value /*= 0*/)
|
||||
{
|
||||
QVariant value = m_settings->value(GetFullKey(section, key));
|
||||
if (!value.isValid())
|
||||
return default_value;
|
||||
|
||||
bool converted_value_okay;
|
||||
int converted_value = value.toInt(&converted_value_okay);
|
||||
if (!converted_value_okay)
|
||||
return default_value;
|
||||
else
|
||||
return converted_value;
|
||||
}
|
||||
|
||||
float QtSettingsInterface::GetFloatValue(const char* section, const char* key, float default_value /*= 0.0f*/)
|
||||
{
|
||||
QVariant value = m_settings->value(GetFullKey(section, key));
|
||||
if (!value.isValid())
|
||||
return default_value;
|
||||
|
||||
bool converted_value_okay;
|
||||
float converted_value = value.toFloat(&converted_value_okay);
|
||||
if (!converted_value_okay)
|
||||
return default_value;
|
||||
else
|
||||
return converted_value;
|
||||
}
|
||||
|
||||
bool QtSettingsInterface::GetBoolValue(const char* section, const char* key, bool default_value /*= false*/)
|
||||
{
|
||||
QVariant value = m_settings->value(GetFullKey(section, key));
|
||||
return value.isValid() ? value.toBool() : default_value;
|
||||
}
|
||||
|
||||
std::string QtSettingsInterface::GetStringValue(const char* section, const char* key,
|
||||
const char* default_value /*= ""*/)
|
||||
{
|
||||
QVariant value = m_settings->value(GetFullKey(section, key));
|
||||
return value.isValid() ? value.toString().toStdString() : std::string(default_value);
|
||||
}
|
||||
|
||||
void QtSettingsInterface::SetIntValue(const char* section, const char* key, int value)
|
||||
{
|
||||
m_settings->setValue(GetFullKey(section, key), QVariant(value));
|
||||
}
|
||||
|
||||
void QtSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
|
||||
{
|
||||
m_settings->setValue(GetFullKey(section, key), QString::number(value));
|
||||
}
|
||||
|
||||
void QtSettingsInterface::SetBoolValue(const char* section, const char* key, bool value)
|
||||
{
|
||||
m_settings->setValue(GetFullKey(section, key), QVariant(value));
|
||||
}
|
||||
|
||||
void QtSettingsInterface::SetStringValue(const char* section, const char* key, const char* value)
|
||||
{
|
||||
m_settings->setValue(GetFullKey(section, key), QVariant(value));
|
||||
}
|
||||
|
||||
std::vector<std::string> QtSettingsInterface::GetStringList(const char* section, const char* key)
|
||||
{
|
||||
QVariant value = m_settings->value(GetFullKey(section, key));
|
||||
if (value.type() == QVariant::String)
|
||||
return {value.toString().toStdString()};
|
||||
else if (value.type() != QVariant::StringList)
|
||||
return {};
|
||||
|
||||
QStringList value_sl = value.toStringList();
|
||||
std::vector<std::string> results;
|
||||
results.reserve(static_cast<unsigned>(value_sl.size()));
|
||||
std::transform(value_sl.begin(), value_sl.end(), std::back_inserter(results),
|
||||
[](const QString& str) { return str.toStdString(); });
|
||||
return results;
|
||||
}
|
||||
|
||||
void QtSettingsInterface::SetStringList(const char* section, const char* key,
|
||||
const std::vector<std::string_view>& items)
|
||||
{
|
||||
QString full_key = GetFullKey(section, key);
|
||||
if (items.empty())
|
||||
{
|
||||
m_settings->remove(full_key);
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList sl;
|
||||
sl.reserve(static_cast<int>(items.size()));
|
||||
std::transform(items.begin(), items.end(), std::back_inserter(sl), [](const std::string_view& sv) {
|
||||
return QString::fromLocal8Bit(sv.data(), static_cast<int>(sv.size()));
|
||||
});
|
||||
m_settings->setValue(full_key, sl);
|
||||
}
|
||||
|
||||
bool QtSettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item)
|
||||
{
|
||||
QString full_key = GetFullKey(section, key);
|
||||
QVariant var = m_settings->value(full_key);
|
||||
QStringList sl = var.toStringList();
|
||||
if (sl.removeAll(item) == 0)
|
||||
return false;
|
||||
|
||||
if (sl.isEmpty())
|
||||
m_settings->remove(full_key);
|
||||
else
|
||||
m_settings->setValue(full_key, sl);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QtSettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
|
||||
{
|
||||
QString full_key = GetFullKey(section, key);
|
||||
QVariant var = m_settings->value(full_key);
|
||||
|
||||
QStringList sl = (var.type() == QVariant::StringList) ? var.toStringList() : QStringList();
|
||||
QString qitem(item);
|
||||
if (sl.contains(qitem))
|
||||
return false;
|
||||
|
||||
sl.push_back(qitem);
|
||||
m_settings->setValue(full_key, sl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtSettingsInterface::DeleteValue(const char* section, const char* key)
|
||||
{
|
||||
m_settings->remove(GetFullKey(section, key));
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
#include "core/settings.h"
|
||||
|
||||
class QSettings;
|
||||
|
||||
class QtSettingsInterface : public SettingsInterface
|
||||
{
|
||||
public:
|
||||
QtSettingsInterface(QSettings* settings);
|
||||
~QtSettingsInterface();
|
||||
|
||||
void Clear() override;
|
||||
|
||||
int GetIntValue(const char* section, const char* key, int default_value = 0) override;
|
||||
float GetFloatValue(const char* section, const char* key, float default_value = 0.0f) override;
|
||||
bool GetBoolValue(const char* section, const char* key, bool default_value = false) override;
|
||||
std::string GetStringValue(const char* section, const char* key, const char* default_value = "") override;
|
||||
|
||||
void SetIntValue(const char* section, const char* key, int value) override;
|
||||
void SetFloatValue(const char* section, const char* key, float value) override;
|
||||
void SetBoolValue(const char* section, const char* key, bool value) override;
|
||||
void SetStringValue(const char* section, const char* key, const char* value) override;
|
||||
|
||||
std::vector<std::string> GetStringList(const char* section, const char* key) override;
|
||||
void SetStringList(const char* section, const char* key, const std::vector<std::string_view>& items) override;
|
||||
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
|
||||
bool AddToStringList(const char* section, const char* key, const char* item) override;
|
||||
|
||||
void DeleteValue(const char* section, const char* key) override;
|
||||
|
||||
private:
|
||||
QSettings* m_settings;
|
||||
};
|
|
@ -200,119 +200,116 @@ struct SettingAccessor<QAction>
|
|||
/// Binds a widget's value to a setting, updating it when the value changes.
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToBoolSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name,
|
||||
bool default_value = false)
|
||||
void BindWidgetToBoolSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, bool default_value = false)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
QVariant value = hi->getSettingValue(setting_name);
|
||||
if (value.isValid())
|
||||
Accessor::setBoolValue(widget, value.toBool());
|
||||
else
|
||||
Accessor::setBoolValue(widget, default_value);
|
||||
bool value =
|
||||
hi->GetBooleanSettingValue(section_name.toStdString().c_str(), key_name.toStdString().c_str(), default_value);
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name]() {
|
||||
Accessor::setBoolValue(widget, value);
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name]() {
|
||||
const bool new_value = Accessor::getBoolValue(widget);
|
||||
hi->putSettingValue(setting_name, new_value);
|
||||
hi->putSettingValue(section_name, key_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToIntSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name, int default_value = 0)
|
||||
void BindWidgetToIntSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, int default_value = 0)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
QVariant value = hi->getSettingValue(setting_name);
|
||||
if (value.isValid())
|
||||
Accessor::setIntValue(widget, value.toInt());
|
||||
else
|
||||
Accessor::setIntValue(widget, default_value);
|
||||
s32 value = hi->GetIntegerSettingValue(section_name.toStdString().c_str(), key_name.toStdString().c_str(),
|
||||
static_cast<s32>(default_value));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name]() {
|
||||
Accessor::setIntValue(widget, static_cast<int>(value));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name]() {
|
||||
const int new_value = Accessor::getIntValue(widget);
|
||||
hi->putSettingValue(setting_name, new_value);
|
||||
hi->putSettingValue(section_name, key_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToFloatSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name,
|
||||
float default_value = 0.0f)
|
||||
void BindWidgetToFloatSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, float default_value = 0.0f)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
QVariant value = hi->getSettingValue(setting_name);
|
||||
if (value.isValid())
|
||||
Accessor::setFloatValue(widget, value.toFloat());
|
||||
else
|
||||
Accessor::setFloatValue(widget, default_value);
|
||||
float value =
|
||||
hi->GetFloatSettingValue(section_name.toStdString().c_str(), key_name.toStdString().c_str(), default_value);
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name]() {
|
||||
Accessor::setFloatValue(widget, value);
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name]() {
|
||||
const float new_value = Accessor::getFloatValue(widget);
|
||||
hi->putSettingValue(setting_name, new_value);
|
||||
hi->putSettingValue(section_name, key_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToNormalizedSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name, float range,
|
||||
float default_value = 0.0f)
|
||||
void BindWidgetToNormalizedSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, float range, float default_value = 0.0f)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
QVariant value = hi->getSettingValue(setting_name);
|
||||
if (value.isValid())
|
||||
Accessor::setIntValue(widget, static_cast<int>(value.toFloat() * range));
|
||||
else
|
||||
Accessor::setIntValue(widget, static_cast<int>(default_value * range));
|
||||
float value =
|
||||
hi->GetFloatSettingValue(section_name.toStdString().c_str(), key_name.toStdString().c_str(), default_value);
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name, range]() {
|
||||
Accessor::setIntValue(widget, static_cast<int>(value * range));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name, range]() {
|
||||
const float new_value = (static_cast<float>(Accessor::getIntValue(widget)) / range);
|
||||
hi->putSettingValue(setting_name, QString::number(new_value));
|
||||
hi->putSettingValue(section_name, key_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToStringSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name,
|
||||
const QString& default_value = QString())
|
||||
void BindWidgetToStringSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, const QString& default_value = QString())
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
QVariant value = hi->getSettingValue(setting_name);
|
||||
if (value.isValid())
|
||||
Accessor::setStringValue(widget, value.toString());
|
||||
else
|
||||
Accessor::setStringValue(widget, default_value);
|
||||
std::string value = hi->GetSettingValue(section_name.toStdString().c_str(), key_name.toStdString().c_str(),
|
||||
default_value.toStdString().c_str());
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name]() {
|
||||
Accessor::setStringValue(widget, QString::fromStdString(value));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name]() {
|
||||
const QString new_value = Accessor::getStringValue(widget);
|
||||
hi->putSettingValue(setting_name, new_value);
|
||||
hi->putSettingValue(section_name, key_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType, typename DataType>
|
||||
void BindWidgetToEnumSetting(QtHostInterface* hi, WidgetType* widget, const QString& setting_name,
|
||||
std::optional<DataType> (*from_string_function)(const char* str),
|
||||
void BindWidgetToEnumSetting(QtHostInterface* hi, WidgetType* widget, const QString& section_name,
|
||||
const QString& key_name, std::optional<DataType> (*from_string_function)(const char* str),
|
||||
const char* (*to_string_function)(DataType value), DataType default_value)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
using UnderlyingType = std::underlying_type_t<DataType>;
|
||||
|
||||
const QString old_setting_string_value = hi->getSettingValue(setting_name).toString();
|
||||
const std::optional<DataType> old_setting_value =
|
||||
from_string_function(old_setting_string_value.toStdString().c_str());
|
||||
// TODO: Clean this up?
|
||||
const std::string old_setting_string_value = hi->GetSettingValue(
|
||||
section_name.toStdString().c_str(), key_name.toStdString().c_str(), to_string_function(default_value));
|
||||
const std::optional<DataType> old_setting_value = from_string_function(old_setting_string_value.c_str());
|
||||
if (old_setting_value.has_value())
|
||||
Accessor::setIntValue(widget, static_cast<int>(static_cast<UnderlyingType>(old_setting_value.value())));
|
||||
else
|
||||
Accessor::setIntValue(widget, static_cast<int>(static_cast<UnderlyingType>(default_value)));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name, to_string_function]() {
|
||||
Accessor::connectValueChanged(widget, [hi, widget, section_name, key_name, to_string_function]() {
|
||||
const DataType value = static_cast<DataType>(static_cast<UnderlyingType>(Accessor::getIntValue(widget)));
|
||||
const char* string_value = to_string_function(value);
|
||||
hi->putSettingValue(setting_name, QString::fromLocal8Bit(string_value));
|
||||
hi->putSettingValue(section_name, key_name, QString::fromLocal8Bit(string_value));
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue