hw_wallet: de-dupe "message_dialog" code, make text selectable
This commit is contained in:
@@ -66,20 +66,11 @@ class Plugin(BitBox02Plugin, QtPluginBase):
|
||||
|
||||
|
||||
class BitBox02_Handler(QtHandlerBase):
|
||||
MESSAGE_DIALOG_TITLE = _("BitBox02 Status")
|
||||
|
||||
def __init__(self, win):
|
||||
super(BitBox02_Handler, self).__init__(win, "BitBox02")
|
||||
|
||||
def message_dialog(self, msg):
|
||||
self.clear_dialog()
|
||||
self.dialog = dialog = WindowModalDialog(
|
||||
self.top_level_window(), _("BitBox02 Status")
|
||||
)
|
||||
l = QLabel(msg)
|
||||
vbox = QVBoxLayout(dialog)
|
||||
vbox.addWidget(l)
|
||||
dialog.show()
|
||||
|
||||
def name_multisig_account(self):
|
||||
return QMetaObject.invokeMethod(
|
||||
self,
|
||||
|
||||
@@ -84,18 +84,11 @@ class Plugin(ColdcardPlugin, QtPluginBase):
|
||||
|
||||
|
||||
class Coldcard_Handler(QtHandlerBase):
|
||||
MESSAGE_DIALOG_TITLE = _("Coldcard Status")
|
||||
|
||||
def __init__(self, win):
|
||||
super(Coldcard_Handler, self).__init__(win, 'Coldcard')
|
||||
|
||||
def message_dialog(self, msg):
|
||||
self.clear_dialog()
|
||||
self.dialog = dialog = WindowModalDialog(self.top_level_window(), _("Coldcard Status"))
|
||||
l = QLabel(msg)
|
||||
vbox = QVBoxLayout(dialog)
|
||||
vbox.addWidget(l)
|
||||
dialog.show()
|
||||
|
||||
|
||||
class CKCCSettingsDialog(WindowModalDialog):
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import threading
|
||||
from functools import partial
|
||||
from typing import TYPE_CHECKING, Union, Optional, Callable, Any
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, Qt
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QLineEdit, QHBoxLayout, QLabel
|
||||
|
||||
from electrum.gui.qt.password_dialog import PasswordLayout, PW_PASSPHRASE
|
||||
@@ -167,14 +167,17 @@ class QtHandlerBase(HardwareHandlerBase, QObject, Logger):
|
||||
self.word = text.text()
|
||||
self.done.set()
|
||||
|
||||
def message_dialog(self, msg, on_cancel):
|
||||
# Called more than once during signing, to confirm output and fee
|
||||
MESSAGE_DIALOG_TITLE = None # type: Optional[str]
|
||||
def message_dialog(self, msg, on_cancel=None):
|
||||
self.clear_dialog()
|
||||
title = _('Please check your {} device').format(self.device)
|
||||
title = self.MESSAGE_DIALOG_TITLE
|
||||
if title is None:
|
||||
title = _('Please check your {} device').format(self.device)
|
||||
self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
|
||||
l = QLabel(msg)
|
||||
label = QLabel(msg)
|
||||
label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
vbox = QVBoxLayout(dialog)
|
||||
vbox.addWidget(l)
|
||||
vbox.addWidget(label)
|
||||
if on_cancel:
|
||||
dialog.rejected.connect(on_cancel)
|
||||
vbox.addLayout(Buttons(CancelButton(dialog)))
|
||||
|
||||
@@ -35,13 +35,7 @@ class Jade_Handler(QtHandlerBase):
|
||||
setup_signal = pyqtSignal()
|
||||
auth_signal = pyqtSignal(object, object)
|
||||
|
||||
MESSAGE_DIALOG_TITLE = _("Jade Status")
|
||||
|
||||
def __init__(self, win):
|
||||
super(Jade_Handler, self).__init__(win, 'Jade')
|
||||
|
||||
def message_dialog(self, msg):
|
||||
self.clear_dialog()
|
||||
self.dialog = dialog = WindowModalDialog(self.top_level_window(), _("Jade Status"))
|
||||
l = QLabel(msg)
|
||||
vbox = QVBoxLayout(dialog)
|
||||
vbox.addWidget(l)
|
||||
dialog.show()
|
||||
|
||||
@@ -35,6 +35,8 @@ class Ledger_Handler(QtHandlerBase):
|
||||
setup_signal = pyqtSignal()
|
||||
auth_signal = pyqtSignal(object, object)
|
||||
|
||||
MESSAGE_DIALOG_TITLE = _("Ledger Status")
|
||||
|
||||
def __init__(self, win):
|
||||
super(Ledger_Handler, self).__init__(win, 'Ledger')
|
||||
self.setup_signal.connect(self.setup_dialog)
|
||||
@@ -48,14 +50,6 @@ class Ledger_Handler(QtHandlerBase):
|
||||
self.word = str(response[0])
|
||||
self.done.set()
|
||||
|
||||
def message_dialog(self, msg):
|
||||
self.clear_dialog()
|
||||
self.dialog = dialog = WindowModalDialog(self.top_level_window(), _("Ledger Status"))
|
||||
l = QLabel(msg)
|
||||
vbox = QVBoxLayout(dialog)
|
||||
vbox.addWidget(l)
|
||||
dialog.show()
|
||||
|
||||
def auth_dialog(self, data, client: 'Ledger_Client'):
|
||||
try:
|
||||
from .auth2fa import LedgerAuthDialog
|
||||
|
||||
Reference in New Issue
Block a user