From 2627241541a2b2bc691c2776f111f95d7bd94c70 Mon Sep 17 00:00:00 2001 From: lat9nq Date: Mon, 13 Jul 2020 21:48:56 -0400 Subject: [PATCH] configuration_shared: Use an int instead of a QString I noticed some of the code could be reduced to just passing the function an int, since I was doing the same thing over and over. Also clang-formats configure_graphics --- .../configuration/configuration_shared.cpp | 4 +- src/yuzu/configuration/configuration_shared.h | 2 +- src/yuzu/configuration/configure_graphics.cpp | 38 +++++++++++-------- .../configure_graphics_advanced.cpp | 6 +-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index 28b6552223..a648d339b7 100644 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -125,8 +125,8 @@ void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) { combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX); } -void ConfigurationShared::InsertGlobalItem(QComboBox* combobox, const QString& global) { - const QString use_global_text = ConfigurePerGame::tr("Use global configuration (%1)").arg(global); +void ConfigurationShared::InsertGlobalItem(QComboBox* combobox, int global_index) { + const QString use_global_text = ConfigurePerGame::tr("Use global configuration (%1)").arg(combobox->itemText(global_index)); combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX, use_global_text); combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX); } diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 71011fd92a..f3676bd3ac 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -61,6 +61,6 @@ void SetColoredTristate(QCheckBox* checkbox, const std::string& name, const Sett ConfigurationShared::CheckState& tracker); void InsertGlobalItem(QComboBox* combobox); -void InsertGlobalItem(QComboBox* combobox, const QString& global); +void InsertGlobalItem(QComboBox* combobox, int global_index); } // namespace ConfigurationShared diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 07dc75ccbc..c1b38728da 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -31,13 +31,14 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) SetConfiguration(); - connect(ui->api, qOverload(&QComboBox::currentIndexChanged), this, - [this] { - UpdateDeviceComboBox(); - if (!Settings::configuring_global) { - ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", ui->api->currentIndex() != ConfigurationShared::USE_GLOBAL_INDEX); - } - }); + connect(ui->api, qOverload(&QComboBox::currentIndexChanged), this, [this] { + UpdateDeviceComboBox(); + if (!Settings::configuring_global) { + ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", + ui->api->currentIndex() != + ConfigurationShared::USE_GLOBAL_INDEX); + } + }); connect(ui->device, qOverload(&QComboBox::activated), this, [this](int device) { UpdateDeviceSelection(device); }); @@ -84,9 +85,12 @@ void ConfigureGraphics::SetConfiguration() { ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1); ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); - ConfigurationShared::SetHighlight(ui->aspect_ratio_layout, "aspect_ratio_layout", !Settings::values.aspect_ratio.UsingGlobal()); - ConfigurationShared::SetHighlight(ui->bg_layout, "bg_layout", !Settings::values.bg_red.UsingGlobal()); - // FIXME: ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", !Settings::values.renderer_backend.UsingGlobal()); + ConfigurationShared::SetHighlight(ui->aspect_ratio_layout, "aspect_ratio_layout", + !Settings::values.aspect_ratio.UsingGlobal()); + ConfigurationShared::SetHighlight(ui->bg_layout, "bg_layout", + !Settings::values.bg_red.UsingGlobal()); + // FIXME: ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", + // !Settings::values.renderer_backend.UsingGlobal()); } UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red.GetValue(), @@ -243,9 +247,11 @@ void ConfigureGraphics::SetupPerGameUI() { return; } - connect(ui->aspect_ratio_combobox, static_cast(&QComboBox::activated), this, [this](int index) { - ConfigurationShared::SetHighlight(ui->aspect_ratio_layout, "aspect_ratio_layout", index != 0); - }); + connect(ui->aspect_ratio_combobox, static_cast(&QComboBox::activated), + this, [this](int index) { + ConfigurationShared::SetHighlight(ui->aspect_ratio_layout, "aspect_ratio_layout", + index != 0); + }); connect(ui->bg_combobox, static_cast(&QComboBox::activated), this, [this](int index) { ui->bg_button->setEnabled(index == 1); @@ -260,6 +266,8 @@ void ConfigureGraphics::SetupPerGameUI() { Settings::values.use_asynchronous_gpu_emulation, ConfigurationShared::trackers.use_asynchronous_gpu_emulation); - ConfigurationShared::InsertGlobalItem(ui->aspect_ratio_combobox, ui->aspect_ratio_combobox->itemText(Settings::values.aspect_ratio.GetValue(true))); - ConfigurationShared::InsertGlobalItem(ui->api, ui->api->itemText(static_cast(Settings::values.renderer_backend.GetValue(true)))); + ConfigurationShared::InsertGlobalItem(ui->aspect_ratio_combobox, + Settings::values.aspect_ratio.GetValue(true)); + ConfigurationShared::InsertGlobalItem( + ui->api, static_cast(Settings::values.renderer_backend.GetValue(true))); } diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index fbeaeccbc8..1d9a1076e5 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -157,12 +157,10 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { Settings::values.force_30fps_mode, ConfigurationShared::trackers.force_30fps_mode); ConfigurationShared::InsertGlobalItem( - ui->gpu_accuracy, - ui->gpu_accuracy->itemText(static_cast(Settings::values.gpu_accuracy.GetValue(true)))); + ui->gpu_accuracy, static_cast(Settings::values.gpu_accuracy.GetValue(true))); ConfigurationShared::InsertGlobalItem( ui->anisotropic_filtering_combobox, - ui->anisotropic_filtering_combobox->itemText( - static_cast(Settings::values.max_anisotropy.GetValue(true)))); + static_cast(Settings::values.max_anisotropy.GetValue(true))); connect(ui->gpu_accuracy, static_cast(&QComboBox::activated), this, [this](int index) {