diff --git a/CHANGELOG.md b/CHANGELOG.md index eff643bb..a6a24516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Comments - Env variables / arguments FPAKMAN_SNAP / FPAKMAN_FLATPAK were removed. To disable a supported type, just uninstall its module. -## [0.4.2] +## [0.4.2] - 2019-07-28 +### Improvements +- showing a warning dialog when the application starts and **snapd** is unavailable ### Fixes: - [Snaps read index error](https://github.com/vinifmor/fpakman/issues/30) diff --git a/fpakman/app.py b/fpakman/app.py index 18b0c750..c8342687 100755 --- a/fpakman/app.py +++ b/fpakman/app.py @@ -18,6 +18,7 @@ from fpakman.core.flatpak.model import FlatpakApplication from fpakman.util import util 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 @@ -81,21 +82,20 @@ managers = [] if args.flatpak: flatpak_api_cache = Cache(expiration_time=args.cache_exp) cache_map[FlatpakApplication] = flatpak_api_cache - managers.append(FlatpakManager(app_args=args, api_cache=flatpak_api_cache, disk_cache=args.disk_cache, http_session=http_session)) + managers.append(FlatpakManager(app_args=args, api_cache=flatpak_api_cache, disk_cache=args.disk_cache, http_session=http_session, locale_keys=locale_keys)) caches.append(flatpak_api_cache) if args.disk_cache: Path(FLATPAK_CACHE_PATH).mkdir(parents=True, exist_ok=True) if args.snap: - pass # snap_api_cache = Cache(expiration_time=args.cache_exp) # cache_map[SnapApplication] = snap_api_cache - # managers.append(SnapManager(app_args=args, disk_cache=args.disk_cache, api_cache=snap_api_cache, http_session=http_session)) + # managers.append(SnapManager(app_args=args, disk_cache=args.disk_cache, api_cache=snap_api_cache, http_session=http_session, locale_keys=locale_keys)) # caches.append(snap_api_cache) # # if args.disk_cache: - # Path(SNAP_CACHE_PATH).mkdir(parents=True, exist_ok=True) + # Path(SNAP_CACHE_PATH).mkdir(parents=True, exist_ok=True) icon_cache = Cache(expiration_time=args.icon_exp) caches.append(icon_cache) @@ -121,4 +121,10 @@ trayIcon.show() CacheCleaner(caches).start() +warnings = manager.list_warnings() + +if warnings: + for warning in warnings: + dialog.show_warning(title=locale_keys['warning'].capitalize(), body=warning) + sys.exit(app.exec_()) diff --git a/fpakman/core/controller.py b/fpakman/core/controller.py index 8c19a96f..8110eee6 100755 --- a/fpakman/core/controller.py +++ b/fpakman/core/controller.py @@ -189,3 +189,18 @@ class GenericApplicationManager(ApplicationManager): updates.extend(man.list_updates()) return updates + + def list_warnings(self) -> List[str]: + if self.managers: + warnings = None + + for man in self.managers: + man_warnings = man.list_warnings() + + if man_warnings: + if warnings is None: + warnings = [] + + warnings.extend(man_warnings) + + return warnings diff --git a/fpakman/core/flatpak/controller.py b/fpakman/core/flatpak/controller.py index f0298e25..72f04040 100644 --- a/fpakman/core/flatpak/controller.py +++ b/fpakman/core/flatpak/controller.py @@ -17,8 +17,8 @@ from fpakman.util.cache import Cache class FlatpakManager(ApplicationManager): - def __init__(self, app_args: Namespace, api_cache: Cache, disk_cache: bool, http_session): - super(FlatpakManager, self).__init__(app_args=app_args) + def __init__(self, app_args: Namespace, api_cache: Cache, disk_cache: bool, http_session, locale_keys: dict): + super(FlatpakManager, self).__init__(app_args=app_args, locale_keys=locale_keys) self.api_cache = api_cache self.http_session = http_session self.disk_cache = disk_cache @@ -176,5 +176,7 @@ class FlatpakManager(ApplicationManager): updates.append(ApplicationUpdate(app_id='{}:{}'.format(app['id'], app['branch']), app_type='flatpak', version=app.get('version'))) - return updates + + def list_warnings(self) -> List[str]: + return None diff --git a/fpakman/resources/locale/en b/fpakman/resources/locale/en index 657d1618..26bb313e 100644 --- a/fpakman/resources/locale/en +++ b/fpakman/resources/locale/en @@ -99,4 +99,6 @@ version.installed=installed version version.latest=latest version version.installed_outdated=the installed version is outdated version.unknown=not informed -app.name=application name \ No newline at end of file +app.name=application name +warning=warning +snap.notification.snapd_unavailable=snapd seems not to be enabled. snap packages will not be available. \ No newline at end of file diff --git a/fpakman/resources/locale/es b/fpakman/resources/locale/es index 7e1036d4..a4c4b0c8 100644 --- a/fpakman/resources/locale/es +++ b/fpakman/resources/locale/es @@ -100,4 +100,6 @@ version.installed=versión instalada version.latest=versión más reciente version.installed_outdated=la versión instalada está desactualizada version.unknown=versión no informada -app.name=nombre del aplicativo \ No newline at end of file +app.name=nombre del aplicativo +warning=aviso +snap.notification.snapd_unavailable=snapd no parece estar habilitado. los paquetes snap estarán indisponibles. \ No newline at end of file diff --git a/fpakman/resources/locale/pt b/fpakman/resources/locale/pt index 82b0ee6a..13c49288 100644 --- a/fpakman/resources/locale/pt +++ b/fpakman/resources/locale/pt @@ -100,4 +100,6 @@ version.installed=versão instalada version.latest=versão mais recente version.installed_outdated=a versão instalada está desatualizada version.unknown=versão não informada -app.name=nome do aplicativo \ No newline at end of file +app.name=nome do aplicativo +warning=aviso +snap.notification.snapd_unavailable=snapd não parece estar habilitado. os pacotes snap estarão indisponíveis. \ No newline at end of file diff --git a/fpakman/view/qt/dialog.py b/fpakman/view/qt/dialog.py index 7d3e27e2..f5cfbb09 100644 --- a/fpakman/view/qt/dialog.py +++ b/fpakman/view/qt/dialog.py @@ -1,5 +1,5 @@ from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QMessageBox, QSizePolicy +from PyQt5.QtWidgets import QMessageBox from fpakman.core import resource @@ -16,6 +16,18 @@ def show_error(title: str, body: str, icon: QIcon = QIcon(resource.get_path('img error_msg.exec_() +def show_warning(title: str, body: str, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))): + msg = QMessageBox() + msg.setIcon(QMessageBox.Warning) + msg.setWindowTitle(title) + msg.setText(body) + + if icon: + msg.setWindowIcon(icon) + + msg.exec_() + + def ask_confirmation(title: str, body: str, locale_keys: dict, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))): dialog_confirmation = QMessageBox() dialog_confirmation.setIcon(QMessageBox.Question)