From 8ef0668b099ce1c4bdf1fb5f8a34d96ec2256033 Mon Sep 17 00:00:00 2001 From: Daniel Seither Date: Thu, 21 Nov 2019 10:45:08 +0100 Subject: [PATCH] Let tray image blend into macOS menu bar The expected style for macOS menu bar images is a template image than can adapt to the user's appearance settings. Also, high-res screens ("Retina" in Apple speak) need higher resolution images. Based on /res/barrier.svg, I created black and transparent SVGs for the three icon states. I had to remove some details to make the image scale down to icon size without becoming too crowded, and I drew a new checkmark and the transfer arrow. --- src/gui/res/Barrier.qrc | 3 + .../icons/32x32/barrier-connected-mask.png | Bin 0 -> 876 bytes .../icons/32x32/barrier-connected-mask.svg | 114 ++++++++++++++ .../icons/32x32/barrier-disconnected-mask.png | Bin 0 -> 732 bytes .../icons/32x32/barrier-disconnected-mask.svg | 102 ++++++++++++ .../icons/32x32/barrier-transfering-mask.png | Bin 0 -> 682 bytes .../icons/32x32/barrier-transfering-mask.svg | 148 ++++++++++++++++++ src/gui/src/MainWindow.cpp | 16 +- 8 files changed, 381 insertions(+), 2 deletions(-) create mode 100644 src/gui/res/icons/32x32/barrier-connected-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-connected-mask.svg create mode 100644 src/gui/res/icons/32x32/barrier-disconnected-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-disconnected-mask.svg create mode 100644 src/gui/res/icons/32x32/barrier-transfering-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-transfering-mask.svg diff --git a/src/gui/res/Barrier.qrc b/src/gui/res/Barrier.qrc index 39da79e6..ee6127d0 100644 --- a/src/gui/res/Barrier.qrc +++ b/src/gui/res/Barrier.qrc @@ -54,5 +54,8 @@ image/spinning-wheel.gif icons/16x16/padlock.png icons/16x16/barrier-transfering.png + icons/32x32/barrier-connected-mask.png + icons/32x32/barrier-disconnected-mask.png + icons/32x32/barrier-transfering-mask.png diff --git a/src/gui/res/icons/32x32/barrier-connected-mask.png b/src/gui/res/icons/32x32/barrier-connected-mask.png new file mode 100644 index 0000000000000000000000000000000000000000..7e17314e5374f96bf67280240280850efc28a77f GIT binary patch literal 876 zcmV-y1C#uTP)rVADq_FC)w|9kDV z*It)%a<2X++v-syorrEiPl%4GnTeIL~)i#z6oOm!)aVlBd{Hta6eYz zO6^;;5HI2+o=t1l;oE7l^c^f{Fpkv-d|2>VSM#Yz--c7ufVc2k6?mXv{3QGEc{p0| zS!1ePfo*t7)Yl96NMtpS-HD5L4=lz{4Y9d?gV9bTR%AOY=@D@qm)F2gbOB!JQH*pVaXZGR`N(6*cR=|D zHR(k9-LLjw4T%(Q#hgTPnCZ;3uX8#mzj zLTUKPF=CA+@RBUed@oFEH;PfMg*UVxt7Z73u*v^! z!-y!rS8*RMZ2-+>NMxxc#;{5j;uY + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/icons/32x32/barrier-disconnected-mask.png b/src/gui/res/icons/32x32/barrier-disconnected-mask.png new file mode 100644 index 0000000000000000000000000000000000000000..bedfa75de60bb7e0caf965c897427713b5c50e85 GIT binary patch literal 732 zcmV<20wev2P)4~^I9SF$UGqhAIU{hj) zV~MzPH3%r#S)pB7bjQ%_!j=T_VnV=Zyr?1h1Lb!1!PoAdSU?9D7U9{`WFe_Pt1!kt-`o&$A^>v zm==>2_3)MO9Onw}yo7}X@rR>-LvH#H|hloQzdS`R3;n6(QfBc03V2 zB=uM + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/icons/32x32/barrier-transfering-mask.png b/src/gui/res/icons/32x32/barrier-transfering-mask.png new file mode 100644 index 0000000000000000000000000000000000000000..90b69d1259ec5c0773b63eb1fc662422bdf9b796 GIT binary patch literal 682 zcmV;b0#*HqP)-d1zLe|?$_@1%2 zBc}i!;2`$;Gt1D2Vg$yC>JkRyK5#z6VI?-^41I|0m@Q=ZV{GWas8Be`@g6;q&z1~(r7<9!u=x2Kb_p3R zVqOf6Gw@RAgrcbKVHi(wSm+HC(J<~}ElvoP|48V#f2kQKg#ygdHnnG9XN5gxMDWk? zL{^b?`<NTymLe#j}L-U^L$!EzBc;J(b{uf=NfaIkN4~0e)yaIPA_?G$vfraC8#zQ`O*v zuJkq|3s;0AS-{x|z%Qtye{|spP7B|DPRc$V7wdpu70!IFnkoEDs|Ftunp#8DBDCpB z@W*It6g*a21WLn4Ft^e0SY3FPfWH&|xJ;>fgzNefmQFQ1)?)PjD|jyY1%U?sNIg4; Q4FCWD07*qoM6N<$f*kQQZU6uP literal 0 HcmV?d00001 diff --git a/src/gui/res/icons/32x32/barrier-transfering-mask.svg b/src/gui/res/icons/32x32/barrier-transfering-mask.svg new file mode 100644 index 00000000..ef7126a6 --- /dev/null +++ b/src/gui/res/icons/32x32/barrier-transfering-mask.svg @@ -0,0 +1,148 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index bcbb15bc..070f15a5 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -67,10 +67,17 @@ static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*. static const char* barrierIconFiles[] = { +#if defined(Q_OS_MAC) + ":/res/icons/32x32/barrier-disconnected-mask.png", + ":/res/icons/32x32/barrier-disconnected-mask.png", + ":/res/icons/32x32/barrier-connected-mask.png", + ":/res/icons/32x32/barrier-transfering-mask.png" +#else ":/res/icons/16x16/barrier-disconnected.png", ":/res/icons/16x16/barrier-disconnected.png", ":/res/icons/16x16/barrier-connected.png", ":/res/icons/16x16/barrier-transfering.png" +#endif }; static const char* barrierLargeIcon = ":/res/icons/256x256/barrier.ico"; @@ -288,8 +295,13 @@ void MainWindow::saveSettings() void MainWindow::setIcon(qBarrierState state) { - if (m_pTrayIcon) - m_pTrayIcon->setIcon(QIcon(barrierIconFiles[state])); + if (m_pTrayIcon) { + QIcon icon = QIcon(barrierIconFiles[state]); +#if defined(Q_OS_MAC) + icon.setIsMask(true); +#endif + m_pTrayIcon->setIcon(icon); + } } void MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason)