Skip to content

Commit c2d60c2

Browse files
authored
Add masked icon for macOS with dynamic wallpapers (flameshot-org#4257)
1 parent b2f3ef5 commit c2d60c2

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

data/graphics.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<file>img/app/flameshot.svg</file>
55
<file>img/app/org.flameshot.Flameshot.png</file>
66
<file>img/app/flameshot.png</file>
7+
<file>img/app/flameshot.mask.png</file>
8+
<file>img/app/flameshot.mask.svg</file>
79
<file>img/app/flameshot.monochrome.png</file>
810
<file>img/app/flameshot.monochrome.svg</file>
911
<file>img/app/keyboard.svg</file>

data/img/app/flameshot.mask.png

837 Bytes
Loading

data/img/app/flameshot.mask.svg

Lines changed: 17 additions & 0 deletions
Loading

src/utils/globalvalues.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <QApplication>
66
#include <QFontMetrics>
77

8+
#if defined(Q_OS_MACOS)
9+
#include <QOperatingSystemVersion>
10+
#endif
11+
812
int GlobalValues::buttonBaseSize()
913
{
1014
return QFontMetrics(qApp->font()).lineSpacing() * 2.2;
@@ -33,3 +37,21 @@ QString GlobalValues::iconPathPNG()
3337
return { ":img/app/flameshot.png" };
3438
#endif
3539
}
40+
41+
QString GlobalValues::trayIconPath()
42+
{
43+
#if USE_MONOCHROME_ICON
44+
#if defined(Q_OS_MACOS)
45+
auto currentMacOsVersion = QOperatingSystemVersion::current();
46+
if (currentMacOsVersion >= QOperatingSystemVersion::MacOSBigSur) {
47+
return { ":img/app/flameshot.mask.png" };
48+
} else {
49+
return { ":img/app/flameshot.monochrome.png" };
50+
}
51+
#else
52+
return { ":img/app/flameshot.monochrome.png" };
53+
#endif
54+
#else
55+
return { ":img/app/flameshot.png" };
56+
#endif
57+
}

src/utils/globalvalues.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ int buttonBaseSize();
1111
QString versionInfo();
1212
QString iconPath();
1313
QString iconPathPNG();
14+
QString trayIconPath();
1415
}

src/widgets/trayicon.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ TrayIcon::TrayIcon(QObject* parent)
3333
setContextMenu(m_menu);
3434
#endif
3535
QIcon icon =
36-
QIcon::fromTheme("flameshot-tray", QIcon(GlobalValues::iconPathPNG()));
36+
QIcon::fromTheme("flameshot-tray", QIcon(GlobalValues::trayIconPath()));
37+
38+
#if defined(Q_OS_MACOS)
39+
if (currentMacOsVersion >= QOperatingSystemVersion::MacOSBigSur) {
40+
icon.setIsMask(true);
41+
}
42+
#endif
43+
3744
setIcon(icon);
3845

3946
#if defined(Q_OS_MACOS)

0 commit comments

Comments
 (0)