diff --git a/bauh/core/controller.py b/bauh/core/controller.py index bd94425f..c1665bdd 100755 --- a/bauh/core/controller.py +++ b/bauh/core/controller.py @@ -120,11 +120,11 @@ class GenericApplicationManager(ApplicationManager): return installed - def downgrade_app(self, app: Application, root_password: str) -> SystemProcess: + def downgrade_app(self, app: Application, root_password: str, handler: ProcessHandler) -> bool: man = self._get_manager_for(app) if man and app.can_be_downgraded(): - return man.downgrade_app(app, root_password) + return man.downgrade_app(app, root_password, handler) else: raise Exception("downgrade is not possible for {}".format(app.__class__.__name__)) diff --git a/bauh/resources/locale/en b/bauh/resources/locale/en index 3b2288d1..ef32e422 100644 --- a/bauh/resources/locale/en +++ b/bauh/resources/locale/en @@ -32,8 +32,6 @@ popup.root.title=Requires root privileges popup.root.password=Password popup.root.bad_password.title=Error popup.root.bad_password.body=Wrong password -popup.downgrade.impossible.title=Error -popup.downgrade.impossible.body=Impossible to downgrade: the app is in its first version popup.history.title=History popup.history.selected.tooltip=Current version popup.button.yes=Yes diff --git a/bauh/resources/locale/es b/bauh/resources/locale/es index c58552b3..0413c891 100644 --- a/bauh/resources/locale/es +++ b/bauh/resources/locale/es @@ -34,8 +34,6 @@ popup.root.title=Requiere privilegios de root popup.root.password=Contraseña popup.root.bad_password.title=Error popup.root.bad_password.body=Contraseña incorrecta -popup.downgrade.impossible.title=Error -popup.downgrade.impossible.body=Imposible revertir la versión: el aplicativo está en su primera versión popup.history.title=Historia popup.history.selected.tooltip=Versión actual popup.button.yes=Sí diff --git a/bauh/resources/locale/pt b/bauh/resources/locale/pt index a12aeca7..8d1ce924 100644 --- a/bauh/resources/locale/pt +++ b/bauh/resources/locale/pt @@ -34,8 +34,6 @@ popup.root.title=Requer privilégios de root popup.root.password=Senha popup.root.bad_password.title=Erro popup.root.bad_password.body=Senha incorreta -popup.downgrade.impossible.title=Erro -popup.downgrade.impossible.body=Impossível reverter a versão: o aplicativo está na sua primeira versão popup.history.title=Histórico popup.history.selected.tooltip=Versão atual popup.button.yes=Sim diff --git a/bauh/view/qt/history.py b/bauh/view/qt/history.py index 59cb2611..e07e9593 100644 --- a/bauh/view/qt/history.py +++ b/bauh/view/qt/history.py @@ -25,7 +25,7 @@ class HistoryDialog(QDialog): table_history.setColumnCount(len(app['history'][0])) table_history.setRowCount(len(app['history'])) - table_history.setHorizontalHeaderLabels([locale_keys['flatpak.info.' + key].capitalize() for key in sorted(app['history'][0].keys())]) + table_history.setHorizontalHeaderLabels([locale_keys.get(app['model'].get_type() + '.info.' + key, key).capitalize() for key in sorted(app['history'][0].keys())]) for row, commit in enumerate(app['history']): diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index b0891fb5..12dc0ff8 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -52,8 +52,11 @@ class AsyncAction(QThread, ProcessHandler): proc.subproc.communicate() return proc.subproc.returncode is None or proc.subproc.returncode == 0 + def show_error(self, title: str, body: str): + dialog.show_error(title, body) -class UpdateSelectedApps(AsyncAction, ProcessHandler): + +class UpdateSelectedApps(AsyncAction): signal_finished = pyqtSignal(bool, int) signal_status = pyqtSignal(str) @@ -101,7 +104,7 @@ class RefreshApps(QThread): self.signal.emit(self.manager.read_installed()) -class UninstallApp(AsyncAction, ProcessHandler): +class UninstallApp(AsyncAction): signal_finished = pyqtSignal(object) signal_output = pyqtSignal(str) @@ -145,16 +148,9 @@ class DowngradeApp(AsyncAction): def run(self): if self.app: - success = False try: - process = self.manager.downgrade_app(self.app.model, self.root_password) - - if process is None: - dialog.show_error(title=self.locale_keys['popup.downgrade.impossible.title'], - body=self.locale_keys['popup.downgrade.impossible.body']) - else: - success = self.notify_subproc_outputs(process, self.signal_output) + success = self.manager.downgrade_app(self.app.model, self.root_password, self) except (requests.exceptions.ConnectionError, NoInternetException): success = False self.signal_output.emit(self.locale_keys['internet.required']) @@ -163,6 +159,13 @@ class DowngradeApp(AsyncAction): self.root_password = None self.signal_finished.emit(success) + def handle(self, proc: SystemProcess) -> bool: + return self.notify_subproc_outputs(proc, self.signal_output) + + def notify(self, msg: str): + if msg: + self.signal_output.emit(msg) + class GetAppInfo(QThread): signal_finished = pyqtSignal(dict)