[icon] notifications and panel favor the system's default

This commit is contained in:
Vinícius Moreira
2019-12-20 13:52:29 -03:00
parent aa6876269f
commit 5e2529456f
4 changed files with 24 additions and 6 deletions

View File

@@ -69,7 +69,8 @@ def main():
app = QApplication(sys.argv)
app.setApplicationName(__app_name__)
app.setApplicationVersion(__version__)
app.setWindowIcon(QIcon(resource.get_path('img/logo.svg')))
app_icon = util.get_default_icon()[1]
app.setWindowIcon(app_icon)
if local_config['ui']['style']:
app.setStyle(str(local_config['ui']['style']))
@@ -84,6 +85,7 @@ def main():
config=local_config,
context=context,
http_client=http_client,
icon=app_icon,
logger=logger)
if args.tray:

View File

@@ -51,7 +51,7 @@ class ManageWindow(QWidget):
signal_table_update = pyqtSignal()
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size, config: dict,
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, tray_icon=None):
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon, tray_icon=None):
super(ManageWindow, self).__init__()
self.i18n = i18n
self.logger = logger
@@ -68,7 +68,7 @@ class ManageWindow(QWidget):
self.context = context
self.http_client = http_client
self.icon_app = QIcon(resource.get_path('img/logo.svg'))
self.icon_app = icon
self.resize(ManageWindow.__BASE_HEIGHT__, ManageWindow.__BASE_HEIGHT__)
self.setWindowIcon(self.icon_app)

View File

@@ -3,9 +3,10 @@ import shutil
import subprocess
import sys
import traceback
from typing import List
from typing import List, Tuple
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
from colorama import Fore
from bauh import __app_name__
@@ -15,8 +16,22 @@ from bauh.commons.system import run_cmd
from bauh.view.util import resource
def notify_user(msg: str, icon_path: str = resource.get_path('img/logo.svg')):
os.system("notify-send -a {} {} '{}'".format(__app_name__, "-i {}".format(icon_path) if icon_path else '', msg))
def notify_user(msg: str, icon_path: str = None):
icon_id = icon_path
if not icon_id:
icon_id = get_default_icon()[0]
os.system("notify-send -a {} {} '{}'".format(__app_name__, "-i {}".format(icon_id) if icon_id else '', msg))
def get_default_icon() -> Tuple[str, QIcon]:
system_icon = QIcon.fromTheme(__app_name__)
if not system_icon.isNull():
return system_icon.name(), system_icon
else:
path = resource.get_path('img/logo.svg')
return path, QIcon(path)
def restart_app(show_panel: bool):