mirror of
https://git.suyu.dev/suyu/suyu
synced 2025-09-20 13:02:08 -05:00
Automatic dark theme switching for Windows and Linux
- Windows dark theme uses "fusion" style, which is better suited, but has minor differences - Improve OS theme detection - Linux: - Listen for OS color schemes changes on D-Bus - Read OS scheme for D-Bus. Fallback with gsettings, reading org.gnome.desktop.interface. First "color-scheme" key, then "gtk-theme". Finally, fallback to checking window palette - Windows (dark mode detection was not implemented before): - Force dark palette when OS uses dark mode by setting QT_QPA_PLATFORM to "windows:darkmode=2" - This enables to detect dark mode by checking the window palette - Improve theming capabilites: - Linux uses custom palette when dark mode is detected. By using palette(xxx) in .qss files, there is no need to create a dark stylesheet - Allow themes to have stylesheet variants, dark.qss and light.qss - If current mode is dark, use dark icons for controller and keyboard applets - Add "dark" property to RendererStatusBarButton and GPUStatusBarButton, set to true when dark mode is used. Allows to have distinct colors for GPU API and accuracy buttons depending on dark mode or not - Enable all themes to have dark icon alternatives, not just "default" and "colorful" - If dark mode, icons are loaded from the directory "THEME-NAME_dark/icons" - If current mode is dark, use dark icons for controller and keyboard applets - Only qdarkstyle, qdarkstyle_midnight_blue, colorful_dark and colorful_midnight_blue used elements specific to dark themes
This commit is contained in:
@@ -25,9 +25,8 @@
|
||||
#include "suyu/util/controller_navigation.h"
|
||||
|
||||
#ifdef __unix__
|
||||
#include <QSocketNotifier>
|
||||
#include <QVariant>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QtDBus>
|
||||
#endif
|
||||
|
||||
class QtConfig;
|
||||
@@ -165,14 +164,9 @@ class GMainWindow : public QMainWindow {
|
||||
CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING,
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to load a stylesheet from its path. If the path starts with ":/", its embedded in the app
|
||||
* @returns true if the text file could be opened as read-only
|
||||
*/
|
||||
bool tryLoadStylesheet(const QString& theme_path);
|
||||
|
||||
public:
|
||||
void filterBarSetChecked(bool state);
|
||||
static bool CheckDarkMode();
|
||||
void UpdateUITheme();
|
||||
explicit GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulkan);
|
||||
~GMainWindow() override;
|
||||
@@ -265,12 +259,44 @@ private:
|
||||
|
||||
void SetDefaultUIGeometry();
|
||||
void RestoreUIState();
|
||||
/**
|
||||
* Load the icons used by the current theme. Use dark icons if the current mode is dark
|
||||
*/
|
||||
void UpdateIcons(const QString& theme_used);
|
||||
/**
|
||||
* Set the palette used by the stylsheet for the dark/light mode selected, according to the OS
|
||||
*/
|
||||
void UpdateThemePalette();
|
||||
/**
|
||||
* Try to load a stylesheet from its URI.
|
||||
* If the path starts with ":/", its embedded in the app, otherwise its in a local directory
|
||||
* @returns true if the text file could be opened as read-only
|
||||
*/
|
||||
bool TryLoadStylesheet(const QString& theme_uri);
|
||||
/**
|
||||
* Try to load a stylesheet from filesystem path
|
||||
* @returns true if the text file could be opened as read-only
|
||||
*/
|
||||
bool TryLoadStylesheet(const std::filesystem::path& theme_path);
|
||||
/**
|
||||
* Default customizations to the stylesheets
|
||||
*/
|
||||
void SetCustomStylesheet();
|
||||
#ifdef __unix__
|
||||
/**
|
||||
* Create a signal to update the UI theme when the OS color scheme is changed
|
||||
* @returns true if we could connect to dbus
|
||||
*/
|
||||
bool ListenColorSchemeChange();
|
||||
#endif
|
||||
|
||||
void ConnectWidgetEvents();
|
||||
void ConnectMenuEvents();
|
||||
void UpdateMenuState();
|
||||
|
||||
#ifdef __unix__
|
||||
void SetupPrepareForSleep();
|
||||
#endif
|
||||
|
||||
void PreventOSSleep();
|
||||
void AllowOSSleep();
|
||||
@@ -401,6 +427,7 @@ private slots:
|
||||
void ResetWindowSize720();
|
||||
void ResetWindowSize900();
|
||||
void ResetWindowSize1080();
|
||||
void UpdateUITheme();
|
||||
void OnAlbum();
|
||||
void OnCabinet(Service::NFP::CabinetMode mode);
|
||||
void OnMiiEdit();
|
||||
@@ -447,7 +474,7 @@ private:
|
||||
void OpenURL(const QUrl& url);
|
||||
void LoadTranslation();
|
||||
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
|
||||
bool CheckDarkMode();
|
||||
bool CheckSystemArchiveDecryption();
|
||||
bool CheckFirmwarePresence();
|
||||
void SetFirmwareVersion();
|
||||
void ConfigureFilesystemProvider(const std::string& filepath);
|
||||
@@ -531,7 +558,8 @@ private:
|
||||
QTimer update_input_timer;
|
||||
|
||||
QString startup_icon_theme;
|
||||
bool os_dark_mode = false;
|
||||
bool alternate_base_modified = false;
|
||||
QColor last_window_color;
|
||||
|
||||
// FS
|
||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||
|
Reference in New Issue
Block a user