macOS: Optimize detection of dark mode

Change-Id: I579527c54f8453c1e4f57bab7eebfc576b6ad365
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
bb10
Tor Arne Vestbø 2018-12-22 20:08:27 +01:00
parent 8c2ca29045
commit 1075f10184
1 changed files with 5 additions and 2 deletions

View File

@ -170,8 +170,11 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool)
bool qt_mac_applicationIsInDarkMode()
{
#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14)
if (__builtin_available(macOS 10.14, *))
return [NSApp.effectiveAppearance.name hasSuffix:@"DarkAqua"];
if (__builtin_available(macOS 10.14, *)) {
auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:
@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
return [appearance isEqualToString:NSAppearanceNameDarkAqua];
}
#endif
return false;
}