summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-05-09 21:10:22 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2023-07-21 16:56:07 +0200
commit23f874ae60eebae5451722cd89101e76e1e14065 (patch)
treece57655a560ca28faeffde11a20c3a985ac7acbc
parentshared_widget: Make button creation static (diff)
downloadyuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.gz
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.bz2
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.lz
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.xz
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.tar.zst
yuzu-23f874ae60eebae5451722cd89101e76e1e14065.zip
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp74
-rw-r--r--src/yuzu/configuration/configure_graphics.h2
-rw-r--r--src/yuzu/configuration/configure_graphics.ui50
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(
ui->setupUi(this);
- SetConfiguration();
+ Setup();
for (const auto& device : vulkan_devices) {
vulkan_device_combobox->addItem(device);
@@ -128,20 +128,22 @@ ConfigureGraphics::ConfigureGraphics(
connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this,
[this](int backend) { UpdateShaderBackendSelection(backend); });
- // connect(ui->bg_button, &QPushButton::clicked, this, [this] {
- // const QColor new_bg_color = QColorDialog::getColor(bg_color);
- // if (!new_bg_color.isValid()) {
- // return;
- // }
- // UpdateBackgroundColorButton(new_bg_color);
- // });
- // ui->bg_label->setVisible(Settings::IsConfiguringGlobal());
- // ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal());
+ connect(ui->bg_button, &QPushButton::clicked, this, [this] {
+ const QColor new_bg_color = QColorDialog::getColor(bg_color);
+ if (!new_bg_color.isValid()) {
+ return;
+ }
+ UpdateBackgroundColorButton(new_bg_color);
+ });
api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled());
ui->api_widget->setEnabled(
(!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) &&
ui->api_widget->isEnabled());
+
+ if (Settings::IsConfiguringGlobal()) {
+ ui->bg_widget->setEnabled(Settings::values.bg_red.UsingGlobal());
+ }
}
void ConfigureGraphics::PopulateVSyncModeSelection() {
@@ -205,7 +207,9 @@ void ConfigureGraphics::UpdateShaderBackendSelection(int backend) {
ConfigureGraphics::~ConfigureGraphics() = default;
-void ConfigureGraphics::SetConfiguration() {
+void ConfigureGraphics::SetConfiguration() {}
+
+void ConfigureGraphics::Setup() {
const bool runtime_lock = !system.IsPoweredOn();
QLayout* api_layout = ui->api_widget->layout();
QWidget* api_grid_widget = new QWidget(this);
@@ -305,6 +309,46 @@ void ConfigureGraphics::SetConfiguration() {
for (auto widget : hold_api) {
api_grid_layout->addWidget(widget);
}
+
+ if (Settings::IsConfiguringGlobal()) {
+ apply_funcs.push_front([this](bool powered_on) {
+ Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red()));
+ Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green()));
+ Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue()));
+ });
+ } else {
+ QPushButton* bg_restore_button = ConfigurationShared::Widget::CreateRestoreGlobalButton(
+ Settings::values.bg_red, ui->bg_widget);
+ ui->bg_widget->layout()->addWidget(bg_restore_button);
+
+ QObject::connect(bg_restore_button, &QAbstractButton::clicked,
+ [bg_restore_button, this](bool) {
+ const int r = Settings::values.bg_red.GetValue(true);
+ const int g = Settings::values.bg_green.GetValue(true);
+ const int b = Settings::values.bg_blue.GetValue(true);
+ UpdateBackgroundColorButton(QColor::fromRgb(r, g, b));
+
+ bg_restore_button->setVisible(false);
+ bg_restore_button->setEnabled(false);
+ });
+
+ QObject::connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) {
+ bg_restore_button->setVisible(true);
+ bg_restore_button->setEnabled(true);
+ });
+
+ apply_funcs.push_front([bg_restore_button, this](bool powered_on) {
+ const bool using_global = !bg_restore_button->isEnabled();
+ Settings::values.bg_red.SetGlobal(using_global);
+ Settings::values.bg_green.SetGlobal(using_global);
+ Settings::values.bg_blue.SetGlobal(using_global);
+ if (!using_global) {
+ Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red()));
+ Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green()));
+ Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue()));
+ }
+ });
+ }
}
const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
@@ -375,11 +419,11 @@ void ConfigureGraphics::RetranslateUI() {
void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) {
bg_color = color;
- // QPixmap pixmap(ui->bg_button->size());
- // pixmap.fill(bg_color);
+ QPixmap pixmap(ui->bg_button->size());
+ pixmap.fill(bg_color);
- // const QIcon color_icon(pixmap);
- // ui->bg_button->setIcon(color_icon);
+ const QIcon color_icon(pixmap);
+ ui->bg_button->setIcon(color_icon);
}
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:
void changeEvent(QEvent* event) override;
void RetranslateUI();
+ void Setup();
+
void PopulateVSyncModeSelection();
void UpdateBackgroundColorButton(QColor color);
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 @@
</layout>
</widget>
</item>
+ <item>
+ <widget class="QWidget" name="bg_widget" native="true">
+ <layout class="QHBoxLayout" name="bg_layout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Background Color:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bg_button">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>40</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
</item>