Merge branch 'accent_colors_feat' into 'main'

feat(ui): Implement customizable accent color and rainbow mode

See merge request citron/emulator!79
This commit is contained in:
Zephyron
2025-10-04 12:04:52 +10:00
10 changed files with 1109 additions and 1175 deletions

View File

@@ -209,6 +209,7 @@ add_executable(citron
qt_common.h qt_common.h
startup_checks.cpp startup_checks.cpp
startup_checks.h startup_checks.h
theme.h
uisettings.cpp uisettings.cpp
uisettings.h uisettings.h
util/clickable_label.cpp util/clickable_label.cpp

View File

@@ -16,15 +16,16 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<!-- High DPI support: Enable automatic scaling and proper window modality -->
<property name="windowModality"> <property name="windowModality">
<enum>Qt::ApplicationModal</enum> <enum>Qt::ApplicationModal</enum>
</property> </property>
<!-- High DPI scaling attributes -->
<property name="windowTitle"> <property name="windowTitle">
<string>citron Configuration</string> <string>citron Configuration</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string/>
</property>
<property name="templateStyleSheet" stdset="0">
<string>QDialog { <string>QDialog {
background-color: #2b2b2b; background-color: #2b2b2b;
color: #ffffff; color: #ffffff;
@@ -68,7 +69,7 @@
} }
QScrollBar::handle:vertical:hover { QScrollBar::handle:vertical:hover {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
} }
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
@@ -92,7 +93,7 @@
} }
QScrollBar::handle:horizontal:hover { QScrollBar::handle:horizontal:hover {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
} }
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal { QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {
@@ -118,10 +119,10 @@
} }
QPushButton.tabButton:checked { QPushButton.tabButton:checked {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
font-weight: bold; font-weight: bold;
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QPushButton.tabButton:hover:!checked { QPushButton.tabButton:hover:!checked {
@@ -130,7 +131,7 @@
} }
QPushButton.tabButton:pressed { QPushButton.tabButton:pressed {
background-color: #2980b9; background-color: %%ACCENT_COLOR_PRESSED%%;
} }
QTabWidget { QTabWidget {
@@ -170,10 +171,10 @@
} }
QTabBar::tab:selected { QTabBar::tab:selected {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
font-weight: bold; font-weight: bold;
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QTabBar::tab:hover:!selected { QTabBar::tab:hover:!selected {
@@ -191,7 +192,7 @@
QTabBar QToolButton:hover { QTabBar QToolButton:hover {
background-color: #4d4d4d; background-color: #4d4d4d;
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QTabBar::scroller { QTabBar::scroller {
@@ -232,12 +233,12 @@
} }
QCheckBox::indicator:checked { QCheckBox::indicator:checked {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QCheckBox::indicator:hover { QCheckBox::indicator:hover {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QComboBox { QComboBox {
@@ -248,16 +249,16 @@
color: #ffffff; color: #ffffff;
min-width: 120px; min-width: 120px;
min-height: 28px; min-height: 28px;
selection-background-color: #4a9eff; selection-background-color: %%ACCENT_COLOR%%;
} }
QComboBox:hover { QComboBox:hover {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
background-color: #404040; background-color: #404040;
} }
QComboBox:focus { QComboBox:focus {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
background-color: #404040; background-color: #404040;
} }
@@ -277,8 +278,8 @@
QComboBox QAbstractItemView { QComboBox QAbstractItemView {
background-color: #3d3d3d; background-color: #3d3d3d;
border: 1px solid #4a9eff; border: 1px solid %%ACCENT_COLOR%%;
selection-background-color: #4a9eff; selection-background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
outline: none; outline: none;
} }
@@ -290,12 +291,12 @@
} }
QComboBox QAbstractItemView::item:selected { QComboBox QAbstractItemView::item:selected {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
} }
QComboBox QAbstractItemView::item:hover { QComboBox QAbstractItemView::item:hover {
background-color: #5dafff; background-color: %%ACCENT_COLOR_HOVER%%;
color: #ffffff; color: #ffffff;
} }
@@ -306,16 +307,16 @@
padding: 8px 12px; padding: 8px 12px;
color: #ffffff; color: #ffffff;
min-height: 20px; min-height: 20px;
selection-background-color: #4a9eff; selection-background-color: %%ACCENT_COLOR%%;
} }
QLineEdit:focus { QLineEdit:focus {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
background-color: #404040; background-color: #404040;
} }
QPushButton { QPushButton {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
border: none; border: none;
padding: 10px 20px; padding: 10px 20px;
@@ -325,11 +326,11 @@
} }
QPushButton:hover { QPushButton:hover {
background-color: #5dafff; background-color: %%ACCENT_COLOR_HOVER%%;
} }
QPushButton:pressed { QPushButton:pressed {
background-color: #2980b9; background-color: %%ACCENT_COLOR_PRESSED%%;
} }
QPushButton:disabled { QPushButton:disabled {
@@ -338,7 +339,7 @@
} }
QToolButton { QToolButton {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
border: none; border: none;
padding: 8px 12px; padding: 8px 12px;
@@ -349,11 +350,11 @@
} }
QToolButton:hover { QToolButton:hover {
background-color: #5dafff; background-color: %%ACCENT_COLOR_HOVER%%;
} }
QToolButton:pressed { QToolButton:pressed {
background-color: #2980b9; background-color: %%ACCENT_COLOR_PRESSED%%;
} }
QLabel { QLabel {
@@ -377,7 +378,7 @@
} }
QListWidget::item:selected { QListWidget::item:selected {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
color: #ffffff; color: #ffffff;
} }
@@ -393,15 +394,15 @@
} }
QSlider::handle:horizontal { QSlider::handle:horizontal {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
border: 1px solid #4a9eff; border: 1px solid %%ACCENT_COLOR%%;
width: 18px; width: 18px;
margin: -5px 0; margin: -5px 0;
border-radius: 9px; border-radius: 9px;
} }
QSlider::handle:horizontal:hover { QSlider::handle:horizontal:hover {
background-color: #5dafff; background-color: %%ACCENT_COLOR_HOVER%%;
} }
QSpinBox, QDoubleSpinBox { QSpinBox, QDoubleSpinBox {
@@ -414,7 +415,7 @@
} }
QSpinBox:focus, QDoubleSpinBox:focus { QSpinBox:focus, QDoubleSpinBox:focus {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
background-color: #404040; background-color: #404040;
} }
@@ -433,12 +434,12 @@
} }
QRadioButton::indicator:checked { QRadioButton::indicator:checked {
background-color: #4a9eff; background-color: %%ACCENT_COLOR%%;
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
QRadioButton::indicator:hover { QRadioButton::indicator:hover {
border-color: #4a9eff; border-color: %%ACCENT_COLOR%%;
} }
/* High DPI specific styles */ /* High DPI specific styles */

View File

@@ -2,24 +2,27 @@
// SPDX-FileCopyrightText: 2025 citron Emulator Project // SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "citron/configuration/configure_dialog.h"
#include <memory> #include <memory>
#include <QApplication>
#include <QButtonGroup>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QScreen> #include <QScreen>
#include <QApplication>
#include <QButtonGroup>
#include <QScrollArea> #include <QScrollArea>
#include <QString>
#include <QTimer>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/settings.h" #include "common/settings.h"
#include "common/settings_enums.h" #include "common/settings_enums.h"
#include "core/core.h" #include "core/core.h"
#include "ui_configure.h" #include "ui_configure.h"
#include "vk_device_info.h" #include "vk_device_info.h"
#include "citron/configuration/configuration_shared.h" // <-- Full definition included here
#include "citron/configuration/configure_applets.h" #include "citron/configuration/configure_applets.h"
#include "citron/configuration/configure_audio.h" #include "citron/configuration/configure_audio.h"
#include "citron/configuration/configure_cpu.h" #include "citron/configuration/configure_cpu.h"
#include "citron/configuration/configure_debug_tab.h" #include "citron/configuration/configure_debug_tab.h"
#include "citron/configuration/configure_dialog.h"
#include "citron/configuration/configure_filesystem.h" #include "citron/configuration/configure_filesystem.h"
#include "citron/configuration/configure_general.h" #include "citron/configuration/configure_general.h"
#include "citron/configuration/configure_graphics.h" #include "citron/configuration/configure_graphics.h"
@@ -33,9 +36,9 @@
#include "citron/configuration/configure_ui.h" #include "citron/configuration/configure_ui.h"
#include "citron/configuration/configure_web.h" #include "citron/configuration/configure_web.h"
#include "citron/hotkeys.h" #include "citron/hotkeys.h"
#include "citron/theme.h"
#include "citron/uisettings.h" #include "citron/uisettings.h"
// Helper function to create a scroll area for a widget
static QScrollArea* CreateScrollArea(QWidget* widget) { static QScrollArea* CreateScrollArea(QWidget* widget) {
auto* scroll_area = new QScrollArea(); auto* scroll_area = new QScrollArea();
scroll_area->setWidget(widget); scroll_area->setWidget(widget);
@@ -43,60 +46,6 @@ static QScrollArea* CreateScrollArea(QWidget* widget) {
scroll_area->setFrameShape(QFrame::NoFrame); scroll_area->setFrameShape(QFrame::NoFrame);
scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// High DPI support: Scroll area will inherit scaling from parent
// Set style with high DPI aware styling
scroll_area->setStyleSheet(QLatin1String(
"QScrollArea { "
"border: none; "
"background-color: #2b2b2b; "
"}"
"QScrollArea > QWidget > QWidget { "
"background-color: #2b2b2b; "
"}"
"QScrollBar:vertical { "
"background-color: #3d3d3d; "
"width: 14px; "
"border-radius: 7px; "
"margin: 2px; "
"}"
"QScrollBar::handle:vertical { "
"background-color: #5d5d5d; "
"border-radius: 6px; "
"min-height: 30px; "
"margin: 1px; "
"}"
"QScrollBar::handle:vertical:hover { "
"background-color: #4a9eff; "
"}"
"QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { "
"border: none; "
"background: none; "
"height: 0px; "
"}"
"QScrollBar:horizontal { "
"background-color: #3d3d3d; "
"height: 14px; "
"border-radius: 7px; "
"margin: 2px; "
"}"
"QScrollBar::handle:horizontal { "
"background-color: #5d5d5d; "
"border-radius: 6px; "
"min-width: 30px; "
"margin: 1px; "
"}"
"QScrollBar::handle:horizontal:hover { "
"background-color: #4a9eff; "
"}"
"QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal { "
"border: none; "
"background: none; "
"width: 0px; "
"}"
));
return scroll_area; return scroll_area;
} }
@@ -127,43 +76,37 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, network_tab{std::make_unique<ConfigureNetwork>(system_, this)},
profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)},
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)}, system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)},
web_tab{std::make_unique<ConfigureWeb>(this)} { web_tab{std::make_unique<ConfigureWeb>(this)},
rainbow_timer{new QTimer(this)} {
Settings::SetConfiguringGlobal(true); Settings::SetConfiguringGlobal(true);
// Set window flags to include maximize button and make it resizable
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint |
Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
// High DPI support: Set proper attributes for scaling
setAttribute(Qt::WA_TranslucentBackground, false); setAttribute(Qt::WA_TranslucentBackground, false);
setAttribute(Qt::WA_NoSystemBackground, false); setAttribute(Qt::WA_NoSystemBackground, false);
setAttribute(Qt::WA_DontShowOnScreen, false); setAttribute(Qt::WA_DontShowOnScreen, false);
ui->setupUi(this); ui->setupUi(this);
// Set size policy and enable resizing UpdateTheme();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Get screen geometry and set to fullscreen with high DPI awareness
QScreen* screen = QApplication::primaryScreen(); QScreen* screen = QApplication::primaryScreen();
if (screen) { if (screen) {
QRect screenGeometry = screen->availableGeometry(); QRect screenGeometry = screen->availableGeometry();
// Calculate logical size based on device pixel ratio for high DPI support
qreal devicePixelRatio = screen->devicePixelRatio(); qreal devicePixelRatio = screen->devicePixelRatio();
int logicalWidth = static_cast<int>(screenGeometry.width() / devicePixelRatio); int logicalWidth = static_cast<int>(screenGeometry.width() / devicePixelRatio);
int logicalHeight = static_cast<int>(screenGeometry.height() / devicePixelRatio); int logicalHeight = static_cast<int>(screenGeometry.height() / devicePixelRatio);
// Set geometry using logical units
setGeometry(0, 0, logicalWidth, logicalHeight); setGeometry(0, 0, logicalWidth, logicalHeight);
showMaximized(); // Start maximized/fullscreen showMaximized();
} }
// Create button group for exclusive tab selection
tab_button_group = std::make_unique<QButtonGroup>(this); tab_button_group = std::make_unique<QButtonGroup>(this);
tab_button_group->setExclusive(true); tab_button_group->setExclusive(true);
// Add tab buttons to the button group and connect to stacked widget
tab_button_group->addButton(ui->generalTabButton, 0); tab_button_group->addButton(ui->generalTabButton, 0);
tab_button_group->addButton(ui->uiTabButton, 1); tab_button_group->addButton(ui->uiTabButton, 1);
tab_button_group->addButton(ui->systemTabButton, 2); tab_button_group->addButton(ui->systemTabButton, 2);
@@ -180,32 +123,32 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
tab_button_group->addButton(ui->appletsTabButton, 13); tab_button_group->addButton(ui->appletsTabButton, 13);
tab_button_group->addButton(ui->loggingTabButton, 14); tab_button_group->addButton(ui->loggingTabButton, 14);
// Add pages to stacked widget wrapped in scroll areas in the same order as button group ui->stackedWidget->addWidget(CreateScrollArea(general_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(general_tab.get())); // 0 ui->stackedWidget->addWidget(CreateScrollArea(ui_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(ui_tab.get())); // 1 ui->stackedWidget->addWidget(CreateScrollArea(system_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(system_tab.get())); // 2 ui->stackedWidget->addWidget(CreateScrollArea(cpu_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(cpu_tab.get())); // 3 ui->stackedWidget->addWidget(CreateScrollArea(graphics_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(graphics_tab.get())); // 4 ui->stackedWidget->addWidget(CreateScrollArea(graphics_advanced_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(graphics_advanced_tab.get())); // 5 ui->stackedWidget->addWidget(CreateScrollArea(audio_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(audio_tab.get())); // 6 ui->stackedWidget->addWidget(CreateScrollArea(input_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(input_tab.get())); // 7 ui->stackedWidget->addWidget(CreateScrollArea(hotkeys_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(hotkeys_tab.get())); // 8 ui->stackedWidget->addWidget(CreateScrollArea(network_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(network_tab.get())); // 9 ui->stackedWidget->addWidget(CreateScrollArea(web_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(web_tab.get())); // 10 ui->stackedWidget->addWidget(CreateScrollArea(filesystem_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(filesystem_tab.get()));// 11 ui->stackedWidget->addWidget(CreateScrollArea(profile_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(profile_tab.get())); // 12 ui->stackedWidget->addWidget(CreateScrollArea(applets_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(applets_tab.get())); // 13 ui->stackedWidget->addWidget(CreateScrollArea(debug_tab_tab.get()));
ui->stackedWidget->addWidget(CreateScrollArea(debug_tab_tab.get())); // 14
// Connect button group to stacked widget connect(tab_button_group.get(), qOverload<int>(&QButtonGroup::idClicked), this, [this](int id) {
connect(tab_button_group.get(), QOverload<int>::of(&QButtonGroup::idClicked),
[this](int id) {
ui->stackedWidget->setCurrentIndex(id); ui->stackedWidget->setCurrentIndex(id);
if (id == 14) { // Logging tab if (id == 14) {
debug_tab_tab->SetCurrentIndex(0); debug_tab_tab->SetCurrentIndex(0);
} }
}); });
connect(ui_tab.get(), &ConfigureUi::themeChanged, this, &ConfigureDialog::UpdateTheme);
connect(rainbow_timer, &QTimer::timeout, this, &ConfigureDialog::UpdateTheme);
web_tab->SetWebServiceConfigEnabled(enable_web_config); web_tab->SetWebServiceConfigEnabled(enable_web_config);
hotkeys_tab->Populate(registry); hotkeys_tab->Populate(registry);
@@ -225,16 +168,43 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
} }
} }
// Set initial tab to General (index 0)
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
ui->generalTabButton->setChecked(true); ui->generalTabButton->setChecked(true);
// Focus on the OK button by default
ui->buttonBox->setFocus(); ui->buttonBox->setFocus();
} }
// This line defines the destructor, completing the type for std::unique_ptr
ConfigureDialog::~ConfigureDialog() = default; ConfigureDialog::~ConfigureDialog() = default;
void ConfigureDialog::UpdateTheme() {
QString accent_color_str;
if (UISettings::values.enable_rainbow_mode.GetValue()) {
rainbow_hue += 0.005f;
if (rainbow_hue > 1.0f) {
rainbow_hue = 0.0f;
}
accent_color_str = QColor::fromHsvF(rainbow_hue, 0.8, 1.0).name();
if (!rainbow_timer->isActive()) {
rainbow_timer->start(16); // ~60 FPS
}
} else {
if (rainbow_timer->isActive()) {
rainbow_timer->stop();
}
accent_color_str = Theme::GetAccentColor();
}
QColor accent_color(accent_color_str);
QString accent_color_hover = accent_color.lighter(115).name();
QString accent_color_pressed = accent_color.darker(120).name();
QString style_sheet = property("templateStyleSheet").toString();
style_sheet.replace(QStringLiteral("%%ACCENT_COLOR%%"), accent_color_str);
style_sheet.replace(QStringLiteral("%%ACCENT_COLOR_HOVER%%"), accent_color_hover);
style_sheet.replace(QStringLiteral("%%ACCENT_COLOR_PRESSED%%"), accent_color_pressed);
setStyleSheet(style_sheet);
}
void ConfigureDialog::SetConfiguration() {} void ConfigureDialog::SetConfiguration() {}
void ConfigureDialog::ApplyConfiguration() { void ConfigureDialog::ApplyConfiguration() {
@@ -281,9 +251,7 @@ void ConfigureDialog::HandleApplyButtonClicked() {
void ConfigureDialog::OnLanguageChanged(const QString& locale) { void ConfigureDialog::OnLanguageChanged(const QString& locale) {
emit LanguageChanged(locale); emit LanguageChanged(locale);
// Reloading the game list is needed to force retranslation.
UISettings::values.is_game_list_reload_pending = true; UISettings::values.is_game_list_reload_pending = true;
// first apply the configuration, and then restore the display
ApplyConfiguration(); ApplyConfiguration();
RetranslateUI(); RetranslateUI();
SetConfiguration(); SetConfiguration();

View File

@@ -7,16 +7,25 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <QDialog> #include <QDialog>
#include <QButtonGroup> #include "common/settings_enums.h"
#include "configuration/shared_widget.h" #include "citron/configuration/shared_widget.h" // <-- Correct header for Builder
#include "citron/configuration/configuration_shared.h"
#include "citron/configuration/shared_translation.h"
#include "citron/vk_device_info.h"
// Forward declarations for other types
class HotkeyRegistry;
class QButtonGroup;
class QTimer;
namespace InputCommon {
class InputSubsystem;
}
namespace Core { namespace Core {
class System; class System;
} }
namespace VkDeviceInfo {
struct Record;
}
namespace Ui {
class ConfigureDialog;
}
class ConfigureApplets; class ConfigureApplets;
class ConfigureAudio; class ConfigureAudio;
class ConfigureCpu; class ConfigureCpu;
@@ -27,56 +36,45 @@ class ConfigureGraphics;
class ConfigureGraphicsAdvanced; class ConfigureGraphicsAdvanced;
class ConfigureHotkeys; class ConfigureHotkeys;
class ConfigureInput; class ConfigureInput;
class ConfigureNetwork;
class ConfigureProfileManager; class ConfigureProfileManager;
class ConfigureSystem; class ConfigureSystem;
class ConfigureNetwork;
class ConfigureUi; class ConfigureUi;
class ConfigureWeb; class ConfigureWeb;
class HotkeyRegistry; class ConfigureDialog final : public QDialog {
namespace InputCommon {
class InputSubsystem;
}
namespace Ui {
class ConfigureDialog;
}
class ConfigureDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
InputCommon::InputSubsystem* input_subsystem, InputCommon::InputSubsystem* input_subsystem,
std::vector<VkDeviceInfo::Record>& vk_device_records, std::vector<VkDeviceInfo::Record>& vk_device_records,
Core::System& system_, bool enable_web_config = true); Core::System& system, bool enable_web_config);
~ConfigureDialog() override; ~ConfigureDialog() override;
void ApplyConfiguration(); void ApplyConfiguration();
private slots: public slots:
void OnLanguageChanged(const QString& locale); void UpdateTheme();
signals: signals:
void LanguageChanged(const QString& locale); void LanguageChanged(const QString& locale);
private: private:
void SetConfiguration();
void HandleApplyButtonClicked();
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
void RetranslateUI(); void RetranslateUI();
void HandleApplyButtonClicked(); void OnLanguageChanged(const QString& locale);
void SetConfiguration();
// All members are now in the EXACT correct order to match the constructor
std::unique_ptr<Ui::ConfigureDialog> ui; std::unique_ptr<Ui::ConfigureDialog> ui;
HotkeyRegistry& registry; HotkeyRegistry& registry;
Core::System& system; Core::System& system;
std::unique_ptr<ConfigurationShared::Builder> builder; std::unique_ptr<ConfigurationShared::Builder> builder;
std::vector<ConfigurationShared::Tab*> tab_group;
std::unique_ptr<QButtonGroup> tab_button_group;
std::unique_ptr<ConfigureApplets> applets_tab; std::unique_ptr<ConfigureApplets> applets_tab;
std::unique_ptr<ConfigureAudio> audio_tab; std::unique_ptr<ConfigureAudio> audio_tab;
std::unique_ptr<ConfigureCpu> cpu_tab; std::unique_ptr<ConfigureCpu> cpu_tab;
@@ -92,4 +90,7 @@ private:
std::unique_ptr<ConfigureProfileManager> profile_tab; std::unique_ptr<ConfigureProfileManager> profile_tab;
std::unique_ptr<ConfigureSystem> system_tab; std::unique_ptr<ConfigureSystem> system_tab;
std::unique_ptr<ConfigureWeb> web_tab; std::unique_ptr<ConfigureWeb> web_tab;
std::unique_ptr<QButtonGroup> tab_button_group;
QTimer* rainbow_timer;
float rainbow_hue = 0.0f;
}; };

View File

@@ -12,6 +12,7 @@
#include <utility> #include <utility>
#include <QCheckBox> #include <QCheckBox>
#include <QColorDialog>
#include <QComboBox> #include <QComboBox>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDirIterator> #include <QDirIterator>
@@ -121,26 +122,31 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
SetConfiguration(); SetConfiguration();
connect(ui->accentColorButton, &QPushButton::clicked, this, &ConfigureUi::OnAccentColorButtonPressed);
connect(ui->rainbowModeCheckBox, &QCheckBox::checkStateChanged, this, [this](int state) {
emit themeChanged();
});
// Force game list reload if any of the relevant settings are changed. // Force game list reload if any of the relevant settings are changed.
connect(ui->show_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->show_add_ons, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
connect(ui->show_compat, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->show_compat, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
connect(ui->show_size, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->show_size, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
connect(ui->show_types, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->show_types, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
connect(ui->show_play_time, &QCheckBox::stateChanged, this, connect(ui->show_play_time, &QCheckBox::checkStateChanged, this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->game_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->game_icon_size_combobox, &QComboBox::currentIndexChanged, this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->folder_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->folder_icon_size_combobox, &QComboBox::currentIndexChanged,
this, &ConfigureUi::RequestGameListUpdate); this, &ConfigureUi::RequestGameListUpdate);
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_1_text_combobox, &QComboBox::currentIndexChanged, this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_2_text_combobox, &QComboBox::currentIndexChanged, this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
// Update text ComboBoxes after user interaction. // Update text ComboBoxes after user interaction.
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated), connect(ui->row_1_text_combobox, &QComboBox::activated,
[this] { ConfigureUi::UpdateSecondRowComboBox(); }); [this] { ConfigureUi::UpdateSecondRowComboBox(); });
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated), connect(ui->row_2_text_combobox, &QComboBox::activated,
[this] { ConfigureUi::UpdateFirstRowComboBox(); }); [this] { ConfigureUi::UpdateFirstRowComboBox(); });
// Set screenshot path to user specification. // Set screenshot path to user specification.
@@ -168,6 +174,7 @@ ConfigureUi::~ConfigureUi() = default;
void ConfigureUi::ApplyConfiguration() { void ConfigureUi::ApplyConfiguration() {
UISettings::values.theme = UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString().toStdString(); ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString().toStdString();
UISettings::values.enable_rainbow_mode = ui->rainbowModeCheckBox->isChecked();
UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
UISettings::values.show_compat = ui->show_compat->isChecked(); UISettings::values.show_compat = ui->show_compat->isChecked();
UISettings::values.show_size = ui->show_size->isChecked(); UISettings::values.show_size = ui->show_size->isChecked();
@@ -198,6 +205,7 @@ void ConfigureUi::SetConfiguration() {
ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme))); ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme)));
ui->language_combobox->setCurrentIndex(ui->language_combobox->findData( ui->language_combobox->setCurrentIndex(ui->language_combobox->findData(
QString::fromStdString(UISettings::values.language.GetValue()))); QString::fromStdString(UISettings::values.language.GetValue())));
ui->rainbowModeCheckBox->setChecked(UISettings::values.enable_rainbow_mode.GetValue());
ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue()); ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue());
ui->show_compat->setChecked(UISettings::values.show_compat.GetValue()); ui->show_compat->setChecked(UISettings::values.show_compat.GetValue());
ui->show_size->setChecked(UISettings::values.show_size.GetValue()); ui->show_size->setChecked(UISettings::values.show_size.GetValue());
@@ -221,6 +229,18 @@ void ConfigureUi::SetConfiguration() {
} }
} }
void ConfigureUi::OnAccentColorButtonPressed() {
const QColor current_color(QString::fromStdString(UISettings::values.accent_color.GetValue()));
QColorDialog dialog(current_color, this);
if (dialog.exec() == QDialog::Accepted) {
const QColor color = dialog.selectedColor();
if (color.isValid()) {
UISettings::values.accent_color.SetValue(color.name().toStdString());
emit themeChanged();
}
}
}
void ConfigureUi::changeEvent(QEvent* event) { void ConfigureUi::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) { if (event->type() == QEvent::LanguageChange) {
RetranslateUI(); RetranslateUI();
@@ -263,10 +283,7 @@ void ConfigureUi::InitializeLanguageComboBox() {
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale); ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale);
} }
// Unlike other configuration changes, interface language changes need to be reflected on the connect(ui->language_combobox, &QComboBox::currentIndexChanged, this,
// interface immediately. This is done by passing a signal to the main window, and then
// retranslating when passing back.
connect(ui->language_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureUi::OnLanguageChanged); &ConfigureUi::OnLanguageChanged);
} }

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
@@ -27,11 +28,13 @@ public:
void UpdateScreenshotInfo(Settings::AspectRatio ratio, void UpdateScreenshotInfo(Settings::AspectRatio ratio,
Settings::ResolutionSetup resolution_info); Settings::ResolutionSetup resolution_info);
private slots:
void OnLanguageChanged(int index);
signals: signals:
void LanguageChanged(const QString& locale); void LanguageChanged(const QString& locale);
void themeChanged();
private slots:
void OnLanguageChanged(int index);
void OnAccentColorButtonPressed();
private: private:
void RequestGameListUpdate(); void RequestGameListUpdate();

View File

@@ -23,131 +23,7 @@
<string>UI</string> <string>UI</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string>QWidget { <string>/* This stylesheet is a template. Placeholders like %%ACCENT_COLOR%% are replaced in C++. */</string>
background-color: #2b2b2b;
color: #ffffff;
}
QGroupBox {
font-weight: bold;
border: 1px solid #3d3d3d;
border-radius: 8px;
margin-top: 12px;
padding-top: 12px;
background-color: #2b2b2b;
}
QGroupBox::title {
subcontrol-origin: margin;
left: 12px;
padding: 0 8px 0 8px;
color: #ffffff;
}
QCheckBox {
color: #ffffff;
spacing: 12px;
padding: 6px;
background-color: transparent;
min-height: 24px;
}
QCheckBox::indicator {
width: 18px;
height: 18px;
border: 2px solid #5d5d5d;
border-radius: 4px;
background-color: #3d3d3d;
}
QCheckBox::indicator:checked {
background-color: #4a9eff;
border-color: #4a9eff;
}
QCheckBox::indicator:hover {
border-color: #4a9eff;
}
QComboBox {
background-color: #3d3d3d;
border: 1px solid #5d5d5d;
border-radius: 6px;
padding: 8px 12px;
color: #ffffff;
min-width: 160px;
min-height: 28px;
}
QComboBox:hover {
border-color: #4a9eff;
background-color: #404040;
}
QComboBox:focus {
border-color: #4a9eff;
background-color: #404040;
}
QComboBox::drop-down {
border: none;
width: 24px;
subcontrol-origin: padding;
subcontrol-position: top right;
}
QComboBox::down-arrow {
width: 12px;
height: 12px;
}
QComboBox QAbstractItemView {
background-color: #3d3d3d;
border: 1px solid #4a9eff;
selection-background-color: #4a9eff;
color: #ffffff;
}
QLineEdit {
background-color: #3d3d3d;
border: 1px solid #5d5d5d;
border-radius: 6px;
padding: 8px 12px;
color: #ffffff;
min-height: 28px;
}
QLineEdit:focus {
border-color: #4a9eff;
background-color: #404040;
}
QToolButton {
background-color: #4a9eff;
color: #ffffff;
border: none;
padding: 8px 12px;
border-radius: 6px;
font-weight: bold;
min-width: 40px;
min-height: 32px;
}
QToolButton:hover {
background-color: #5dafff;
}
QToolButton:pressed {
background-color: #2980b9;
}
QLabel {
color: #ffffff;
background-color: transparent;
padding: 4px;
min-width: 140px;
}
</string>
</property> </property>
<layout class="QHBoxLayout" name="mainHorizontalLayout"> <layout class="QHBoxLayout" name="mainHorizontalLayout">
<property name="spacing"> <property name="spacing">
@@ -270,6 +146,40 @@ QLabel {
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="accentColorLayout">
<property name="spacing">
<number>16</number>
</property>
<item>
<widget class="QLabel" name="accentColorLabel">
<property name="text">
<string>Accent Color:</string>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="accentColorButton">
<property name="text">
<string>Choose Color...</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="rainbowModeCheckBox">
<property name="text">
<string>Enable Rainbow Mode</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

29
src/citron/theme.h Normal file
View File

@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QColor>
#include <QString>
#include "citron/uisettings.h"
namespace Theme {
// Gets the user-defined accent color from settings, with a default fallback.
inline QString GetAccentColor() {
return QString::fromStdString(UISettings::values.accent_color.GetValue());
}
// Gets a lighter version of the accent color for hover effects.
inline QString GetAccentColorHover() {
QColor color(GetAccentColor());
return color.lighter(115).name(); // 115% of original brightness
}
// Gets a darker version of the accent color for pressed effects.
inline QString GetAccentColorPressed() {
QColor color(GetAccentColor());
return color.darker(120).name(); // 120% of original darkness
}
} // namespace Theme

View File

@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <QSettings> #include <QSettings>

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
@@ -164,6 +165,9 @@ struct Values {
std::string theme; std::string theme;
Setting<std::string> accent_color{linkage, "#4a9eff", "accent_color", Category::Ui};
Setting<bool> enable_rainbow_mode{linkage, false, "enable_rainbow_mode", Category::Ui};
// Shortcut name <Shortcut, context> // Shortcut name <Shortcut, context>
std::vector<Shortcut> shortcuts; std::vector<Shortcut> shortcuts;