yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

configure_general: Implement manual tristate buttons

This commit is contained in:
lat9nq 2020-07-13 17:08:50 -04:00
parent e26e82d8d5
commit 58672cc7b6
2 changed files with 27 additions and 17 deletions

View File

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

View File

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