macOS: Simplify Utility::hasDarkSystray()

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Erik Verbruggen 2021-10-07 15:56:07 +02:00 committed by Camila Ayres
parent a616fbf189
commit fb13eb7203
No known key found for this signature in database
GPG Key ID: 7A4A6121E88E2AD4

View File

@ -27,6 +27,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSUserDefaults.h>
namespace OCC {
@ -223,17 +224,13 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName,
#ifndef TOKEN_AUTH_ONLY
bool Utility::hasDarkSystray()
{
bool returnValue = false;
CFStringRef interfaceStyleKey = CFSTR("AppleInterfaceStyle");
CFStringRef interfaceStyle = nullptr;
CFStringRef darkInterfaceStyle = CFSTR("Dark");
interfaceStyle = (CFStringRef)CFPreferencesCopyAppValue(interfaceStyleKey,
kCFPreferencesCurrentApplication);
if (interfaceStyle) {
returnValue = (kCFCompareEqualTo == CFStringCompare(interfaceStyle, darkInterfaceStyle, 0));
CFRelease(interfaceStyle);
@autoreleasepool {
if (auto style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]) {
return [style isEqualToString:@"Dark"];
}
}
return returnValue;
return false;
}
#endif