From 38dd6dc190313e507db21f6aaeda90b94e9b9768 Mon Sep 17 00:00:00 2001 From: Kyle K <190571+Docteh@users.noreply.github.com> Date: Sun, 10 Apr 2022 14:04:50 -0700 Subject: ui: Set Link Color when setting theme Long story short, QT doesn't allow the link colors to be set via their stylesheets. There are two ways to work with this, specify the color manually for every link (See the About dialog) The other way is to change the default palette. IsDarkTheme is copy/pasted from src/yuzu/debugger/wait_tree.cpp --- src/yuzu/main.cpp | 10 ++++++++++ src/yuzu/uisettings.cpp | 8 ++++++++ src/yuzu/uisettings.h | 2 ++ 3 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 62d15f8cd..d1be08edb 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3652,6 +3652,16 @@ void GMainWindow::UpdateUITheme() { setStyleSheet({}); } + QPalette new_pal(qApp->palette()); + if (UISettings::IsDarkTheme()) { + new_pal.setColor(QPalette::Text, QColor(255, 255, 255, 255)); + new_pal.setColor(QPalette::Link, QColor(0, 190, 255, 255)); + } else { + new_pal.setColor(QPalette::Text, QColor(0, 0, 0, 255)); + new_pal.setColor(QPalette::Link, QColor(0, 140, 200, 255)); + } + qApp->setPalette(new_pal); + QIcon::setThemeName(current_theme); QIcon::setThemeSearchPaths(theme_paths); } diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp index 21683576c..f683b80f7 100644 --- a/src/yuzu/uisettings.cpp +++ b/src/yuzu/uisettings.cpp @@ -15,6 +15,14 @@ const Themes themes{{ {"Midnight Blue Colorful", "colorful_midnight_blue"}, }}; +bool IsDarkTheme() { + const auto& theme = UISettings::values.theme; + return theme == QStringLiteral("qdarkstyle") || + theme == QStringLiteral("qdarkstyle_midnight_blue") || + theme == QStringLiteral("colorful_dark") || + theme == QStringLiteral("colorful_midnight_blue"); +} + Values values = {}; } // namespace UISettings diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index cc5aee382..15ba9ea17 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -17,6 +17,8 @@ namespace UISettings { +bool IsDarkTheme(); + struct ContextualShortcut { QString keyseq; QString controller_keyseq; -- cgit v1.2.3 From f6695814beb2db2bf9884c22f760476d65753040 Mon Sep 17 00:00:00 2001 From: Kyle K <190571+Docteh@users.noreply.github.com> Date: Tue, 12 Apr 2022 12:50:56 -0700 Subject: ui: Touching QPalette::Text broke dark -> light UI. don't do --- src/yuzu/main.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index d1be08edb..52879a989 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3654,10 +3654,8 @@ void GMainWindow::UpdateUITheme() { QPalette new_pal(qApp->palette()); if (UISettings::IsDarkTheme()) { - new_pal.setColor(QPalette::Text, QColor(255, 255, 255, 255)); new_pal.setColor(QPalette::Link, QColor(0, 190, 255, 255)); } else { - new_pal.setColor(QPalette::Text, QColor(0, 0, 0, 255)); new_pal.setColor(QPalette::Link, QColor(0, 140, 200, 255)); } qApp->setPalette(new_pal); -- cgit v1.2.3