From 56710260ee5bd70807105ffffc8e573f083b9a8d Mon Sep 17 00:00:00 2001 From: SerhiiGadzhilov <71632867+SerhiiGadzhilov@users.noreply.github.com> Date: Wed, 10 Feb 2021 13:11:40 +0300 Subject: [PATCH] SYNERGY-691 Systray icon is incorrect for macOS Big Sur (#6944) * SYNERGY-691 Systray icon is incorrect for macOS Big Sur * Update ChangeLog --- ChangeLog | 1 + src/gui/src/MainWindow.cpp | 2 +- src/gui/src/OSXHelpers.h | 1 + src/gui/src/OSXHelpers.mm | 19 +++++++++++++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22452a116..dca78e9f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Bug fixes: - #6936 Application loses settings - #6939 Update pipelines to use correct credentials - #6942 All the text in all the windows should have the same font and size +- #6944 Systray icon is incorrect for macOS Big Sur Enhancements: - #6912 Removes UI for Screen Saver Sync and Files Drag and Drop diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 100bf03f1..8c0f06d79 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -360,7 +360,7 @@ void MainWindow::setIcon(qSynergyState state) const QIcon icon; #ifdef Q_OS_MAC - if (isOSXInterfaceStyleDark()) + if (isOSXUseDarkIcons()) icon.addFile(synergyDarkIconFiles[state]); else icon.addFile(synergyLightIconFiles[state]); diff --git a/src/gui/src/OSXHelpers.h b/src/gui/src/OSXHelpers.h index 6b2b65bc0..05643ad50 100644 --- a/src/gui/src/OSXHelpers.h +++ b/src/gui/src/OSXHelpers.h @@ -20,5 +20,6 @@ #define OSXHELPERS__H bool isOSXInterfaceStyleDark(); +bool isOSXUseDarkIcons(); #endif diff --git a/src/gui/src/OSXHelpers.mm b/src/gui/src/OSXHelpers.mm index de5debbee..ce5aa4592 100644 --- a/src/gui/src/OSXHelpers.mm +++ b/src/gui/src/OSXHelpers.mm @@ -24,8 +24,19 @@ bool isOSXInterfaceStyleDark() { - // Implementation from http://stackoverflow.com/a/26472651 - NSDictionary* dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain]; - id style = [dict objectForKey:@"AppleInterfaceStyle"]; - return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]); + // Implementation from http://stackoverflow.com/a/26472651 + NSDictionary* dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain]; + id style = [dict objectForKey:@"AppleInterfaceStyle"]; + return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]); +} + +bool +isOSXUseDarkIcons() +{ + if (@available(macOS 11, *)) { + return true; + } + else { + return isOSXInterfaceStyleDark(); + } }