mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[view] improvement: allowing max_width to be defined for the confirmation dialogs
This commit is contained in:
@@ -21,7 +21,8 @@ class 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,
|
||||
min_height: Optional[int] = None) -> bool:
|
||||
min_height: Optional[int] = None,
|
||||
max_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
|
||||
@@ -34,6 +35,7 @@ class ProcessWatcher:
|
||||
: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
|
||||
:param max_width: maximum width for the confirmation dialog
|
||||
:return: if the request was confirmed by the user
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -35,7 +35,7 @@ class ConfirmationDialog(QDialog):
|
||||
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,
|
||||
min_height: Optional[int] = None):
|
||||
min_height: Optional[int] = None, max_width: Optional[int] = None):
|
||||
super(ConfirmationDialog, self).__init__()
|
||||
|
||||
if not window_cancel:
|
||||
@@ -46,6 +46,9 @@ class ConfirmationDialog(QDialog):
|
||||
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
||||
self.setMinimumWidth(min_width if min_width and min_width > 0 else 250)
|
||||
|
||||
if max_width is not None and max_width > 0:
|
||||
self.setMaximumWidth(max_width)
|
||||
|
||||
if isinstance(min_height, int) and min_height > 0:
|
||||
self.setMinimumHeight(min_height)
|
||||
|
||||
|
||||
@@ -60,13 +60,14 @@ class AsyncAction(QThread, ProcessWatcher):
|
||||
window_cancel: bool = False,
|
||||
confirmation_button: bool = True,
|
||||
min_width: Optional[int] = None,
|
||||
min_height: Optional[int] = None) -> bool:
|
||||
min_height: Optional[int] = None,
|
||||
max_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, 'min_width': min_width,
|
||||
'min_height': min_height})
|
||||
'min_height': min_height, 'max_width': max_width})
|
||||
self.wait_user()
|
||||
return self.confirmation_res
|
||||
|
||||
|
||||
@@ -559,7 +559,8 @@ class ManageWindow(QWidget):
|
||||
window_cancel=msg['window_cancel'],
|
||||
confirmation_button=msg.get('confirmation_button', True),
|
||||
min_width=msg.get('min_width'),
|
||||
min_height=msg.get('min_height'))
|
||||
min_height=msg.get('min_height'),
|
||||
max_width=msg.get('max_width'))
|
||||
diag.ask()
|
||||
res = diag.confirmed
|
||||
self.thread_animate_progress.animate()
|
||||
|
||||
Reference in New Issue
Block a user