Skip to content

Commit

Permalink
Merge pull request #7036 from symless/SYNERGY-1006-Big-sur-icon-theme
Browse files Browse the repository at this point in the history
SYNERGY-1006 - Added template mode for icons on Big Sur and higher
  • Loading branch information
igor-sikachyna committed Jun 10, 2021
2 parents f0940d2 + 42c1ce5 commit 54a8a35
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bug fixes:
- #7001 Add option to prevent computer from going to sleep
- #7029 | #7033 Wrong encoding for text copied between linux and windows
- #7015 Fix Windows service not starting up after sleep
- #7036 Fix tray icon not changing theme on Big Sur

Enhancements:
- #6998 Remove functionality related to the screen saver synchronisation
Expand Down
17 changes: 13 additions & 4 deletions src/gui/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,19 @@ void MainWindow::setIcon(qSynergyState state) const
QIcon icon;

#ifdef Q_OS_MAC
if (isOSXUseDarkIcons())
icon.addFile(synergyDarkIconFiles[state]);
else
icon.addFile(synergyLightIconFiles[state]);
switch(getOSXIconsTheme()) {
case IconsTheme::ICONS_DARK:
icon.addFile(synergyDarkIconFiles[state]);
break;
case IconsTheme::ICONS_LIGHT:
icon.addFile(synergyLightIconFiles[state]);
break;
case IconsTheme::ICONS_TEMPLATE:
default:
icon.addFile(synergyDarkIconFiles[state]);
icon.setIsMask(true);
break;
}
#else
icon.addFile(synergyDefaultIconFiles[state]);
#endif
Expand Down
8 changes: 7 additions & 1 deletion src/gui/src/OSXHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@

#define OSXHELPERS__H

enum class IconsTheme {
ICONS_DARK,
ICONS_LIGHT,
ICONS_TEMPLATE
};

bool isOSXInterfaceStyleDark();
bool isOSXUseDarkIcons();
IconsTheme getOSXIconsTheme();

#endif
15 changes: 7 additions & 8 deletions src/gui/src/OSXHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
}

bool
isOSXUseDarkIcons()
IconsTheme
getOSXIconsTheme()
{
if (@available(macOS 11, *)) {
return true;
}
else {
return isOSXInterfaceStyleDark();
}
if (@available(macOS 11, *))
return IconsTheme::ICONS_TEMPLATE;
else if(isOSXInterfaceStyleDark())
return IconsTheme::ICONS_DARK;
return IconsTheme::ICONS_LIGHT;
}

0 comments on commit 54a8a35

Please sign in to comment.