mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
Add cancel button to trezor dialogs
This commit is contained in:
parent
144f53be18
commit
c160a99ebc
2 changed files with 11 additions and 13 deletions
|
@ -23,13 +23,7 @@ class GuiMixin(object):
|
||||||
def callback_ButtonRequest(self, msg):
|
def callback_ButtonRequest(self, msg):
|
||||||
msg_code = self.msg_code_override or msg.code
|
msg_code = self.msg_code_override or msg.code
|
||||||
message = self.messages.get(msg_code, self.messages['default'])
|
message = self.messages.get(msg_code, self.messages['default'])
|
||||||
|
self.handler.show_message(message % self.device, self.cancel)
|
||||||
if msg.code in [3, 8] and hasattr(self, 'cancel'):
|
|
||||||
cancel_callback = self.cancel
|
|
||||||
else:
|
|
||||||
cancel_callback = None
|
|
||||||
|
|
||||||
self.handler.show_message(message % self.device, cancel_callback)
|
|
||||||
return self.proto.ButtonAck()
|
return self.proto.ButtonAck()
|
||||||
|
|
||||||
def callback_PinMatrixRequest(self, msg):
|
def callback_PinMatrixRequest(self, msg):
|
||||||
|
@ -106,6 +100,10 @@ class TrezorClientBase(GuiMixin, PrintError):
|
||||||
path.append(abs(int(x)) | prime)
|
path.append(abs(int(x)) | prime)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
'''Provided here as in keepkeylib but not trezorlib.'''
|
||||||
|
self.transport.write(self.proto.Cancel())
|
||||||
|
|
||||||
def first_address(self, derivation):
|
def first_address(self, derivation):
|
||||||
return self.address_from_derivation(derivation)
|
return self.address_from_derivation(derivation)
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ class QtHandler(PrintError):
|
||||||
def watching_only_changed(self):
|
def watching_only_changed(self):
|
||||||
self.win.emit(SIGNAL('watching_only_changed'))
|
self.win.emit(SIGNAL('watching_only_changed'))
|
||||||
|
|
||||||
def show_message(self, msg, cancel_callback=None):
|
def show_message(self, msg, on_cancel=None):
|
||||||
self.win.emit(SIGNAL('message_dialog'), msg, cancel_callback)
|
self.win.emit(SIGNAL('message_dialog'), msg, on_cancel)
|
||||||
|
|
||||||
def show_error(self, msg):
|
def show_error(self, msg):
|
||||||
self.win.emit(SIGNAL('error_dialog'), msg)
|
self.win.emit(SIGNAL('error_dialog'), msg)
|
||||||
|
@ -106,17 +106,17 @@ class QtHandler(PrintError):
|
||||||
self.word = unicode(text.text())
|
self.word = unicode(text.text())
|
||||||
self.done.set()
|
self.done.set()
|
||||||
|
|
||||||
def message_dialog(self, msg, cancel_callback):
|
def message_dialog(self, msg, on_cancel):
|
||||||
# Called more than once during signing, to confirm output and fee
|
# Called more than once during signing, to confirm output and fee
|
||||||
self.clear_dialog()
|
self.clear_dialog()
|
||||||
title = _('Please check your %s device') % self.device
|
title = _('Please check your %s device') % self.device
|
||||||
self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
|
self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
|
||||||
l = QLabel(msg)
|
l = QLabel(msg)
|
||||||
vbox = QVBoxLayout(dialog)
|
vbox = QVBoxLayout(dialog)
|
||||||
if cancel_callback:
|
|
||||||
vbox.addLayout(Buttons(CancelButton(dialog)))
|
|
||||||
dialog.connect(dialog, SIGNAL('rejected()'), cancel_callback)
|
|
||||||
vbox.addWidget(l)
|
vbox.addWidget(l)
|
||||||
|
if on_cancel:
|
||||||
|
dialog.rejected.connect(on_cancel)
|
||||||
|
vbox.addLayout(Buttons(CancelButton(dialog)))
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def error_dialog(self, msg):
|
def error_dialog(self, msg):
|
||||||
|
|
Loading…
Add table
Reference in a new issue