mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[view] improvement: allowing to set a min height for confirmation dialogs
This commit is contained in:
@@ -20,7 +20,8 @@ class ProcessWatcher:
|
||||
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:
|
||||
min_width: Optional[int] = None,
|
||||
min_height: Optional[int] = None) -> bool:
|
||||
"""
|
||||
request a user confirmation. In the current GUI implementation, it shows a popup to the user.
|
||||
:param title: popup title
|
||||
@@ -32,6 +33,7 @@ class ProcessWatcher:
|
||||
: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
|
||||
:param min_height: minimum height for the confirmation dialog
|
||||
:return: if the request was confirmed by the user
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -34,7 +34,8 @@ 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, min_width: Optional[int] = None):
|
||||
confirmation_icon: bool = True, min_width: Optional[int] = None,
|
||||
min_height: Optional[int] = None):
|
||||
super(ConfirmationDialog, self).__init__()
|
||||
|
||||
if not window_cancel:
|
||||
@@ -44,6 +45,10 @@ class ConfirmationDialog(QDialog):
|
||||
self.setWindowTitle(title)
|
||||
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
||||
self.setMinimumWidth(min_width if min_width and min_width > 0 else 250)
|
||||
|
||||
if isinstance(min_height, int) and min_height > 0:
|
||||
self.setMinimumHeight(min_height)
|
||||
|
||||
self.confirmed = False
|
||||
|
||||
if icon:
|
||||
@@ -53,6 +58,9 @@ class ConfirmationDialog(QDialog):
|
||||
container_body.setObjectName('confirm_container_body')
|
||||
container_body.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
||||
|
||||
if isinstance(min_height, int) and min_height > 0:
|
||||
container_body.setMinimumWidth(min_height)
|
||||
|
||||
if widgets:
|
||||
container_body.setLayout(QVBoxLayout())
|
||||
scroll = QScrollArea(self)
|
||||
|
||||
@@ -56,12 +56,14 @@ class AsyncAction(QThread, ProcessWatcher):
|
||||
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:
|
||||
min_width: Optional[int] = None,
|
||||
min_height: 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, 'min_width': min_width})
|
||||
'confirmation_button': confirmation_button, 'min_width': min_width,
|
||||
'min_height': min_height})
|
||||
self.wait_user()
|
||||
return self.confirmation_res
|
||||
|
||||
|
||||
@@ -546,7 +546,8 @@ class ManageWindow(QWidget):
|
||||
deny_button=msg['deny_button'],
|
||||
window_cancel=msg['window_cancel'],
|
||||
confirmation_button=msg.get('confirmation_button', True),
|
||||
min_width=msg.get('min_width'))
|
||||
min_width=msg.get('min_width'),
|
||||
min_height=msg.get('min_height'))
|
||||
diag.ask()
|
||||
res = diag.confirmed
|
||||
self.thread_animate_progress.animate()
|
||||
|
||||
Reference in New Issue
Block a user