diff options
| author | 2023-05-09 15:10:22 -0400 | |
|---|---|---|
| committer | 2023-07-21 10:56:07 -0400 | |
| commit | 23f874ae60eebae5451722cd89101e76e1e14065 (patch) | |
| tree | ce57655a560ca28faeffde11a20c3a985ac7acbc /src | |
| parent | shared_widget: Make button creation static (diff) | |
| download | yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.gz yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.xz yuzu-23f874ae60eebae5451722cd89101e76e1e14065.zip | |
configure_graphics: Reimplement bg_color
To specialized a setting to be worth adding to the shared_widget imo,
so add it roughly like before.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 74 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.ui | 50 |
3 files changed, 111 insertions, 15 deletions
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 0b21f80f5..4c6d69703 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -88,7 +88,7 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 88 | 88 | ||
| 89 | ui->setupUi(this); | 89 | ui->setupUi(this); |
| 90 | 90 | ||
| 91 | SetConfiguration(); | 91 | Setup(); |
| 92 | 92 | ||
| 93 | for (const auto& device : vulkan_devices) { | 93 | for (const auto& device : vulkan_devices) { |
| 94 | vulkan_device_combobox->addItem(device); | 94 | vulkan_device_combobox->addItem(device); |
| @@ -128,20 +128,22 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 128 | connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this, | 128 | connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this, |
| 129 | [this](int backend) { UpdateShaderBackendSelection(backend); }); | 129 | [this](int backend) { UpdateShaderBackendSelection(backend); }); |
| 130 | 130 | ||
| 131 | // connect(ui->bg_button, &QPushButton::clicked, this, [this] { | 131 | connect(ui->bg_button, &QPushButton::clicked, this, [this] { |
| 132 | // const QColor new_bg_color = QColorDialog::getColor(bg_color); | 132 | const QColor new_bg_color = QColorDialog::getColor(bg_color); |
| 133 | // if (!new_bg_color.isValid()) { | 133 | if (!new_bg_color.isValid()) { |
| 134 | // return; | 134 | return; |
| 135 | // } | 135 | } |
| 136 | // UpdateBackgroundColorButton(new_bg_color); | 136 | UpdateBackgroundColorButton(new_bg_color); |
| 137 | // }); | 137 | }); |
| 138 | // ui->bg_label->setVisible(Settings::IsConfiguringGlobal()); | ||
| 139 | // ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal()); | ||
| 140 | 138 | ||
| 141 | api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled()); | 139 | api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled()); |
| 142 | ui->api_widget->setEnabled( | 140 | ui->api_widget->setEnabled( |
| 143 | (!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) && | 141 | (!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) && |
| 144 | ui->api_widget->isEnabled()); | 142 | ui->api_widget->isEnabled()); |
| 143 | |||
| 144 | if (Settings::IsConfiguringGlobal()) { | ||
| 145 | ui->bg_widget->setEnabled(Settings::values.bg_red.UsingGlobal()); | ||
| 146 | } | ||
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | void ConfigureGraphics::PopulateVSyncModeSelection() { | 149 | void ConfigureGraphics::PopulateVSyncModeSelection() { |
| @@ -205,7 +207,9 @@ void ConfigureGraphics::UpdateShaderBackendSelection(int backend) { | |||
| 205 | 207 | ||
| 206 | ConfigureGraphics::~ConfigureGraphics() = default; | 208 | ConfigureGraphics::~ConfigureGraphics() = default; |
| 207 | 209 | ||
| 208 | void ConfigureGraphics::SetConfiguration() { | 210 | void ConfigureGraphics::SetConfiguration() {} |
| 211 | |||
| 212 | void ConfigureGraphics::Setup() { | ||
| 209 | const bool runtime_lock = !system.IsPoweredOn(); | 213 | const bool runtime_lock = !system.IsPoweredOn(); |
| 210 | QLayout* api_layout = ui->api_widget->layout(); | 214 | QLayout* api_layout = ui->api_widget->layout(); |
| 211 | QWidget* api_grid_widget = new QWidget(this); | 215 | QWidget* api_grid_widget = new QWidget(this); |
| @@ -305,6 +309,46 @@ void ConfigureGraphics::SetConfiguration() { | |||
| 305 | for (auto widget : hold_api) { | 309 | for (auto widget : hold_api) { |
| 306 | api_grid_layout->addWidget(widget); | 310 | api_grid_layout->addWidget(widget); |
| 307 | } | 311 | } |
| 312 | |||
| 313 | if (Settings::IsConfiguringGlobal()) { | ||
| 314 | apply_funcs.push_front([this](bool powered_on) { | ||
| 315 | Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red())); | ||
| 316 | Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); | ||
| 317 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); | ||
| 318 | }); | ||
| 319 | } else { | ||
| 320 | QPushButton* bg_restore_button = ConfigurationShared::Widget::CreateRestoreGlobalButton( | ||
| 321 | Settings::values.bg_red, ui->bg_widget); | ||
| 322 | ui->bg_widget->layout()->addWidget(bg_restore_button); | ||
| 323 | |||
| 324 | QObject::connect(bg_restore_button, &QAbstractButton::clicked, | ||
| 325 | [bg_restore_button, this](bool) { | ||
| 326 | const int r = Settings::values.bg_red.GetValue(true); | ||
| 327 | const int g = Settings::values.bg_green.GetValue(true); | ||
| 328 | const int b = Settings::values.bg_blue.GetValue(true); | ||
| 329 | UpdateBackgroundColorButton(QColor::fromRgb(r, g, b)); | ||
| 330 | |||
| 331 | bg_restore_button->setVisible(false); | ||
| 332 | bg_restore_button->setEnabled(false); | ||
| 333 | }); | ||
| 334 | |||
| 335 | QObject::connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) { | ||
| 336 | bg_restore_button->setVisible(true); | ||
| 337 | bg_restore_button->setEnabled(true); | ||
| 338 | }); | ||
| 339 | |||
| 340 | apply_funcs.push_front([bg_restore_button, this](bool powered_on) { | ||
| 341 | const bool using_global = !bg_restore_button->isEnabled(); | ||
| 342 | Settings::values.bg_red.SetGlobal(using_global); | ||
| 343 | Settings::values.bg_green.SetGlobal(using_global); | ||
| 344 | Settings::values.bg_blue.SetGlobal(using_global); | ||
| 345 | if (!using_global) { | ||
| 346 | Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red())); | ||
| 347 | Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); | ||
| 348 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); | ||
| 349 | } | ||
| 350 | }); | ||
| 351 | } | ||
| 308 | } | 352 | } |
| 309 | 353 | ||
| 310 | const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, | 354 | const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, |
| @@ -375,11 +419,11 @@ void ConfigureGraphics::RetranslateUI() { | |||
| 375 | void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { | 419 | void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { |
| 376 | bg_color = color; | 420 | bg_color = color; |
| 377 | 421 | ||
| 378 | // QPixmap pixmap(ui->bg_button->size()); | 422 | QPixmap pixmap(ui->bg_button->size()); |
| 379 | // pixmap.fill(bg_color); | 423 | pixmap.fill(bg_color); |
| 380 | 424 | ||
| 381 | // const QIcon color_icon(pixmap); | 425 | const QIcon color_icon(pixmap); |
| 382 | // ui->bg_button->setIcon(color_icon); | 426 | ui->bg_button->setIcon(color_icon); |
| 383 | } | 427 | } |
| 384 | 428 | ||
| 385 | void ConfigureGraphics::UpdateAPILayout() { | 429 | void ConfigureGraphics::UpdateAPILayout() { |
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 4ef551341..61eb2f2fc 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h | |||
| @@ -51,6 +51,8 @@ private: | |||
| 51 | void changeEvent(QEvent* event) override; | 51 | void changeEvent(QEvent* event) override; |
| 52 | void RetranslateUI(); | 52 | void RetranslateUI(); |
| 53 | 53 | ||
| 54 | void Setup(); | ||
| 55 | |||
| 54 | void PopulateVSyncModeSelection(); | 56 | void PopulateVSyncModeSelection(); |
| 55 | void UpdateBackgroundColorButton(QColor color); | 57 | void UpdateBackgroundColorButton(QColor color); |
| 56 | void UpdateAPILayout(); | 58 | void UpdateAPILayout(); |
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 1f6ffea1a..d09415d70 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui | |||
| @@ -76,6 +76,56 @@ | |||
| 76 | </layout> | 76 | </layout> |
| 77 | </widget> | 77 | </widget> |
| 78 | </item> | 78 | </item> |
| 79 | <item> | ||
| 80 | <widget class="QWidget" name="bg_widget" native="true"> | ||
| 81 | <layout class="QHBoxLayout" name="bg_layout"> | ||
| 82 | <property name="leftMargin"> | ||
| 83 | <number>0</number> | ||
| 84 | </property> | ||
| 85 | <property name="topMargin"> | ||
| 86 | <number>0</number> | ||
| 87 | </property> | ||
| 88 | <property name="rightMargin"> | ||
| 89 | <number>0</number> | ||
| 90 | </property> | ||
| 91 | <property name="bottomMargin"> | ||
| 92 | <number>0</number> | ||
| 93 | </property> | ||
| 94 | <item> | ||
| 95 | <widget class="QLabel" name="label"> | ||
| 96 | <property name="sizePolicy"> | ||
| 97 | <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | ||
| 98 | <horstretch>0</horstretch> | ||
| 99 | <verstretch>0</verstretch> | ||
| 100 | </sizepolicy> | ||
| 101 | </property> | ||
| 102 | <property name="text"> | ||
| 103 | <string>Background Color:</string> | ||
| 104 | </property> | ||
| 105 | </widget> | ||
| 106 | </item> | ||
| 107 | <item> | ||
| 108 | <widget class="QPushButton" name="bg_button"> | ||
| 109 | <property name="sizePolicy"> | ||
| 110 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
| 111 | <horstretch>0</horstretch> | ||
| 112 | <verstretch>0</verstretch> | ||
| 113 | </sizepolicy> | ||
| 114 | </property> | ||
| 115 | <property name="maximumSize"> | ||
| 116 | <size> | ||
| 117 | <width>40</width> | ||
| 118 | <height>16777215</height> | ||
| 119 | </size> | ||
| 120 | </property> | ||
| 121 | <property name="text"> | ||
| 122 | <string/> | ||
| 123 | </property> | ||
| 124 | </widget> | ||
| 125 | </item> | ||
| 126 | </layout> | ||
| 127 | </widget> | ||
| 128 | </item> | ||
| 79 | </layout> | 129 | </layout> |
| 80 | </widget> | 130 | </widget> |
| 81 | </item> | 131 | </item> |