1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-08-31 16:36:34 -05:00

Rework themes to easily use light/dark palette, using only different icons

- Renamed themes:
  - "colorful" to "default" and "colorful_dark" to "default_dark"
  - "default" to "monochrome" and "default_dark" to "monochrome_dark"
  - "colorful_midnight_blue" to "qdarkstyle_midnight_blue"
  - "qdarkstyle_midnight_blue" to "qdarkstyle_midnight_blue_monochrome"
  - qdarkstyle is renamed from "Dark" to "Mine Shaft" in the UI
- default and monochrome themes all use the same qss stylesheet
- Remove the ability to select "default_dark" directly
    - Default has better support for light and dark
    - Controller and Keyboard applets icons and style adapt to dark mode
- Add "qdarkstyle_monochrome" theme
- Remove duplicated icon files
This commit is contained in:
flodavid
2024-02-04 04:05:50 +01:00
committed by Crimson Hawk
parent f01d7305c0
commit 104e6c3ff7
115 changed files with 685 additions and 1586 deletions

View File

@@ -372,6 +372,14 @@ QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() {
StopInputThread();
}
QString QtSoftwareKeyboardDialog::theme() {
if (GMainWindow::CheckDarkMode()) {
return QStringLiteral("_dark");
} else {
return QString{};
}
}
void QtSoftwareKeyboardDialog::ShowNormalKeyboard(QPoint pos, QSize size) {
if (isVisible()) {
return;
@@ -382,6 +390,7 @@ void QtSoftwareKeyboardDialog::ShowNormalKeyboard(QPoint pos, QSize size) {
SetKeyboardType();
SetPasswordMode();
SetControllerImage();
SetButtonImages();
DisableKeyboardButtons();
SetBackspaceOkEnabled();
@@ -449,6 +458,7 @@ void QtSoftwareKeyboardDialog::ShowInlineKeyboard(
SetKeyboardType();
SetControllerImage();
SetButtonImages();
DisableKeyboardButtons();
SetBackspaceOkEnabled();
@@ -822,70 +832,146 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
const auto controller_type =
handheld->IsConnected() ? handheld->GetNpadStyleIndex() : player_1->GetNpadStyleIndex();
const QString theme = [] {
// Use dark icons if current OS mode is dark, or the theme contains "dark", or "midnight" in
// its name
if (GMainWindow::CheckDarkMode() || QIcon::themeName().contains(QStringLiteral("dark")) ||
QIcon::themeName().contains(QStringLiteral("midnight"))) {
return QStringLiteral("_dark");
} else {
return QString{};
}
}();
switch (controller_type) {
case Core::HID::NpadStyleIndex::Fullkey:
case Core::HID::NpadStyleIndex::GameCube:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_pro.png);").arg(theme()));
ui->icon_controller_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_pro.png);").arg(theme()));
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_pro.png);").arg(theme()));
break;
case Core::HID::NpadStyleIndex::JoyconDual:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_dual_joycon.png);").arg(theme()));
ui->icon_controller_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_dual_joycon.png);").arg(theme()));
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_dual_joycon.png);").arg(theme()));
break;
case Core::HID::NpadStyleIndex::JoyconLeft:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_left.png);")
.arg(theme()));
ui->icon_controller_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_left.png);")
.arg(theme()));
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_left.png);")
.arg(theme()));
break;
case Core::HID::NpadStyleIndex::JoyconRight:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_right.png);")
.arg(theme()));
ui->icon_controller_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_right.png);")
.arg(theme()));
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
.arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_single_joycon_right.png);")
.arg(theme()));
break;
case Core::HID::NpadStyleIndex::Handheld:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_handheld.png);").arg(theme()));
ui->icon_controller_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_handheld.png);").arg(theme()));
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme));
QStringLiteral("image: url(:/overlay%1/controller_handheld.png);").arg(theme()));
break;
default:
break;
}
}
void QtSoftwareKeyboardDialog::SetButtonImages() {
QString button_backspace_stylesheet =
QStringLiteral("QPushButton {"
" image: url(:/overlay%1/osk_button_B.png);"
" image-position: right;"
" qproperty-icon: url(:/overlay%1/osk_button_backspace.png); }"
"QPushButton:disabled { image: url(:/overlay%1/osk_button_B_disabled.png);}")
.arg(theme());
ui->button_backspace->setStyleSheet(button_backspace_stylesheet);
ui->button_backspace_shift->setStyleSheet(button_backspace_stylesheet);
ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize());
ui->button_backspace_num->setStyleSheet(button_backspace_stylesheet);
QString button_space_stylesheet =
QStringLiteral("QPushButton {"
" image: url(:/overlay%1/osk_button_Y.png);"
" image-position: right;"
" qproperty-icon: url(:/overlay%1/osk_button_space.png); }"
"QPushButton:disabled { image: url(:/overlay%1/osk_button_Y_disabled.png);}")
.arg(theme());
ui->button_space->setStyleSheet(button_space_stylesheet);
ui->button_space_shift->setStyleSheet(button_space_stylesheet);
QString button_ok_stylesheet =
QStringLiteral(
"QPushButton { image: url(:/overlay%1/osk_button_plus.png); }"
"QPushButton:disabled { image: url(:/overlay%1/osk_button_plus_disabled.png); }")
.arg(theme());
ui->button_ok->setStyleSheet(button_ok_stylesheet);
ui->button_ok_shift->setStyleSheet(button_ok_stylesheet);
ui->button_ok_num->setStyleSheet(button_ok_stylesheet);
QString button_shift_stylesheet =
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);"
"image-position: left;"
"qproperty-icon: url(:/overlay%1/osk_button_shift.png);")
.arg(theme());
ui->button_shift->setStyleSheet(button_shift_stylesheet);
QString button_shift_shift_stylesheet =
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);"
"image-position: left;"
"qproperty-icon: url(:/overlay%1/osk_button_shift_on.png);")
.arg(theme());
ui->button_shift_shift->setStyleSheet(button_shift_shift_stylesheet);
ui->button_shift_shift->setIconSize(ui->button_shift->iconSize());
QString L_stylesheet = QStringLiteral("image: url(:/overlay%1/button_L.png);").arg(theme());
ui->button_L->setStyleSheet(L_stylesheet);
ui->button_L_shift->setStyleSheet(L_stylesheet);
ui->button_L_num->setStyleSheet(L_stylesheet);
QString R_stylesheet = QStringLiteral("image: url(:/overlay%1/button_R.png);").arg(theme());
ui->button_R->setStyleSheet(R_stylesheet);
ui->button_R_shift->setStyleSheet(R_stylesheet);
ui->button_R_num->setStyleSheet(R_stylesheet);
QString arrow_left_stylesheet =
QStringLiteral("image: url(:/overlay%1/arrow_left.png);").arg(theme());
ui->arrow_left->setStyleSheet(arrow_left_stylesheet);
ui->arrow_left_shift->setStyleSheet(arrow_left_stylesheet);
ui->arrow_left_num->setStyleSheet(arrow_left_stylesheet);
QString arrow_right_stylesheet =
QStringLiteral("image: url(:/overlay%1/arrow_right.png);").arg(theme());
ui->arrow_right->setStyleSheet(arrow_right_stylesheet);
ui->arrow_right_shift->setStyleSheet(arrow_right_stylesheet);
ui->arrow_right_num->setStyleSheet(arrow_right_stylesheet);
QString button_press_stick_stylesheet =
QStringLiteral("image: url(:/overlay%1/button_press_stick.png);").arg(theme());
ui->button_press_stick->setStyleSheet(button_press_stick_stylesheet);
ui->button_press_stick_shift->setStyleSheet(button_press_stick_stylesheet);
QString button_X_stylesheet =
QStringLiteral("image: url(:/overlay%1/button_X.png);").arg(theme());
ui->button_X->setStyleSheet(button_X_stylesheet);
ui->button_X_shift->setStyleSheet(button_X_stylesheet);
ui->button_X_num->setStyleSheet(button_X_stylesheet);
QString button_A_stylesheet =
QStringLiteral("image: url(:/overlay%1/button_A.png);").arg(theme());
ui->button_A->setStyleSheet(button_A_stylesheet);
ui->button_A_shift->setStyleSheet(button_A_stylesheet);
ui->button_A_num->setStyleSheet(button_A_stylesheet);
}
void QtSoftwareKeyboardDialog::DisableKeyboardButtons() {
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
@@ -1052,10 +1138,8 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() {
ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index));
ui->button_shift_shift->setStyleSheet(
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);"
"\nimage-position: left;"));
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);"));
ui->button_shift_shift->setIconSize(ui->button_shift->iconSize());
ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize());
break;
case BottomOSKIndex::UpperCase:
@@ -1066,9 +1150,6 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() {
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);"
"\nimage-position: left;"));
ui->button_shift_shift->setIconSize(ui->button_shift->iconSize());
ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize());
ui->label_shift_shift->setText(QStringLiteral("Caps Lock"));
bottom_osk_index = BottomOSKIndex::LowerCase;
@@ -1080,9 +1161,6 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() {
QStringLiteral("image: url(:/overlay/osk_button_shift_lock_on.png);"
"\nimage-position: left;"));
ui->button_shift_shift->setIconSize(ui->button_shift->iconSize());
ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize());
ui->label_shift_shift->setText(QStringLiteral("Caps Lock Off"));
}
break;

View File

@@ -80,6 +80,12 @@ private:
NumberPad,
};
/**
* Get the current theme suffix
* @return an empty string for light theme, "_dark" for dark theme
*/
QString theme();
/**
* Moves and resizes the window to a specified position and size.
*
@@ -109,6 +115,9 @@ private:
/// Sets the controller image at the bottom left of the software keyboard.
void SetControllerImage();
/// Sets the controller image at the bottom left of the software keyboard.
void SetButtonImages();
/// Disables buttons based on initialize_parameters.
void DisableKeyboardButtons();

View File

@@ -9,7 +9,6 @@
#include <fstream>
#include <iostream>
#include <memory>
#include <QStyleFactory>
#include <thread>
#include "core/hle/service/am/applet_manager.h"
@@ -297,12 +296,11 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
statusBar()->hide();
startup_icon_theme = QIcon::themeName();
// fallback can only be set once, colorful theme icons are okay on both light/dark
QIcon::setFallbackThemeName(QStringLiteral("colorful"));
// fallback can only be set once, default theme icons are okay on both light/dark
QIcon::setFallbackThemeName(QStringLiteral("default"));
QIcon::setFallbackSearchPaths(QStringList(QStringLiteral(":/icons")));
default_theme_paths = QIcon::themeSearchPaths();
UpdateUITheme();
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
discord_rpc->Update();
@@ -3612,8 +3610,6 @@ void GMainWindow::OnConfigure() {
multiplayer_state->UpdateCredentials();
}
emit UpdateThemedIcons();
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
if (reload || Settings::values.language_index.GetValue() != old_language_index) {
game_list->PopulateAsync(UISettings::values.game_dirs);
@@ -5030,9 +5026,9 @@ bool GMainWindow::CheckDarkMode() {
// Using the freedesktop specifications for checking dark mode
LOG_INFO(Frontend, "Retrieving theme from freedesktop color-scheme...");
gdbus_arguments << QStringLiteral("--dest=org.freedesktop.portal.Desktop")
<< QStringLiteral("--object-path /org/freedesktop/portal/desktop")
<< QStringLiteral("--method org.freedesktop.portal.Settings.Read "
"org.freedesktop.appearance color-scheme");
<< QStringLiteral("--object-path /org/freedesktop/portal/desktop")
<< QStringLiteral("--method org.freedesktop.portal.Settings.Read")
<< QStringLiteral("org.freedesktop.appearance color-scheme");
process.start(QStringLiteral("gdbus call --session"), gdbus_arguments);
process.waitForFinished(1000);
QByteArray dbus_output = process.readAllStandardOutput();
@@ -5096,7 +5092,8 @@ void GMainWindow::changeEvent(QEvent* event) {
UpdateUITheme();
}
} else QWidget::changeEvent(event);
}
QWidget::changeEvent(event);
}
void GMainWindow::LoadTranslation() {

View File

@@ -167,7 +167,6 @@ class GMainWindow : public QMainWindow {
public:
void filterBarSetChecked(bool state);
static bool CheckDarkMode();
void UpdateUITheme();
explicit GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulkan);
~GMainWindow() override;

View File

@@ -23,12 +23,12 @@ namespace FS = Common::FS;
namespace UISettings {
const Themes included_themes{{
{"Default", ":/default/"},
{"Default Colorful", ":/colorful/"},
{"Dark", ":/qdarkstyle/"},
{"Dark Colorful", ":/colorful_dark/"},
{"Midnight Blue", ":/qdarkstyle_midnight_blue/"},
{"Midnight Blue Colorful", ":/colorful_midnight_blue/"},
{"Default", ":/default"},
{"Default monochrome", ":/monochrome"},
{"Mine Shaft", ":/qdarkstyle"},
{"Mine Shaft monochrome", ":/qdarkstyle_monochrome"},
{"Midnight Blue", ":/qdarkstyle_midnight_blue"},
{"Midnight Blue monochrome", ":/qdarkstyle_midnight_blue_monochrome"},
}};
Values values = {};

View File

@@ -48,7 +48,7 @@ struct Shortcut {
ContextualShortcut shortcut;
};
static constexpr std::string_view default_theme{"colorful"};
static constexpr std::string_view default_theme{":/default"};
using Themes = std::array<std::pair<const char*, const char*>, 6>;
extern const Themes included_themes;