Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mask-based tray icon for macOS #2091

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading