From 60edddac7d2afc3f8f1893c169ba2ebc550882ac Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Thu, 2 Aug 2018 11:36:47 +0800 Subject: [PATCH] citra_qt/configuration: Add background color config This is actually very easy to do. I added a label and a push button for it, and used the Qt standard dialog QColorDialog for picking colors. --- .../configuration/configure_graphics.cpp | 16 ++++++++++++++ .../configuration/configure_graphics.h | 1 + .../configuration/configure_graphics.ui | 21 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index 1c537910e..4e4aeb8cd 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #ifdef __APPLE__ #include #endif @@ -41,6 +42,14 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) } }); #endif + connect(ui->bg_button, &QPushButton::clicked, this, [this] { + const QColor new_bg_color = QColorDialog::getColor(bg_color); + if (!new_bg_color.isValid()) + return; + bg_color = new_bg_color; + ui->bg_button->setStyleSheet( + QString("QPushButton { background-color: %1 }").arg(bg_color.name())); + }); } ConfigureGraphics::~ConfigureGraphics() {} @@ -59,6 +68,10 @@ void ConfigureGraphics::setConfiguration() { ui->toggle_3d->setChecked(Settings::values.toggle_3d); ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); ui->swap_screen->setChecked(Settings::values.swap_screen); + bg_color = QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, + Settings::values.bg_blue); + ui->bg_button->setStyleSheet( + QString("QPushButton { background-color: %1 }").arg(bg_color.name())); } void ConfigureGraphics::applyConfiguration() { @@ -77,6 +90,9 @@ void ConfigureGraphics::applyConfiguration() { Settings::values.layout_option = static_cast(ui->layout_combobox->currentIndex()); Settings::values.swap_screen = ui->swap_screen->isChecked(); + Settings::values.bg_red = static_cast(bg_color.redF()); + Settings::values.bg_green = static_cast(bg_color.greenF()); + Settings::values.bg_blue = static_cast(bg_color.blueF()); } void ConfigureGraphics::retranslateUi() { diff --git a/src/citra_qt/configuration/configure_graphics.h b/src/citra_qt/configuration/configure_graphics.h index 36bdef890..44514faf8 100644 --- a/src/citra_qt/configuration/configure_graphics.h +++ b/src/citra_qt/configuration/configure_graphics.h @@ -26,4 +26,5 @@ private: private: std::unique_ptr ui; + QColor bg_color; }; diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui index 9ba4bd0b1..040c5e397 100644 --- a/src/citra_qt/configuration/configure_graphics.ui +++ b/src/citra_qt/configuration/configure_graphics.ui @@ -297,6 +297,27 @@ + + + + + + Background Color: + + + + + + + + 40 + 16777215 + + + + + +