[view] improvement: upgrade summary dialog width

This commit is contained in:
Vinicius Moreira
2022-02-21 14:21:42 -03:00
parent 656810ffe5
commit d2ed73d9ca
5 changed files with 31 additions and 16 deletions

View File

@@ -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/). 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 ## [0.9.28] 2022-02-14
### Fixes ### Fixes

View File

@@ -17,9 +17,10 @@ class ProcessWatcher:
""" """
pass pass
def request_confirmation(self, title: str, body: Optional[str], components: List[ViewComponent] = None, confirmation_label: str = None, def request_confirmation(self, title: str, body: Optional[str], components: List[ViewComponent] = None,
deny_label: str = None, deny_button: bool = True, window_cancel: bool = False, confirmation_label: str = None, deny_label: str = None, deny_button: bool = True,
confirmation_button: bool = True) -> bool: 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. request a user confirmation. In the current GUI implementation, it shows a popup to the user.
:param title: popup title :param title: popup title
@@ -30,6 +31,7 @@ class ProcessWatcher:
:param deny_button: if the deny button should be displayed :param deny_button: if the deny button should be displayed
:param window_cancel: if the window cancel button should be visible :param window_cancel: if the window cancel button should be visible
:param confirmation_button: if the confirmation button should be displayed :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 :return: if the request was confirmed by the user
""" """
pass pass

View File

@@ -1,9 +1,9 @@
from typing import List, Optional 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.QtGui import QIcon, QCursor
from PyQt5.QtWidgets import QMessageBox, QLabel, QWidget, QHBoxLayout, QDialog, QVBoxLayout, QSizePolicy, QApplication, \ from PyQt5.QtWidgets import QMessageBox, QLabel, QWidget, QHBoxLayout, QDialog, QVBoxLayout, QSizePolicy, QPushButton, \
QStyle, QPushButton, QScrollArea, QFrame QScrollArea, QFrame
from bauh.api.abstract.view import MessageType from bauh.api.abstract.view import MessageType
from bauh.view.qt.components import new_spacer 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')), 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, 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, 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__() super(ConfirmationDialog, self).__init__()
if not window_cancel: if not window_cancel:
@@ -43,7 +43,7 @@ class ConfirmationDialog(QDialog):
self.setLayout(QVBoxLayout()) self.setLayout(QVBoxLayout())
self.setWindowTitle(title) self.setWindowTitle(title)
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) 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 self.confirmed = False
if icon: if icon:

View File

@@ -55,12 +55,13 @@ class AsyncAction(QThread, ProcessWatcher):
def request_confirmation(self, title: str, body: str, components: List[ViewComponent] = None, def request_confirmation(self, title: str, body: str, components: List[ViewComponent] = None,
confirmation_label: str = None, deny_label: str = None, deny_button: bool = True, confirmation_label: str = None, deny_label: str = None, deny_button: bool = True,
window_cancel: bool = False, window_cancel: bool = False,
confirmation_button: bool = True) -> bool: confirmation_button: bool = True,
min_width: Optional[int] = None) -> bool:
self.wait_confirmation = True self.wait_confirmation = True
self.signal_confirmation.emit({'title': title, 'body': body, 'components': components, self.signal_confirmation.emit({'title': title, 'body': body, 'components': components,
'confirmation_label': confirmation_label, 'deny_label': deny_label, 'confirmation_label': confirmation_label, 'deny_label': deny_label,
'deny_button': deny_button, 'window_cancel': window_cancel, 'deny_button': deny_button, 'window_cancel': window_cancel,
'confirmation_button': confirmation_button}) 'confirmation_button': confirmation_button, 'min_width': min_width})
self.wait_user() self.wait_user()
return self.confirmation_res return self.confirmation_res
@@ -203,12 +204,14 @@ class UpgradeSelected(AsyncAction):
UPGRADE_LOGS_DIR = f'{LOGS_DIR}/upgrade' UPGRADE_LOGS_DIR = f'{LOGS_DIR}/upgrade'
SUMMARY_FILE = UPGRADE_LOGS_DIR + '/{}_summary.txt' 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__() super(UpgradeSelected, self).__init__()
self.pkgs = pkgs self.pkgs = pkgs
self.manager = manager self.manager = manager
self.i18n = i18n self.i18n = i18n
self.internet_checker = internet_checker 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: 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: 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, 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_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.notify_finished({'success': success, 'updated': updated, 'types': updated_types, 'id': None})
self.pkgs = None self.pkgs = None
return return

View File

@@ -5,7 +5,7 @@ import traceback
from pathlib import Path from pathlib import Path
from typing import List, Type, Set, Tuple, Optional 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.QtGui import QIcon, QWindowStateChangeEvent, QCursor
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \
QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \ QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \
@@ -94,7 +94,7 @@ class ManageWindow(QWidget):
signal_table_update = pyqtSignal() signal_table_update = pyqtSignal()
signal_stop_notifying = 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): context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon):
super(ManageWindow, self).__init__() super(ManageWindow, self).__init__()
self.setObjectName('manage_window') self.setObjectName('manage_window')
@@ -316,7 +316,10 @@ class ManageWindow(QWidget):
self.layout.addWidget(self.toolbar_substatus) self.layout.addWidget(self.toolbar_substatus)
self._change_label_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_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_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) 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_label=msg['deny_label'],
deny_button=msg['deny_button'], deny_button=msg['deny_button'],
window_cancel=msg['window_cancel'], 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() diag.ask()
res = diag.confirmed res = diag.confirmed
self.thread_animate_progress.animate() self.thread_animate_progress.animate()