citra-emu
/
citra
Archived
1
0
Fork 0

Merge pull request #4047 from zhaowenlan1779/bg-color

citra_qt/configuration: Add background color config
This commit is contained in:
James Rowe 2018-08-02 11:05:20 -06:00 committed by GitHub
commit cafe9838b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <QColorDialog>
#ifdef __APPLE__ #ifdef __APPLE__
#include <QMessageBox> #include <QMessageBox>
#endif #endif
@ -41,6 +42,14 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
} }
}); });
#endif #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() {} ConfigureGraphics::~ConfigureGraphics() {}
@ -59,6 +68,10 @@ void ConfigureGraphics::setConfiguration() {
ui->toggle_3d->setChecked(Settings::values.toggle_3d); ui->toggle_3d->setChecked(Settings::values.toggle_3d);
ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option)); ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option));
ui->swap_screen->setChecked(Settings::values.swap_screen); 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() { void ConfigureGraphics::applyConfiguration() {
@ -77,6 +90,9 @@ void ConfigureGraphics::applyConfiguration() {
Settings::values.layout_option = Settings::values.layout_option =
static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex()); static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());
Settings::values.swap_screen = ui->swap_screen->isChecked(); Settings::values.swap_screen = ui->swap_screen->isChecked();
Settings::values.bg_red = static_cast<float>(bg_color.redF());
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
} }
void ConfigureGraphics::retranslateUi() { void ConfigureGraphics::retranslateUi() {

View File

@ -26,4 +26,5 @@ private:
private: private:
std::unique_ptr<Ui::ConfigureGraphics> ui; std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color;
}; };

View File

@ -297,6 +297,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="bg_label">
<property name="text">
<string>Background Color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bg_button">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>