summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar lat9nq2020-07-13 19:22:41 -0400
committerGravatar lat9nq2020-07-19 13:26:55 -0400
commitda65b92f9e9992413938bb084949367822b890c8 (patch)
tree4ed34575261a37458ba823f29324e8fa52631029 /src
parentconfiguration_shared: Use a highlight instead of background color (diff)
downloadyuzu-da65b92f9e9992413938bb084949367822b890c8.tar.gz
yuzu-da65b92f9e9992413938bb084949367822b890c8.tar.xz
yuzu-da65b92f9e9992413938bb084949367822b890c8.zip
configuration_shared: Require name of the widget for highlighting
Prevents mass-coloring of elements later on
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configuration_shared.cpp32
-rw-r--r--src/yuzu/configuration/configuration_shared.h6
-rw-r--r--src/yuzu/configuration/configure_general.cpp5
3 files changed, 27 insertions, 16 deletions
diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp
index 78dd76c6e..08d67facd 100644
--- a/src/yuzu/configuration/configuration_shared.cpp
+++ b/src/yuzu/configuration/configuration_shared.cpp
@@ -5,6 +5,7 @@
5#include <QCheckBox> 5#include <QCheckBox>
6#include <QComboBox> 6#include <QComboBox>
7#include <QObject> 7#include <QObject>
8#include <QString>
8#include "core/settings.h" 9#include "core/settings.h"
9#include "yuzu/configuration/configuration_shared.h" 10#include "yuzu/configuration/configuration_shared.h"
10#include "yuzu/configuration/configure_per_game.h" 11#include "yuzu/configuration/configure_per_game.h"
@@ -85,30 +86,37 @@ void ConfigurationShared::SetPerGameSetting(
85 ConfigurationShared::USE_GLOBAL_OFFSET); 86 ConfigurationShared::USE_GLOBAL_OFFSET);
86} 87}
87 88
88void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) { 89void ConfigurationShared::SetHighlight(QWidget* widget, const std::string& name, bool highlighted) {
89 if (highlighted) { 90 if (highlighted) {
90 widget->setStyleSheet(QStringLiteral("border:2px solid;border-color:rgba(0,203,255,0.5);")); 91 widget->setStyleSheet(
92 QStringLiteral("QWidget#%1 { border:2px solid;border-color:rgba(0,203,255,0.5) }")
93 .arg(QString::fromStdString(name)));
91 } else { 94 } else {
92 widget->setStyleSheet(QStringLiteral("border:2px solid;border-color:rgba(0,0,0,0);")); 95 widget->setStyleSheet(
96 QStringLiteral("QWidget#%1 { border:2px solid;border-color:rgba(0,0,0,0) }")
97 .arg(QString::fromStdString(name)));
93 } 98 }
94 widget->show(); 99 widget->show();
95} 100}
96 101
97void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, Settings::Setting<bool>& setting, 102void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, const std::string& name,
103 const Settings::Setting<bool>& setting,
98 ConfigurationShared::CheckState& tracker) { 104 ConfigurationShared::CheckState& tracker) {
99 if (setting.UsingGlobal()) { 105 if (setting.UsingGlobal()) {
100 tracker = CheckState::Global; 106 tracker = CheckState::Global;
101 } else { 107 } else {
102 tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off; 108 tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off;
103 } 109 }
104 SetHighlight(checkbox, tracker != CheckState::Global); 110 SetHighlight(checkbox, name, tracker != CheckState::Global);
105 QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, setting, &tracker]() { 111 QObject::connect(
106 tracker = static_cast<ConfigurationShared::CheckState>((tracker + 1) % CheckState::Count); 112 checkbox, &QCheckBox::clicked, checkbox, [checkbox, name, setting, &tracker]() {
107 if (tracker == CheckState::Global) { 113 tracker =
108 checkbox->setChecked(setting.GetValue(true)); 114 static_cast<ConfigurationShared::CheckState>((tracker + 1) % CheckState::Count);
109 } 115 if (tracker == CheckState::Global) {
110 SetHighlight(checkbox, tracker != CheckState::Global); 116 checkbox->setChecked(setting.GetValue(true));
111 }); 117 }
118 SetHighlight(checkbox, name, tracker != CheckState::Global);
119 });
112} 120}
113 121
114void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) { 122void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) {
diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h
index 88709446c..b2bd971c8 100644
--- a/src/yuzu/configuration/configuration_shared.h
+++ b/src/yuzu/configuration/configuration_shared.h
@@ -25,6 +25,8 @@ enum CheckState {
25struct Trackers { 25struct Trackers {
26 CheckState use_frame_limit; 26 CheckState use_frame_limit;
27 CheckState use_multi_core; 27 CheckState use_multi_core;
28
29 CheckState enable_audio_stretching;
28} extern trackers; 30} extern trackers;
29 31
30// Global-aware apply and set functions 32// Global-aware apply and set functions
@@ -45,8 +47,8 @@ void SetPerGameSetting(QComboBox* combobox,
45void SetPerGameSetting(QComboBox* combobox, 47void SetPerGameSetting(QComboBox* combobox,
46 const Settings::Setting<Settings::GPUAccuracy>* setting); 48 const Settings::Setting<Settings::GPUAccuracy>* setting);
47 49
48void SetHighlight(QWidget* widget, bool highlighted); 50void SetHighlight(QWidget* widget, const std::string& name, bool highlighted);
49void SetColoredTristate(QCheckBox* checkbox, Settings::Setting<bool>& setting, 51void SetColoredTristate(QCheckBox* checkbox, const std::string& name, const Settings::Setting<bool>& setting,
50 ConfigurationShared::CheckState& tracker); 52 ConfigurationShared::CheckState& tracker);
51 53
52void InsertGlobalItem(QComboBox* combobox); 54void InsertGlobalItem(QComboBox* combobox);
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index e3ddbc294..b4c288ca4 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -108,10 +108,11 @@ void ConfigureGeneral::SetupPerGameUI() {
108 ui->toggle_background_pause->setVisible(false); 108 ui->toggle_background_pause->setVisible(false);
109 ui->toggle_hide_mouse->setVisible(false); 109 ui->toggle_hide_mouse->setVisible(false);
110 110
111 ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, 111 ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, "toggle_frame_limit",
112 Settings::values.use_frame_limit, 112 Settings::values.use_frame_limit,
113 ConfigurationShared::trackers.use_frame_limit); 113 ConfigurationShared::trackers.use_frame_limit);
114 ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, 114 ConfigurationShared::SetColoredTristate(ui->use_multi_core, "use_multi_core",
115 Settings::values.use_multi_core,
115 ConfigurationShared::trackers.use_multi_core); 116 ConfigurationShared::trackers.use_multi_core);
116 117
117 connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() { 118 connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() {