[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

@@ -47,6 +47,7 @@ updates:
1) Icon paths defined in **~/.config/bauh/config.yml** 1) Icon paths defined in **~/.config/bauh/config.yml**
2) Icons from the system with the following names: `bauh_tray_default` and `bauh_tray_updates` 2) Icons from the system with the following names: `bauh_tray_default` and `bauh_tray_updates`
3) Own packaged icons 3) Own packaged icons
- Now bauh considers the default system icon for the notifications and panel. If there is none, then it will use its own.
- AppImage: - AppImage:
- cleaning the downloaded database files when **--reset** is passed as parameter - cleaning the downloaded database files when **--reset** is passed as parameter
- environment variables **BAUH_APPIMAGE_DB_UPDATER** and **BAUH_APPIMAGE_DB_UPDATER_TIME** dropped in favor of the new configuration file located at **~/.config/bauh/appimage.yml** - environment variables **BAUH_APPIMAGE_DB_UPDATER** and **BAUH_APPIMAGE_DB_UPDATER_TIME** dropped in favor of the new configuration file located at **~/.config/bauh/appimage.yml**

View File

@@ -69,7 +69,8 @@ def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setApplicationName(__app_name__) app.setApplicationName(__app_name__)
app.setApplicationVersion(__version__) 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']: if local_config['ui']['style']:
app.setStyle(str(local_config['ui']['style'])) app.setStyle(str(local_config['ui']['style']))
@@ -84,6 +85,7 @@ def main():
config=local_config, config=local_config,
context=context, context=context,
http_client=http_client, http_client=http_client,
icon=app_icon,
logger=logger) logger=logger)
if args.tray: if args.tray:

View File

@@ -51,7 +51,7 @@ class ManageWindow(QWidget):
signal_table_update = pyqtSignal() signal_table_update = pyqtSignal()
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size, config: dict, 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__() super(ManageWindow, self).__init__()
self.i18n = i18n self.i18n = i18n
self.logger = logger self.logger = logger
@@ -68,7 +68,7 @@ class ManageWindow(QWidget):
self.context = context self.context = context
self.http_client = http_client 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.resize(ManageWindow.__BASE_HEIGHT__, ManageWindow.__BASE_HEIGHT__)
self.setWindowIcon(self.icon_app) self.setWindowIcon(self.icon_app)

View File

@@ -3,9 +3,10 @@ import shutil
import subprocess import subprocess
import sys import sys
import traceback import traceback
from typing import List from typing import List, Tuple
from PyQt5.QtCore import QCoreApplication from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
from colorama import Fore from colorama import Fore
from bauh import __app_name__ from bauh import __app_name__
@@ -15,8 +16,22 @@ from bauh.commons.system import run_cmd
from bauh.view.util import resource from bauh.view.util import resource
def notify_user(msg: str, icon_path: str = resource.get_path('img/logo.svg')): def notify_user(msg: str, icon_path: str = None):
os.system("notify-send -a {} {} '{}'".format(__app_name__, "-i {}".format(icon_path) if icon_path else '', msg)) 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): def restart_app(show_panel: bool):