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
- Add "qdarkstyle_monochrome" theme
- Remove duplicated icon files
This commit is contained in:
flodavid 2024-02-04 04:05:50 +01:00
parent 91d8666bb1
commit e88e93e055
82 changed files with 525 additions and 1251 deletions

View file

@ -164,7 +164,6 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<resources>
<include location="../../dist/qt_themes_default/default/default.qrc"/>
<include location="../../dist/qt_themes/default/default.qrc"/>
</resources>
<connections>

View file

@ -7,7 +7,6 @@
#include <fstream>
#include <iostream>
#include <memory>
#include <QStyleFactory>
#include <thread>
#include "core/hle/service/am/applet_manager.h"
@ -330,12 +329,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();
@ -3799,8 +3797,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);
@ -4845,8 +4841,10 @@ void GMainWindow::UpdateUITheme() {
void GMainWindow::UpdateIcons(const QString& theme_used) {
// Append _dark to the theme name to use dark variant icons
if (CheckDarkMode()) {
LOG_DEBUG(Frontend, "Using icons from: {}", theme_used.toStdString() + "_dark");
QIcon::setThemeName(theme_used + QStringLiteral("_dark"));
} else {
LOG_DEBUG(Frontend, "Using icons from: {}", theme_used.toStdString());
QIcon::setThemeName(theme_used);
}
@ -5041,9 +5039,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();
@ -5107,7 +5105,8 @@ void GMainWindow::changeEvent(QEvent* event) {
UpdateUITheme();
}
} else QWidget::changeEvent(event);
}
QWidget::changeEvent(event);
}
void GMainWindow::LoadTranslation() {

View file

@ -166,7 +166,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

@ -24,11 +24,11 @@ namespace UISettings {
const Themes included_themes{{
{"Default", "default"},
{"Default Colorful", "colorful"},
{"Dark", "qdarkstyle"},
{"Dark Colorful", "colorful_dark"},
{"Default monochrome", "monochrome"},
{"Mine Shaft", "qdarkstyle"},
{"Mine Shaft monochrome", "qdarkstyle_monochrome"},
{"Midnight Blue", "qdarkstyle_midnight_blue"},
{"Midnight Blue Colorful", "colorful_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;