enable / disable tray and update-check daemon

This commit is contained in:
Vinicius Moreira
2019-07-29 11:26:07 -03:00
parent 7a89ad02b6
commit e1d13f9905
4 changed files with 31 additions and 25 deletions

View File

@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.4.3]
### Improvements
- new environment variable / argument to enable / disable the tray icon and update-check daemon: FPAKMAN_TRAY (--tray)
## [0.4.2] - 2019-07-28
### Improvements
- showing a warning dialog when the application starts and **snapd** is unavailable

View File

@@ -52,6 +52,7 @@ You can change some application settings via environment variables or arguments
- **FPAKMAN_FLATPAK**: enables / disables flatpak usage. Use **0** (disable) or **1** (enabled, default)
- **FPAKMAN_SNAP**: enables / disables snap usage. Use **0** (disable) or **1** (enabled, default)
- **FPAKMAN_CHECK_PACKAGING_ONCE**: If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Use **0** (disable, default) or **1** (enable).
- **FPAKMAN_TRAY**: If the tray icon and update-check daemon should be created. Use **0** (disable) or **1** (enable, default).
### How to improve the application performance
- If you don't care about a specific packaging technology and don't want **fpakman** to deal with it, just disable it via the specific argument or environment variable. For instance, if I don't care

View File

@@ -23,6 +23,7 @@ from fpakman.util.cache import Cache
from fpakman.util.memory import CacheCleaner
from fpakman.view.qt import dialog
from fpakman.view.qt.systray import TrayIcon
from fpakman.view.qt.window import ManageWindow
def log_msg(msg: str, color: int = None):
@@ -45,6 +46,7 @@ parser.add_argument('-di', '--download-icons', action="store", choices=[0, 1], d
parser.add_argument('--flatpak', action="store", default=os.getenv('FPAKMAN_FLATPAK', 1), choices=[0, 1], type=int, help='Enables / disables flatpak usage. Default: %(default)s')
parser.add_argument('--snap', action="store", default=os.getenv('FPAKMAN_SNAP', 1), choices=[0, 1], type=int, help='Enables / disables snap usage. Default: %(default)s')
parser.add_argument('-co', '--check-packaging-once', action="store", default=os.getenv('FPAKMAN_CHECK_PACKAGING_ONCE', 0), choices=[0, 1], type=int, help='If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Default: %(default)s')
parser.add_argument('--tray', action="store", default=os.getenv('FPAKMAN_TRAY', 1), choices=[0, 1], type=int, help='If the tray icon and update-check daemon should be created. Default: %(default)s')
args = parser.parse_args()
if args.cache_exp < 0:
@@ -112,16 +114,27 @@ app.setApplicationName(__app_name__)
app.setApplicationVersion(__version__)
app.setWindowIcon(QIcon(resource.get_path('img/logo.svg')))
trayIcon = TrayIcon(locale_keys=locale_keys,
manager=manager,
check_interval=args.check_interval,
icon_cache=icon_cache,
disk_cache=args.disk_cache,
update_notification=bool(args.update_notification),
download_icons=args.download_icons,
screen_size=app.primaryScreen().size())
screen_size = app.primaryScreen().size()
trayIcon.show()
manage_window = ManageWindow(locale_keys=locale_keys,
manager=manager,
icon_cache=icon_cache,
disk_cache=args.disk_cache,
download_icons=bool(args.download_icons),
screen_size=screen_size)
if args.tray:
trayIcon = TrayIcon(locale_keys=locale_keys,
manager=manager,
manage_window=manage_window,
check_interval=args.check_interval,
update_notification=bool(args.update_notification))
manage_window.tray_icon = trayIcon
trayIcon.show()
else:
manage_window.refresh_apps()
manage_window.show()
CacheCleaner(caches).start()

View File

@@ -2,7 +2,7 @@ import time
from threading import Lock, Thread
from typing import List
from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt, QSize
from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QSystemTrayIcon, QMenu
@@ -10,7 +10,6 @@ from fpakman import __app_name__
from fpakman.core import resource, system
from fpakman.core.controller import ApplicationManager
from fpakman.core.model import ApplicationUpdate
from fpakman.util.cache import Cache
from fpakman.view.qt.about import AboutDialog
from fpakman.view.qt.window import ManageWindow
@@ -34,14 +33,10 @@ class UpdateCheck(QThread):
class TrayIcon(QSystemTrayIcon):
def __init__(self, locale_keys: dict, manager: ApplicationManager, icon_cache: Cache, disk_cache: bool, download_icons: bool, screen_size: QSize, check_interval: int = 60, update_notification: bool = True):
def __init__(self, locale_keys: dict, manager: ApplicationManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True):
super(TrayIcon, self).__init__()
self.locale_keys = locale_keys
self.manager = manager
self.icon_cache = icon_cache
self.disk_cache = disk_cache
self.download_icons = download_icons
self.screen_size = screen_size
self.icon_default = QIcon(resource.get_path('img/logo.png'))
self.icon_update = QIcon(resource.get_path('img/logo_update.png'))
@@ -73,6 +68,8 @@ class TrayIcon(QSystemTrayIcon):
self.activated.connect(self.handle_click)
self.set_default_tooltip()
self.manage_window = manage_window
def set_default_tooltip(self):
self.setToolTip('{} ({})'.format(self.locale_keys['manage_window.title'], __app_name__).lower())
@@ -116,15 +113,6 @@ class TrayIcon(QSystemTrayIcon):
self.lock_notify.release()
def show_manage_window(self):
if self.manage_window is None:
self.manage_window = ManageWindow(locale_keys=self.locale_keys,
manager=self.manager,
icon_cache=self.icon_cache,
tray_icon=self,
disk_cache=self.disk_cache,
download_icons=self.download_icons,
screen_size=self.screen_size)
if self.manage_window.isMinimized():
self.manage_window.setWindowState(Qt.WindowNoState)
elif not self.manage_window.isVisible():