Skip to content

Commit

Permalink
Synced with main master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
i1sm3ky committed Apr 8, 2023
1 parent c97f3e9 commit 87391cd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 51 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
platformdirs >=3.0.0, <4.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0,
platformdirs >=2.6.0, <4.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently.
paramiko
pyqt5
pyqt6
peewee
psutil
setuptools
Expand Down Expand Up @@ -101,7 +101,7 @@ commands=flake8 src tests
max_line_length = 120

[pylint.master]
extension-pkg-whitelist=PyQt5
extension-pkg-whitelist=PyQt6
load-plugins=

[pylint.messages control]
Expand Down
Binary file added src/vorta/assets/icons/hdd-o-active.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions src/vorta/assets/icons/hdd-o-active.svg

This file was deleted.

Binary file added src/vorta/assets/icons/hdd-o.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions src/vorta/assets/icons/hdd-o.svg

This file was deleted.

16 changes: 4 additions & 12 deletions src/vorta/tray_menu.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from PyQt6.QtGui import QColor, QScreen
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
from vorta.store.models import BackupProfileModel
from vorta.views.utils import get_colored_icon
from vorta.views.utils import get_asset


class TrayMenu(QSystemTrayIcon):
Expand Down Expand Up @@ -73,18 +73,10 @@ def build_menu(self):
exit_action = menu.addAction(self.tr('Quit'))
exit_action.triggered.connect(self.app.quit)

def is_taskbar_dark(self):
app = QApplication.instance()
long_color = QScreen.grabWindow(app.primaryScreen()).toImage().pixel(0, 0)
int_color = int(long_color)
return 150 > QColor.lightness(
QColor.fromRgb(((int_color >> 16) & 0xFF), ((int_color >> 8) & 0xFF), (int_color & 0xFF))
)

def set_tray_icon(self, active=False):
"""
Use white tray icon, when on Gnome or in dark mode. Otherwise use dark icon.
"""
icon_name = f"hdd-o{'-active' if active else ''}"
icon = get_colored_icon(icon_name, force_color='#ffffff' if self.is_taskbar_dark() else '#000000')
icon_name = f"icons/hdd-o{'-active' if active else ''}.png"
icon = QIcon(get_asset(icon_name))
self.setIcon(icon)
9 changes: 3 additions & 6 deletions src/vorta/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
from vorta.utils import get_asset, uses_dark_mode


def get_colored_icon(icon_name, force_color=''):
def get_colored_icon(icon_name):
"""
Return SVG icon in the correct color.
"""
with open(get_asset(f"icons/{icon_name}.svg"), 'rb') as svg_file:
svg_str = svg_file.read()
if not force_color:
if uses_dark_mode():
svg_str = svg_str.replace(b'#000000', b'#ffffff')
else:
svg_str = svg_str.replace(b'#000000', bytes(force_color, encoding="ascii"))
if uses_dark_mode():
svg_str = svg_str.replace(b'#000000', b'#ffffff')
# Reduce image size to 128 height
svg_img = QImage.fromData(svg_str).scaledToHeight(128)

Expand Down

0 comments on commit 87391cd

Please sign in to comment.