Skip to content

Commit

Permalink
Forces light theme on macOS until all icons can be drawn for the dark…
Browse files Browse the repository at this point in the history
… theme
  • Loading branch information
thoellt committed Oct 5, 2023
1 parent c1755ff commit 440ac5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion HDPS/src/ApplicationSettingsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion HDPS/src/util/MacThemeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ bool macIsInDarkTheme();
void macSetToDarkTheme();
void macSetToLightTheme();
void macSetToAutoTheme();
void fixCurrentTheme();

#endif // MAC_THEME_HELPER_H
#endif // MAC_THEME_HELPER_H
18 changes: 18 additions & 0 deletions HDPS/src/util/MacThemeHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
}
}
}

0 comments on commit 440ac5d

Please sign in to comment.