Skip to content

Commit

Permalink
Merge pull request #504 from tiwoc/macos-tray-image
Browse files Browse the repository at this point in the history
Let tray image blend into macOS menu bar
  • Loading branch information
AdrianKoshka authored Nov 21, 2019
2 parents 1246ec3 + 8ef0668 commit d8e0394
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/gui/res/Barrier.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
<file>image/spinning-wheel.gif</file>
<file>icons/16x16/padlock.png</file>
<file>icons/16x16/barrier-transfering.png</file>
<file>icons/32x32/barrier-connected-mask.png</file>
<file>icons/32x32/barrier-disconnected-mask.png</file>
<file>icons/32x32/barrier-transfering-mask.png</file>
</qresource>
</RCC>
Binary file added src/gui/res/icons/32x32/barrier-connected-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions src/gui/res/icons/32x32/barrier-connected-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions src/gui/res/icons/32x32/barrier-disconnected-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/gui/res/icons/32x32/barrier-transfering-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions src/gui/res/icons/32x32/barrier-transfering-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions src/gui/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d8e0394

Please sign in to comment.