mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 01:02:48 +01:00
configure_general: Implement manual tristate buttons
This commit is contained in:
parent
e26e82d8d5
commit
58672cc7b6
2 changed files with 27 additions and 17 deletions
|
@ -23,6 +23,8 @@ enum CheckState {
|
|||
};
|
||||
|
||||
struct Trackers {
|
||||
CheckState use_frame_limit;
|
||||
CheckState use_multi_core;
|
||||
} extern trackers;
|
||||
|
||||
// Global-aware apply and set functions
|
||||
|
|
|
@ -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::values.use_frame_limit.UsingGlobal()) {
|
||||
ui->toggle_frame_limit->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);
|
||||
}
|
||||
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue