From d2ed73d9caed123ba1647b13978da713d62a938a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 21 Feb 2022 14:21:42 -0300 Subject: [PATCH] [view] improvement: upgrade summary dialog width --- CHANGELOG.md | 6 ++++++ bauh/api/abstract/handler.py | 8 +++++--- bauh/view/qt/dialog.py | 10 +++++----- bauh/view/qt/thread.py | 11 +++++++---- bauh/view/qt/window.py | 12 ++++++++---- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a4ded53..08d9e6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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.X.X] + +### Improvements +- UI + - upgrade summary dialog size + ## [0.9.28] 2022-02-14 ### Fixes diff --git a/bauh/api/abstract/handler.py b/bauh/api/abstract/handler.py index 3ecb763b..b666ef59 100644 --- a/bauh/api/abstract/handler.py +++ b/bauh/api/abstract/handler.py @@ -17,9 +17,10 @@ class ProcessWatcher: """ pass - def request_confirmation(self, title: str, body: Optional[str], components: List[ViewComponent] = None, confirmation_label: str = None, - deny_label: str = None, deny_button: bool = True, window_cancel: bool = False, - confirmation_button: bool = True) -> bool: + def request_confirmation(self, title: str, body: Optional[str], components: List[ViewComponent] = None, + confirmation_label: str = None, deny_label: str = None, deny_button: bool = True, + window_cancel: bool = False, confirmation_button: bool = True, + min_width: Optional[int] = None) -> bool: """ request a user confirmation. In the current GUI implementation, it shows a popup to the user. :param title: popup title @@ -30,6 +31,7 @@ class ProcessWatcher: :param deny_button: if the deny button should be displayed :param window_cancel: if the window cancel button should be visible :param confirmation_button: if the confirmation button should be displayed + :param min_width: minimum width for the confirmation dialog :return: if the request was confirmed by the user """ pass diff --git a/bauh/view/qt/dialog.py b/bauh/view/qt/dialog.py index e69d05e9..a8532af3 100644 --- a/bauh/view/qt/dialog.py +++ b/bauh/view/qt/dialog.py @@ -1,9 +1,9 @@ from typing import List, Optional -from PyQt5.QtCore import Qt, QSize, QMargins +from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon, QCursor -from PyQt5.QtWidgets import QMessageBox, QLabel, QWidget, QHBoxLayout, QDialog, QVBoxLayout, QSizePolicy, QApplication, \ - QStyle, QPushButton, QScrollArea, QFrame +from PyQt5.QtWidgets import QMessageBox, QLabel, QWidget, QHBoxLayout, QDialog, QVBoxLayout, QSizePolicy, QPushButton, \ + QScrollArea, QFrame from bauh.api.abstract.view import MessageType from bauh.view.qt.components import new_spacer @@ -34,7 +34,7 @@ class ConfirmationDialog(QDialog): def __init__(self, title: str, body: Optional[str], i18n: I18n, icon: QIcon = QIcon(resource.get_path('img/logo.svg')), widgets: Optional[List[QWidget]] = None, confirmation_button: bool = True, deny_button: bool = True, window_cancel: bool = False, confirmation_label: Optional[str] = None, deny_label: Optional[str] = None, - confirmation_icon: bool = True): + confirmation_icon: bool = True, min_width: Optional[int] = None): super(ConfirmationDialog, self).__init__() if not window_cancel: @@ -43,7 +43,7 @@ class ConfirmationDialog(QDialog): self.setLayout(QVBoxLayout()) self.setWindowTitle(title) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) - self.setMinimumWidth(250) + self.setMinimumWidth(min_width if min_width and min_width > 0 else 250) self.confirmed = False if icon: diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 7356cfbf..48d9298b 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -55,12 +55,13 @@ class AsyncAction(QThread, ProcessWatcher): def request_confirmation(self, title: str, body: str, components: List[ViewComponent] = None, confirmation_label: str = None, deny_label: str = None, deny_button: bool = True, window_cancel: bool = False, - confirmation_button: bool = True) -> bool: + confirmation_button: bool = True, + min_width: Optional[int] = None) -> bool: self.wait_confirmation = True self.signal_confirmation.emit({'title': title, 'body': body, 'components': components, 'confirmation_label': confirmation_label, 'deny_label': deny_label, 'deny_button': deny_button, 'window_cancel': window_cancel, - 'confirmation_button': confirmation_button}) + 'confirmation_button': confirmation_button, 'min_width': min_width}) self.wait_user() return self.confirmation_res @@ -203,12 +204,14 @@ class UpgradeSelected(AsyncAction): UPGRADE_LOGS_DIR = f'{LOGS_DIR}/upgrade' SUMMARY_FILE = UPGRADE_LOGS_DIR + '/{}_summary.txt' - def __init__(self, manager: SoftwareManager, internet_checker: InternetChecker, i18n: I18n, pkgs: List[PackageView] = None): + def __init__(self, manager: SoftwareManager, internet_checker: InternetChecker, i18n: I18n, + screen_width: int, pkgs: List[PackageView] = None): super(UpgradeSelected, self).__init__() self.pkgs = pkgs self.manager = manager self.i18n = i18n self.internet_checker = internet_checker + self.screen_width = screen_width def _req_as_option(self, req: UpgradeRequirement, tooltip: bool = True, custom_tooltip: str = None, required_size: bool = True, display_sizes: bool = True) -> InputOption: if req.pkg.installed: @@ -469,7 +472,7 @@ class UpgradeSelected(AsyncAction): if not self.request_confirmation(title=self.i18n['action.update.summary'].capitalize(), body='', components=comps, confirmation_label=self.i18n['proceed'].capitalize(), deny_label=self.i18n['cancel'].capitalize(), - confirmation_button=can_upgrade): + confirmation_button=can_upgrade, min_width=int(0.45 * self.screen_width)): self.notify_finished({'success': success, 'updated': updated, 'types': updated_types, 'id': None}) self.pkgs = None return diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index f7064c28..759c2a96 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -5,7 +5,7 @@ import traceback from pathlib import Path from typing import List, Type, Set, Tuple, Optional -from PyQt5.QtCore import QEvent, Qt, pyqtSignal +from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QSize from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QCursor from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \ QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \ @@ -94,7 +94,7 @@ class ManageWindow(QWidget): signal_table_update = pyqtSignal() signal_stop_notifying = 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: QSize, config: dict, context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon): super(ManageWindow, self).__init__() self.setObjectName('manage_window') @@ -316,7 +316,10 @@ class ManageWindow(QWidget): self.layout.addWidget(self.toolbar_substatus) self._change_label_substatus('') - self.thread_update = self._bind_async_action(UpgradeSelected(self.manager, context.internet_checker, self.i18n), finished_call=self._finish_upgrade_selected) + self.thread_update = self._bind_async_action(UpgradeSelected(manager=self.manager, i18n=self.i18n, + internet_checker=context.internet_checker, + screen_width=screen_size.width()), + finished_call=self._finish_upgrade_selected) self.thread_refresh = self._bind_async_action(RefreshApps(self.manager), finished_call=self._finish_refresh_packages, only_finished=True) self.thread_uninstall = self._bind_async_action(UninstallPackage(self.manager, self.icon_cache, self.i18n), finished_call=self._finish_uninstall) self.thread_show_info = self._bind_async_action(ShowPackageInfo(self.manager), finished_call=self._finish_show_info) @@ -542,7 +545,8 @@ class ManageWindow(QWidget): deny_label=msg['deny_label'], deny_button=msg['deny_button'], window_cancel=msg['window_cancel'], - confirmation_button=msg.get('confirmation_button', True)) + confirmation_button=msg.get('confirmation_button', True), + min_width=msg.get('min_width')) diag.ask() res = diag.confirmed self.thread_animate_progress.animate()