Qt/GameConfigWidget: Add `reverse` argument for `{Save,Load}CheckBox`
In order to not hard code `if (key == "FastDiscSpeed")`
This commit is contained in:
parent
0a2afa48b7
commit
0892998af1
|
@ -219,30 +219,19 @@ void GameConfigWidget::ConnectWidgets()
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameConfigWidget::LoadCheckBox(QCheckBox* checkbox, const std::string& section,
|
void GameConfigWidget::LoadCheckBox(QCheckBox* checkbox, const std::string& section,
|
||||||
const std::string& key)
|
const std::string& key, bool reverse)
|
||||||
{
|
{
|
||||||
bool checked;
|
bool checked;
|
||||||
if (key == "FastDiscSpeed")
|
|
||||||
{
|
|
||||||
if (m_gameini_local.GetOrCreateSection(section)->Get("FastDiscSpeed", &checked))
|
|
||||||
return checkbox->setCheckState(!checked ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
if (m_gameini_default.GetOrCreateSection(section)->Get("FastDiscSpeed", &checked))
|
|
||||||
return checkbox->setCheckState(!checked ? Qt::Checked : Qt::Unchecked);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_gameini_local.GetOrCreateSection(section)->Get(key, &checked))
|
if (m_gameini_local.GetOrCreateSection(section)->Get(key, &checked))
|
||||||
return checkbox->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
|
return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
if (m_gameini_default.GetOrCreateSection(section)->Get(key, &checked))
|
if (m_gameini_default.GetOrCreateSection(section)->Get(key, &checked))
|
||||||
return checkbox->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
|
return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
|
||||||
checkbox->setCheckState(Qt::PartiallyChecked);
|
checkbox->setCheckState(Qt::PartiallyChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& section,
|
void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& section,
|
||||||
const std::string& key)
|
const std::string& key, bool reverse)
|
||||||
{
|
{
|
||||||
// Delete any existing entries from the local gameini if checkbox is undetermined.
|
// Delete any existing entries from the local gameini if checkbox is undetermined.
|
||||||
// Otherwise, write the current value to the local gameini if the value differs from the default
|
// Otherwise, write the current value to the local gameini if the value differs from the default
|
||||||
|
@ -256,13 +245,7 @@ void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& sect
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checked = checkbox->checkState() == Qt::Checked;
|
bool checked = (checkbox->checkState() == Qt::Checked) ^ reverse;
|
||||||
|
|
||||||
if (key == "FastDiscSpeed")
|
|
||||||
{
|
|
||||||
m_gameini_local.GetOrCreateSection(section)->Set(key, !checked);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_gameini_default.Exists(section, key))
|
if (m_gameini_default.Exists(section, key))
|
||||||
{
|
{
|
||||||
|
@ -293,7 +276,7 @@ void GameConfigWidget::LoadSettings()
|
||||||
LoadCheckBox(m_enable_mmu, "Core", "MMU");
|
LoadCheckBox(m_enable_mmu, "Core", "MMU");
|
||||||
LoadCheckBox(m_enable_fprf, "Core", "FPRF");
|
LoadCheckBox(m_enable_fprf, "Core", "FPRF");
|
||||||
LoadCheckBox(m_sync_gpu, "Core", "SyncGPU");
|
LoadCheckBox(m_sync_gpu, "Core", "SyncGPU");
|
||||||
LoadCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed");
|
LoadCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed", true);
|
||||||
LoadCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
|
LoadCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
|
||||||
|
|
||||||
std::string determinism_mode;
|
std::string determinism_mode;
|
||||||
|
@ -343,7 +326,7 @@ void GameConfigWidget::SaveSettings()
|
||||||
SaveCheckBox(m_enable_mmu, "Core", "MMU");
|
SaveCheckBox(m_enable_mmu, "Core", "MMU");
|
||||||
SaveCheckBox(m_enable_fprf, "Core", "FPRF");
|
SaveCheckBox(m_enable_fprf, "Core", "FPRF");
|
||||||
SaveCheckBox(m_sync_gpu, "Core", "SyncGPU");
|
SaveCheckBox(m_sync_gpu, "Core", "SyncGPU");
|
||||||
SaveCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed");
|
SaveCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed", true);
|
||||||
SaveCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
|
SaveCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
|
||||||
|
|
||||||
int determinism_num = m_deterministic_dual_core->currentIndex();
|
int determinism_num = m_deterministic_dual_core->currentIndex();
|
||||||
|
|
|
@ -35,8 +35,10 @@ private:
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
void SaveCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key);
|
void SaveCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key,
|
||||||
void LoadCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key);
|
bool reverse = false);
|
||||||
|
void LoadCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key,
|
||||||
|
bool reverse = false);
|
||||||
|
|
||||||
QString m_gameini_sys_path;
|
QString m_gameini_sys_path;
|
||||||
QString m_gameini_local_path;
|
QString m_gameini_local_path;
|
||||||
|
|
Loading…
Reference in New Issue