supporting custom confirmation / deny button label

This commit is contained in:
Vinicius Moreira
2019-08-26 14:32:33 -03:00
parent 0f33597168
commit 69b1837c83
6 changed files with 17 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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):