From 69b1837c831d102a0197ac0b1af8c6f46b1b5bbd Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 26 Aug 2019 14:32:33 -0300 Subject: [PATCH] supporting custom confirmation / deny button label --- bauh/resources/locale/en | 3 ++- bauh/resources/locale/es | 3 ++- bauh/resources/locale/pt | 3 ++- bauh/view/qt/confirmation.py | 6 +++--- bauh/view/qt/thread.py | 4 ++-- bauh/view/qt/window.py | 7 ++++++- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/bauh/resources/locale/en b/bauh/resources/locale/en index 325e1e13..f0de3da7 100644 --- a/bauh/resources/locale/en +++ b/bauh/resources/locale/en @@ -88,4 +88,5 @@ action.cancelled=operation cancelled by the user copy=copy back=back show=show -ask.continue=Continue ? \ No newline at end of file +ask.continue=Continue ? +cancel=cancel diff --git a/bauh/resources/locale/es b/bauh/resources/locale/es index 56c70206..d396aa7c 100644 --- a/bauh/resources/locale/es +++ b/bauh/resources/locale/es @@ -90,4 +90,5 @@ action.cancelled=operación cancelada por el usuario copy=copiar back=volver show=mostrar -ask.continue=¿Continuar ? \ No newline at end of file +ask.continue=¿Continuar ? +cancel=cancelar \ No newline at end of file diff --git a/bauh/resources/locale/pt b/bauh/resources/locale/pt index 7ef6ff78..43a4a0e1 100644 --- a/bauh/resources/locale/pt +++ b/bauh/resources/locale/pt @@ -90,4 +90,5 @@ action.cancelled=operação cancelada pelo usuário copy=copiar back=voltar show=mostrar -ask.continue=Continuar ? \ No newline at end of file +ask.continue=Continuar ? +cancel=cancelar \ No newline at end of file diff --git a/bauh/view/qt/confirmation.py b/bauh/view/qt/confirmation.py index 5443154b..702815aa 100644 --- a/bauh/view/qt/confirmation.py +++ b/bauh/view/qt/confirmation.py @@ -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: diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 99d9260e..ba3e2d4e 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -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 diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 4fe48f6a..a6061ee1 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -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):