Skip to content

Commit

Permalink
Add mask-based tray icon for macOS. By @alecdwm (#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm authored Oct 18, 2024
1 parent 0d3d644 commit 4aea368
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/vorta/assets/icons/hdd-o-active-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/vorta/assets/icons/hdd-o-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: 12 additions & 4 deletions src/vorta/tray_menu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys

from PyQt6.QtGui import QIcon
from PyQt6.QtGui import QIcon, QImage, QPixmap
from PyQt6.QtWidgets import QApplication, QMenu, QSystemTrayIcon

from vorta.store.models import BackupProfileModel
Expand Down Expand Up @@ -77,8 +78,15 @@ def build_menu(self):

def set_tray_icon(self, active=False):
"""
Use white tray icon, when on Gnome or in dark mode. Otherwise use dark icon.
Use white tray icon, when on Gnome or in dark mode.
Use mask tray icon when on macOS.
Otherwise use dark icon.
"""
icon_name = f"icons/hdd-o{'-active' if active else ''}.png"
icon = QIcon(get_asset(icon_name))
if sys.platform == 'darwin':
icon_name = f"icons/hdd-o{'-active' if active else ''}-mask.svg"
icon = QIcon(QPixmap(QImage.fromData(open(get_asset(icon_name), 'rb').read()).scaledToHeight(128)))
icon.setIsMask(True)
else:
icon_name = f"icons/hdd-o{'-active' if active else ''}.png"
icon = QIcon(get_asset(icon_name))
self.setIcon(icon)

0 comments on commit 4aea368

Please sign in to comment.