From 440ac5ddb0d2520999fa5be3f6d26b23d07b7fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Ho=CC=88llt?= Date: Thu, 5 Oct 2023 17:18:13 +0200 Subject: [PATCH] Forces light theme on macOS until all icons can be drawn for the dark theme --- HDPS/src/ApplicationSettingsAction.cpp | 5 ++++- HDPS/src/util/MacThemeHelper.h | 3 ++- HDPS/src/util/MacThemeHelper.mm | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/HDPS/src/ApplicationSettingsAction.cpp b/HDPS/src/ApplicationSettingsAction.cpp index a0ad5ad3d..0ad1c21ad 100644 --- a/HDPS/src/ApplicationSettingsAction.cpp +++ b/HDPS/src/ApplicationSettingsAction.cpp @@ -21,7 +21,10 @@ ApplicationSettingsAction::ApplicationSettingsAction(QObject* parent) : bool themesAvailable = false; #ifdef Q_OS_MACX - themesAvailable = macDarkThemeAvailable(); + //themesAvailable = macDarkThemeAvailable(); + // Temporary no option is provided, instead we fix for the light theme. + // While changing the theme works, there is still a number of icons that do not work on dark theme. + macSetToLightTheme(); #endif // Q_OS_MACX if( themesAvailable ) diff --git a/HDPS/src/util/MacThemeHelper.h b/HDPS/src/util/MacThemeHelper.h index dde1c0e81..65229d350 100644 --- a/HDPS/src/util/MacThemeHelper.h +++ b/HDPS/src/util/MacThemeHelper.h @@ -6,5 +6,6 @@ bool macIsInDarkTheme(); void macSetToDarkTheme(); void macSetToLightTheme(); void macSetToAutoTheme(); +void fixCurrentTheme(); -#endif // MAC_THEME_HELPER_H \ No newline at end of file +#endif // MAC_THEME_HELPER_H diff --git a/HDPS/src/util/MacThemeHelper.mm b/HDPS/src/util/MacThemeHelper.mm index d351fc1ca..3567ab2db 100644 --- a/HDPS/src/util/MacThemeHelper.mm +++ b/HDPS/src/util/MacThemeHelper.mm @@ -47,3 +47,21 @@ void macSetToAutoTheme() [NSApp setAppearance:nil]; } } + + +void fixCurrentTheme() +{ + if (__builtin_available(macOS 10.14, *)) + { + auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: + @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; + if([appearance isEqualToString:NSAppearanceNameDarkAqua]) + { + [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; + } + else + { + [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; + } + } +}