mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 02:05:19 +00:00
fix #3439: ScanQRTextEdit optionally allows to concat data
This commit is contained in:
parent
13bf539d17
commit
aef0444867
5 changed files with 21 additions and 10 deletions
|
@ -702,6 +702,7 @@ class AddXpubDialog(WizardDialog):
|
||||||
self.is_valid = kwargs['is_valid']
|
self.is_valid = kwargs['is_valid']
|
||||||
self.title = kwargs['title']
|
self.title = kwargs['title']
|
||||||
self.message = kwargs['message']
|
self.message = kwargs['message']
|
||||||
|
self.allow_multi = kwargs.get('allow_multi', False)
|
||||||
|
|
||||||
def check_text(self, dt):
|
def check_text(self, dt):
|
||||||
self.ids.next.disabled = not bool(self.is_valid(self.get_text()))
|
self.ids.next.disabled = not bool(self.is_valid(self.get_text()))
|
||||||
|
@ -715,7 +716,10 @@ class AddXpubDialog(WizardDialog):
|
||||||
|
|
||||||
def scan_xpub(self):
|
def scan_xpub(self):
|
||||||
def on_complete(text):
|
def on_complete(text):
|
||||||
self.ids.text_input.text = text
|
if self.allow_multi:
|
||||||
|
self.ids.text_input.text += text + '\n'
|
||||||
|
else:
|
||||||
|
self.ids.text_input.text = text
|
||||||
self.app.scan_qr(on_complete)
|
self.app.scan_qr(on_complete)
|
||||||
|
|
||||||
def do_paste(self):
|
def do_paste(self):
|
||||||
|
|
|
@ -332,8 +332,9 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||||
def remove_from_recently_open(self, filename):
|
def remove_from_recently_open(self, filename):
|
||||||
self.config.remove_from_recently_open(filename)
|
self.config.remove_from_recently_open(filename)
|
||||||
|
|
||||||
def text_input(self, title, message, is_valid):
|
def text_input(self, title, message, is_valid, allow_multi=False):
|
||||||
slayout = KeysLayout(parent=self, title=message, is_valid=is_valid)
|
slayout = KeysLayout(parent=self, title=message, is_valid=is_valid,
|
||||||
|
allow_multi=allow_multi)
|
||||||
self.exec_layout(slayout, title, next_enabled=False)
|
self.exec_layout(slayout, title, next_enabled=False)
|
||||||
return slayout.get_text()
|
return slayout.get_text()
|
||||||
|
|
||||||
|
@ -343,8 +344,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||||
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
|
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
|
||||||
|
|
||||||
@wizard_dialog
|
@wizard_dialog
|
||||||
def add_xpub_dialog(self, title, message, is_valid, run_next):
|
def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False):
|
||||||
return self.text_input(title, message, is_valid)
|
return self.text_input(title, message, is_valid, allow_multi)
|
||||||
|
|
||||||
@wizard_dialog
|
@wizard_dialog
|
||||||
def add_cosigner_dialog(self, run_next, index, is_valid):
|
def add_cosigner_dialog(self, run_next, index, is_valid):
|
||||||
|
|
|
@ -33,8 +33,9 @@ class ShowQRTextEdit(ButtonsTextEdit):
|
||||||
|
|
||||||
class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
||||||
|
|
||||||
def __init__(self, text=""):
|
def __init__(self, text="", allow_multi=False):
|
||||||
ButtonsTextEdit.__init__(self, text)
|
ButtonsTextEdit.__init__(self, text)
|
||||||
|
self.allow_multi = allow_multi
|
||||||
self.setReadOnly(0)
|
self.setReadOnly(0)
|
||||||
self.addButton(":icons/file.png", self.file_input, _("Read file"))
|
self.addButton(":icons/file.png", self.file_input, _("Read file"))
|
||||||
icon = ":icons/qrcode_white.png" if ColorScheme.dark_scheme else ":icons/qrcode.png"
|
icon = ":icons/qrcode_white.png" if ColorScheme.dark_scheme else ":icons/qrcode.png"
|
||||||
|
@ -58,7 +59,11 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
||||||
data = ''
|
data = ''
|
||||||
if not data:
|
if not data:
|
||||||
data = ''
|
data = ''
|
||||||
self.setText(data)
|
if self.allow_multi:
|
||||||
|
new_text = self.text() + data + '\n'
|
||||||
|
else:
|
||||||
|
new_text = data
|
||||||
|
self.setText(new_text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def contextMenuEvent(self, e):
|
def contextMenuEvent(self, e):
|
||||||
|
|
|
@ -153,11 +153,11 @@ class SeedLayout(QVBoxLayout):
|
||||||
|
|
||||||
|
|
||||||
class KeysLayout(QVBoxLayout):
|
class KeysLayout(QVBoxLayout):
|
||||||
def __init__(self, parent=None, title=None, is_valid=None):
|
def __init__(self, parent=None, title=None, is_valid=None, allow_multi=False):
|
||||||
QVBoxLayout.__init__(self)
|
QVBoxLayout.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.is_valid = is_valid
|
self.is_valid = is_valid
|
||||||
self.text_e = ScanQRTextEdit()
|
self.text_e = ScanQRTextEdit(allow_multi=allow_multi)
|
||||||
self.text_e.textChanged.connect(self.on_edit)
|
self.text_e.textChanged.connect(self.on_edit)
|
||||||
self.addWidget(WWLabel(title))
|
self.addWidget(WWLabel(title))
|
||||||
self.addWidget(self.text_e)
|
self.addWidget(self.text_e)
|
||||||
|
|
|
@ -140,7 +140,8 @@ class BaseWizard(object):
|
||||||
v = lambda x: keystore.is_address_list(x) or keystore.is_private_key_list(x)
|
v = lambda x: keystore.is_address_list(x) or keystore.is_private_key_list(x)
|
||||||
title = _("Import Bitcoin Addresses")
|
title = _("Import Bitcoin Addresses")
|
||||||
message = _("Enter a list of Bitcoin addresses (this will create a watching-only wallet), or a list of private keys.")
|
message = _("Enter a list of Bitcoin addresses (this will create a watching-only wallet), or a list of private keys.")
|
||||||
self.add_xpub_dialog(title=title, message=message, run_next=self.on_import, is_valid=v)
|
self.add_xpub_dialog(title=title, message=message, run_next=self.on_import,
|
||||||
|
is_valid=v, allow_multi=True)
|
||||||
|
|
||||||
def on_import(self, text):
|
def on_import(self, text):
|
||||||
if keystore.is_address_list(text):
|
if keystore.is_address_list(text):
|
||||||
|
|
Loading…
Add table
Reference in a new issue