configure_general: Implement manual tristate buttons

master
lat9nq 2020-07-13 17:08:50 +07:00
parent e26e82d8d5
commit 58672cc7b6
2 changed files with 27 additions and 17 deletions

@ -23,6 +23,8 @@ enum CheckState {
}; };
struct Trackers { struct Trackers {
CheckState use_frame_limit;
CheckState use_multi_core;
} extern trackers; } extern trackers;
// Global-aware apply and set functions // Global-aware apply and set functions

@ -19,9 +19,10 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
SetConfiguration(); SetConfiguration();
connect(ui->toggle_frame_limit, &QCheckBox::stateChanged, ui->frame_limit, [this]() { if (Settings::configuring_global) {
ui->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked); connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit,
}); [this]() { ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); });
}
} }
ConfigureGeneral::~ConfigureGeneral() = default; ConfigureGeneral::~ConfigureGeneral() = default;
@ -40,17 +41,13 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue()); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue());
ui->frame_limit->setValue(Settings::values.frame_limit.GetValue()); ui->frame_limit->setValue(Settings::values.frame_limit.GetValue());
if (!Settings::configuring_global) { if (Settings::configuring_global) {
if (Settings::values.use_multi_core.UsingGlobal()) { ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue());
ui->use_multi_core->setCheckState(Qt::PartiallyChecked); } else {
} ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue() &&
if (Settings::values.use_frame_limit.UsingGlobal()) { ConfigurationShared::trackers.use_frame_limit !=
ui->toggle_frame_limit->setCheckState(Qt::PartiallyChecked); ConfigurationShared::CheckState::Global);
}
} }
ui->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked &&
ui->toggle_frame_limit->isEnabled());
} }
void ConfigureGeneral::ApplyConfiguration() { void ConfigureGeneral::ApplyConfiguration() {
@ -71,9 +68,11 @@ void ConfigureGeneral::ApplyConfiguration() {
} }
} else { } else {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core,
ui->use_multi_core); ui->use_multi_core,
ConfigurationShared::trackers.use_multi_core);
bool global_frame_limit = ui->toggle_frame_limit->checkState() == Qt::PartiallyChecked; bool global_frame_limit = ConfigurationShared::trackers.use_frame_limit ==
ConfigurationShared::CheckState::Global;
Settings::values.use_frame_limit.SetGlobal(global_frame_limit); Settings::values.use_frame_limit.SetGlobal(global_frame_limit);
Settings::values.frame_limit.SetGlobal(global_frame_limit); Settings::values.frame_limit.SetGlobal(global_frame_limit);
if (!global_frame_limit) { if (!global_frame_limit) {
@ -109,6 +108,15 @@ void ConfigureGeneral::SetupPerGameUI() {
ui->toggle_background_pause->setVisible(false); ui->toggle_background_pause->setVisible(false);
ui->toggle_hide_mouse->setVisible(false); ui->toggle_hide_mouse->setVisible(false);
ui->toggle_frame_limit->setTristate(true); ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit,
ui->use_multi_core->setTristate(true); Settings::values.use_frame_limit,
ConfigurationShared::trackers.use_frame_limit);
ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core,
ConfigurationShared::trackers.use_multi_core);
connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() {
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked() &&
(ConfigurationShared::trackers.use_frame_limit !=
ConfigurationShared::CheckState::Global));
});
} }