mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 03:34:15 +02:00
supporting custom confirmation / deny button label
This commit is contained in:
@@ -88,4 +88,5 @@ action.cancelled=operation cancelled by the user
|
||||
copy=copy
|
||||
back=back
|
||||
show=show
|
||||
ask.continue=Continue ?
|
||||
ask.continue=Continue ?
|
||||
cancel=cancel
|
||||
|
||||
@@ -90,4 +90,5 @@ action.cancelled=operación cancelada por el usuario
|
||||
copy=copiar
|
||||
back=volver
|
||||
show=mostrar
|
||||
ask.continue=¿Continuar ?
|
||||
ask.continue=¿Continuar ?
|
||||
cancel=cancelar
|
||||
@@ -90,4 +90,5 @@ action.cancelled=operação cancelada pelo usuário
|
||||
copy=copiar
|
||||
back=voltar
|
||||
show=mostrar
|
||||
ask.continue=Continuar ?
|
||||
ask.continue=Continuar ?
|
||||
cancel=cancelar
|
||||
@@ -8,12 +8,12 @@ from bauh.view.qt.components import MultipleSelectQt, new_single_select
|
||||
|
||||
class ConfirmationDialog(QMessageBox):
|
||||
|
||||
def __init__(self, title: str, body: str, locale_keys: dict, components: List[ViewComponent] = None):
|
||||
def __init__(self, title: str, body: str, locale_keys: dict, components: List[ViewComponent] = None, confirmation_label: str = None, deny_label: str = None):
|
||||
super(ConfirmationDialog, self).__init__()
|
||||
self.setWindowTitle(title)
|
||||
self.setStyleSheet('QLabel { margin-right: 25px; }')
|
||||
self.bt_yes = self.addButton(locale_keys['popup.button.yes'], QMessageBox.YesRole)
|
||||
self.addButton(locale_keys['popup.button.no'], QMessageBox.NoRole)
|
||||
self.bt_yes = self.addButton(locale_keys['popup.button.yes'] if not confirmation_label else confirmation_label.capitalize(), QMessageBox.YesRole)
|
||||
self.addButton(locale_keys['popup.button.no'] if not deny_label else deny_label.capitalize(), QMessageBox.NoRole)
|
||||
|
||||
if body:
|
||||
if components:
|
||||
|
||||
@@ -28,9 +28,9 @@ class AsyncAction(QThread, ProcessWatcher):
|
||||
self.wait_confirmation = False
|
||||
self.confirmation_res = None
|
||||
|
||||
def request_confirmation(self, title: str, body: str, options: List[InputViewComponent] = None) -> bool:
|
||||
def request_confirmation(self, title: str, body: str, options: List[InputViewComponent] = None, confirmation_label: str = None, deny_label: str = None) -> bool:
|
||||
self.wait_confirmation = True
|
||||
self.signal_confirmation.emit({'title': title, 'body': body, 'options': options})
|
||||
self.signal_confirmation.emit({'title': title, 'body': body, 'components': options, 'confirmation_label': confirmation_label, 'deny_label': deny_label})
|
||||
self.wait_user()
|
||||
return self.confirmation_res
|
||||
|
||||
|
||||
@@ -223,7 +223,12 @@ class ManageWindow(QWidget):
|
||||
return action
|
||||
|
||||
def _ask_confirmation(self, msg: dict):
|
||||
diag = ConfirmationDialog(title=msg['title'], body=msg['body'], locale_keys=self.locale_keys, components=msg['options'])
|
||||
diag = ConfirmationDialog(title=msg['title'],
|
||||
body=msg['body'],
|
||||
locale_keys=self.locale_keys,
|
||||
components=msg['components'],
|
||||
confirmation_label=msg['confirmation_label'],
|
||||
deny_label=msg['deny_label'])
|
||||
self.signal_user_res.emit(diag.is_confirmed())
|
||||
|
||||
def _show_message(self, msg: dict):
|
||||
|
||||
Reference in New Issue
Block a user