commit 661ecb2cf520e25ccdd5e01ac49d8c4884d2d09f
parent 83cabccdb59095c8b4a9fe649ecb296647699131
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 16 Jun 2020 18:48:04 +0200
add help text to channel backup QR code
Diffstat:
6 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
@@ -462,7 +462,7 @@ class ElectrumWindow(App):
self.invoice_popup = InvoiceDialog('Invoice', data, key)
self.invoice_popup.open()
- def qr_dialog(self, title, data, show_text=False, text_for_clipboard=None):
+ def qr_dialog(self, title, data, show_text=False, text_for_clipboard=None, help_text=None):
from .uix.dialogs.qr_dialog import QRDialog
def on_qr_failure():
popup.dismiss()
@@ -471,8 +471,11 @@ class ElectrumWindow(App):
msg += '\n' + _('Text copied to clipboard.')
self._clipboard.copy(text_for_clipboard)
Clock.schedule_once(lambda dt: self.show_info(msg))
- popup = QRDialog(title, data, show_text, failure_cb=on_qr_failure,
- text_for_clipboard=text_for_clipboard)
+ popup = QRDialog(
+ title, data, show_text,
+ failure_cb=on_qr_failure,
+ text_for_clipboard=text_for_clipboard,
+ help_text=help_text)
popup.open()
def scan_qr(self, on_complete):
diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
@@ -373,7 +373,13 @@ class ChannelDetailsPopup(Popup):
def export_backup(self):
text = self.app.wallet.lnworker.export_channel_backup(self.chan.channel_id)
- self.app.qr_dialog(_("Channel Backup " + self.chan.short_id_for_GUI()), 'channel_backup:'+text)
+ # TODO: some messages are duplicated between Kivy and Qt.
+ help_text = ' '.join([
+ _("Channel backups can be imported in another instance of the same wallet, by scanning this QR code."),
+ _("Please note that channel backups cannot be used to restore your channels."),
+ _("If you lose your wallet file, the only thing you can do with a backup is to request your channel to be closed, so that your funds will be sent on-chain."),
+ ])
+ self.app.qr_dialog(_("Channel Backup " + self.chan.short_id_for_GUI()), 'channel_backup:'+text, help_text=help_text)
def force_close(self):
Question(_('Force-close channel?'), self._force_close).open()
diff --git a/electrum/gui/kivy/uix/dialogs/qr_dialog.py b/electrum/gui/kivy/uix/dialogs/qr_dialog.py
@@ -13,7 +13,7 @@ Builder.load_string('''
title: ''
data: ''
shaded: False
- show_text: False
+ help_text: ''
AnchorLayout:
anchor_x: 'center'
BoxLayout:
@@ -29,7 +29,7 @@ Builder.load_string('''
touch = args[1]
if self.collide_point(*touch.pos): self.shaded = not self.shaded
TopLabel:
- text: root.data if root.show_text else ''
+ text: root.help_text
Widget:
size_hint: 1, 0.2
BoxLayout:
@@ -56,12 +56,12 @@ Builder.load_string('''
class QRDialog(Factory.Popup):
def __init__(self, title, data, show_text, *,
- failure_cb=None, text_for_clipboard=None):
+ failure_cb=None, text_for_clipboard=None, help_text=None):
Factory.Popup.__init__(self)
self.app = App.get_running_app()
self.title = title
self.data = data
- self.show_text = show_text
+ self.help_text = data if show_text else help_text
self.failure_cb = failure_cb
self.text_for_clipboard = text_for_clipboard if text_for_clipboard else data
diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py
@@ -126,8 +126,13 @@ class ChannelsList(MyTreeView):
self.lnbackups.remove_channel_backup(channel_id)
def export_channel_backup(self, channel_id):
+ msg = ' '.join([
+ _("Channel backups can be imported in another instance of the same wallet, by scanning this QR code."),
+ _("Please note that channel backups cannot be used to restore your channels."),
+ _("If you lose your wallet file, the only thing you can do with a backup is to request your channel to be closed, so that your funds will be sent on-chain."),
+ ])
data = self.lnworker.export_channel_backup(channel_id)
- self.main_window.show_qrcode('channel_backup:' + data, 'channel backup')
+ self.main_window.show_qrcode('channel_backup:' + data, 'channel backup', help_text=msg)
def request_force_close(self, channel_id):
def task():
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -2372,10 +2372,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
d = SeedDialog(self, seed, passphrase)
d.exec_()
- def show_qrcode(self, data, title = _("QR code"), parent=None):
+ def show_qrcode(self, data, title = _("QR code"), parent=None, help_text=None):
if not data:
return
- d = QRDialog(data, parent or self, title)
+ d = QRDialog(data, parent or self, title, help_text=help_text)
d.exec_()
@protected
diff --git a/electrum/gui/qt/qrcodewidget.py b/electrum/gui/qt/qrcodewidget.py
@@ -10,7 +10,7 @@ from PyQt5.QtWidgets import (
from electrum.i18n import _
-from .util import WindowModalDialog, get_parent_main_window
+from .util import WindowModalDialog, get_parent_main_window, WWLabel
class QRCodeWidget(QWidget):
@@ -93,17 +93,17 @@ class QRCodeWidget(QWidget):
class QRDialog(WindowModalDialog):
- def __init__(self, data, parent=None, title = "", show_text=False):
+ def __init__(self, data, parent=None, title = "", show_text=False, help_text=None):
WindowModalDialog.__init__(self, parent, title)
vbox = QVBoxLayout()
qrw = QRCodeWidget(data)
vbox.addWidget(qrw, 1)
- if show_text:
- text = QTextEdit()
- text.setText(data)
- text.setReadOnly(True)
- vbox.addWidget(text)
+ help_text = data if show_text else help_text
+ if help_text:
+ text_label = WWLabel()
+ text_label.setText(help_text)
+ vbox.addWidget(text_label)
hbox = QHBoxLayout()
hbox.addStretch(1)