diff --git a/rpcs3/Json/tooltips.json b/rpcs3/Json/tooltips.json index c4ccf6f632..8be96d9620 100644 --- a/rpcs3/Json/tooltips.json +++ b/rpcs3/Json/tooltips.json @@ -49,7 +49,8 @@ "gui": { "configs": "Only useful to developers.\nIf unsure, don't use this option.", "stylesheets": "Only useful to developers.\nIf unsure, don't use this option.", - "show_welcome": "Shows the initial welcome screen upon starting RPCS3." + "show_welcome": "Shows the initial welcome screen upon starting RPCS3.", + "custom_colors": "Prioritize custom user interface colors over properties set in stylesheet." }, "misc": { "exitOnStop": "Automatically close RPCS3 when closing a game, or when a game closes itself.", diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index 5090210721..78e8432fbb 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -299,6 +299,7 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& sheetFilePath) setStyleSheet(file.readAll()); file.close(); } + GUI::stylesheet = styleSheet(); } /** diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index edbe0ed408..69a2c10135 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -849,7 +849,16 @@ void game_list_frame::SetSearchText(const QString& text) void game_list_frame::RepaintToolBarIcons() { - QColor newColor = xgui_settings->GetValue(GUI::gl_toolIconColor).value(); + QColor newColor; + + if (xgui_settings->GetValue(GUI::m_enableUIColors).toBool()) + { + newColor = GUI::get_Label_Color("gamelist_toolbar_icon_color"); + } + else + { + newColor = xgui_settings->GetValue(GUI::gl_toolIconColor).value(); + } m_catActHDD.colored = gui_settings::colorizedIcon(QIcon(":/Icons/hdd_blue.png"), GUI::gl_tool_icon_color, newColor, true); m_catActDisc.colored = gui_settings::colorizedIcon(QIcon(":/Icons/disc_blue.png"), GUI::gl_tool_icon_color, newColor, true); diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index 259abff978..05930f9b56 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -299,7 +299,7 @@ QString gui_settings::GetCurrentStylesheetPath() { QString stylesheet = GetValue(GUI::m_currentStylesheet).toString(); - if (stylesheet == "default") + if (stylesheet == GUI::Default) { return ""; } diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index f7ff1f9621..e779c66e10 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -8,6 +8,7 @@ #include #include #include +#include struct GUI_SAVE { @@ -35,6 +36,8 @@ typedef QList q_size_list; namespace GUI { + static QString stylesheet; + const QSize gl_icon_size_min = QSize(40, 22); const QSize gl_icon_size_small = QSize(80, 44); const QSize gl_icon_size_medium = QSize(160, 88); @@ -42,12 +45,22 @@ namespace GUI const int gl_max_slider_pos = 100; - inline int get_Index(const QSize& current) { + inline int get_Index(const QSize& current) + { int size_delta = gl_icon_size_max.width() - gl_icon_size_min.width(); int current_delta = current.width() - gl_icon_size_min.width(); return gl_max_slider_pos * current_delta / size_delta; }; + inline QColor get_Label_Color(const QString& objectName, QPalette::ColorRole colorRole = QPalette::Foreground) + { + QLabel dummy_color; + dummy_color.setObjectName(objectName); + dummy_color.ensurePolished(); + return dummy_color.palette().color(colorRole); + }; + + const QString Default = QObject::tr("default"); const QString main_window = "main_window"; const QString game_list = "GameList"; const QString logger = "Logger"; @@ -117,9 +130,10 @@ namespace GUI const GUI_SAVE d_splitterState = GUI_SAVE( debugger, "splitterState", QByteArray()); const GUI_SAVE m_currentConfig = GUI_SAVE(meta, "currentConfig", QObject::tr("CurrentSettings")); - const GUI_SAVE m_currentStylesheet = GUI_SAVE(meta, "currentStylesheet", QObject::tr("default")); + const GUI_SAVE m_currentStylesheet = GUI_SAVE(meta, "currentStylesheet", Default); const GUI_SAVE m_saveNotes = GUI_SAVE(meta, "saveNotes", QVariantMap()); const GUI_SAVE m_showDebugTab = GUI_SAVE(meta, "showDebugTab", false); + const GUI_SAVE m_enableUIColors = GUI_SAVE(meta, "enableUIColors", false); const GUI_SAVE gs_disableMouse = GUI_SAVE(gs_frame, "disableMouse", false); const GUI_SAVE gs_resize = GUI_SAVE(gs_frame, "resize", false); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index ca6e0fb42d..6b8223915c 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -70,8 +70,6 @@ void main_window::Init() { ui->setupUi(this); - // Load Icons: This needs to happen before any actions or buttons are created - RepaintToolBarIcons(); appIcon = QIcon(":/rpcs3.ico"); // add toolbar widgets (crappy Qt designer is not able to) @@ -100,6 +98,8 @@ void main_window::Init() Q_EMIT RequestGlobalStylesheetChange(guiSettings->GetCurrentStylesheetPath()); ConfigureGuiFromSettings(true); + RepaintToolBarIcons(); + gameListFrame->RepaintToolBarIcons(); if (!utils::has_ssse3()) { @@ -694,7 +694,16 @@ void main_window::SaveWindowState() void main_window::RepaintToolBarIcons() { - QColor newColor = guiSettings->GetValue(GUI::mw_toolIconColor).value(); + QColor newColor; + + if (guiSettings->GetValue(GUI::m_enableUIColors).toBool()) + { + newColor = GUI::get_Label_Color("toolbar_icon_color"); + } + else + { + newColor = guiSettings->GetValue(GUI::mw_toolIconColor).value(); + } icon_play = gui_settings::colorizedIcon(QIcon(":/Icons/play.png"), GUI::mw_tool_icon_color, newColor); icon_pause = gui_settings::colorizedIcon(QIcon(":/Icons/pause.png"), GUI::mw_tool_icon_color, newColor); @@ -1026,14 +1035,23 @@ void main_window::AddRecentAction(const q_string_pair& entry) void main_window::RepaintToolbar() { - QColor tbc = guiSettings->GetValue(GUI::mw_toolBarColor).value(); - ui->toolBar->setStyleSheet(styleSheet().append( - "QToolBar { background-color: rgba(%1, %2, %3, %4); }" - "QToolBar::separator {background-color: rgba(%5, %6, %7, %8); width: 1px; margin-top: 2px; margin-bottom: 2px;}" - "QSlider { background-color: rgba(%1, %2, %3, %4); }" - "QLineEdit { background-color: rgba(%1, %2, %3, %4); }") - .arg(tbc.red()).arg(tbc.green()).arg(tbc.blue()).arg(tbc.alpha()) - .arg(tbc.red() - 20).arg(tbc.green() - 20).arg(tbc.blue() - 20).arg(tbc.alpha() - 20)); + if (guiSettings->GetValue(GUI::m_enableUIColors).toBool()) + { + ui->toolBar->setStyleSheet(GUI::stylesheet); + } + else + { + QColor tbc = guiSettings->GetValue(GUI::mw_toolBarColor).value(); + + ui->toolBar->setStyleSheet(GUI::stylesheet + QString( + "QToolBar { background-color: rgba(%1, %2, %3, %4); }" + "QToolBar::separator {background-color: rgba(%5, %6, %7, %8); width: 1px; margin-top: 2px; margin-bottom: 2px;}" + "QSlider { background-color: rgba(%1, %2, %3, %4); }" + "QLineEdit { background-color: rgba(%1, %2, %3, %4); }") + .arg(tbc.red()).arg(tbc.green()).arg(tbc.blue()).arg(tbc.alpha()) + .arg(tbc.red() - 20).arg(tbc.green() - 20).arg(tbc.blue() - 20).arg(tbc.alpha() - 20) + ); + } } void main_window::CreateActions() @@ -1116,7 +1134,14 @@ void main_window::CreateConnects() connect(&dlg, &settings_dialog::ToolBarRepaintRequest, this, &main_window::RepaintToolBarIcons); connect(&dlg, &settings_dialog::ToolBarRepaintRequest, gameListFrame, &game_list_frame::RepaintToolBarIcons); connect(&dlg, &settings_dialog::accepted, [this](){ - gameListFrame->RepaintIcons(guiSettings->GetValue(GUI::gl_iconColor).value()); + if (guiSettings->GetValue(GUI::m_enableUIColors).toBool()) + { + gameListFrame->RepaintIcons(GUI::get_Label_Color("gamelist_icon_background_color")); + } + else + { + gameListFrame->RepaintIcons(guiSettings->GetValue(GUI::gl_iconColor).value()); + } RepaintToolbar(); }); dlg.exec(); diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index b33bb9c572..1ea53f0e37 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -669,6 +669,8 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const ui->cb_show_welcome->setToolTip(json_emu_gui["show_welcome"].toString()); + ui->cb_custom_colors->setToolTip(json_emu_gui["custom_colors"].toString()); + xemu_settings->EnhanceCheckBox(ui->exitOnStop, emu_settings::ExitRPCS3OnFinish); ui->exitOnStop->setToolTip(json_emu_misc["exitOnStop"].toString()); @@ -691,6 +693,13 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const { ui->cb_show_welcome->setChecked(xgui_settings->GetValue(GUI::ib_show_welcome).toBool()); + bool enableUIColors = xgui_settings->GetValue(GUI::m_enableUIColors).toBool(); + ui->cb_custom_colors->setChecked(enableUIColors); + ui->pb_gl_icon_color->setEnabled(enableUIColors); + ui->pb_gl_tool_icon_color->setEnabled(enableUIColors); + ui->pb_tool_bar_color->setEnabled(enableUIColors); + ui->pb_tool_icon_color->setEnabled(enableUIColors); + connect(ui->okButton, &QAbstractButton::clicked, [this]() { // Only attempt to load a config if changes occurred. if (m_startingConfig != xgui_settings->GetValue(GUI::m_currentConfig).toString()) @@ -707,8 +716,8 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { xgui_settings->Reset(true); - xgui_settings->ChangeToConfig(tr("default")); - Q_EMIT GuiStylesheetRequest(tr("default")); + xgui_settings->ChangeToConfig(GUI::Default); + Q_EMIT GuiStylesheetRequest(GUI::Default); Q_EMIT GuiSettingsSyncRequest(); AddConfigs(); AddStylesheets(); @@ -719,6 +728,13 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const connect(ui->pb_apply_stylesheet, &QAbstractButton::clicked, this, &settings_dialog::OnApplyStylesheet); connect(ui->pb_open_folder, &QAbstractButton::clicked, [=]() {QDesktopServices::openUrl(xgui_settings->GetSettingsDir()); }); connect(ui->cb_show_welcome, &QCheckBox::clicked, [=](bool val) {xgui_settings->SetValue(GUI::ib_show_welcome, val); }); + connect(ui->cb_custom_colors, &QCheckBox::clicked, [=](bool val) { + xgui_settings->SetValue(GUI::m_enableUIColors, val); + ui->pb_gl_icon_color->setEnabled(val); + ui->pb_gl_tool_icon_color->setEnabled(val); + ui->pb_tool_bar_color->setEnabled(val); + ui->pb_tool_icon_color->setEnabled(val); + }); auto colorDialog = [&](const GUI_SAVE& color, const QString& title, QPushButton *button){ QColor oldColor = xgui_settings->GetValue(color).value(); QColorDialog dlg(oldColor, this); @@ -858,11 +874,11 @@ void settings_dialog::AddConfigs() { ui->combo_configs->clear(); - ui->combo_configs->addItem(tr("default")); + ui->combo_configs->addItem(GUI::Default); for (QString entry : xgui_settings->GetConfigEntries()) { - if (entry != tr("default")) + if (entry != GUI::Default) { ui->combo_configs->addItem(entry); } @@ -886,20 +902,19 @@ void settings_dialog::AddStylesheets() { ui->combo_stylesheets->clear(); - ui->combo_stylesheets->addItem(tr("default")); + ui->combo_stylesheets->addItem(GUI::Default); for (QString entry : xgui_settings->GetStylesheetEntries()) { - if (entry != tr("default")) + if (entry != GUI::Default) { ui->combo_stylesheets->addItem(entry); } } - QString currentSelection = xgui_settings->GetValue(GUI::m_currentStylesheet).toString(); - m_startingStylesheet = currentSelection; + m_startingStylesheet = xgui_settings->GetValue(GUI::m_currentStylesheet).toString(); - int index = ui->combo_stylesheets->findText(currentSelection); + int index = ui->combo_stylesheets->findText(m_startingStylesheet); if (index != -1) { ui->combo_stylesheets->setCurrentIndex(index); diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 6dfcb53a6a..677bca9788 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -1200,9 +1200,16 @@ - UI Colors (difficult in stylesheets) + UI Colors + + + + Use custom UI Colors + + +