Merge branch 'staging' into modules

# Conflicts:
#	CHANGELOG.md
#	fpakman/app.py
#	fpakman/core/controller.py
#	fpakman/core/snap/controller.py
#	fpakman/core/snap/snap.py
This commit is contained in:
Vinicius Moreira
2019-07-29 10:42:40 -03:00
8 changed files with 55 additions and 12 deletions

View File

@@ -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_())

View File

@@ -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

View File

@@ -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

View File

@@ -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
app.name=application name
warning=warning
snap.notification.snapd_unavailable=snapd seems not to be enabled. snap packages will not be available.

View File

@@ -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
app.name=nombre del aplicativo
warning=aviso
snap.notification.snapd_unavailable=snapd no parece estar habilitado. los paquetes snap estarán indisponibles.

View File

@@ -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
app.name=nome do aplicativo
warning=aviso
snap.notification.snapd_unavailable=snapd não parece estar habilitado. os pacotes snap estarão indisponíveis.

View File

@@ -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)