electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6cf7aefe28bc2d248782623378e8eb624f744be7
parent 21ab65e5f76c10c46dc067cf4427522fee22fd64
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue,  4 Jun 2019 19:20:31 +0200

kivy: offer to copy raw hex tx to clipboard

related: #5405

Diffstat:
Melectrum/gui/kivy/main_window.py | 3++-
Melectrum/gui/kivy/uix/dialogs/qr_dialog.py | 21+++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py @@ -435,7 +435,8 @@ 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, on_qr_failure) + popup = QRDialog(title, data, show_text, failure_cb=on_qr_failure, + text_for_clipboard=text_for_clipboard) popup.open() def scan_qr(self, on_complete): diff --git a/electrum/gui/kivy/uix/dialogs/qr_dialog.py b/electrum/gui/kivy/uix/dialogs/qr_dialog.py @@ -1,5 +1,11 @@ from kivy.factory import Factory from kivy.lang import Builder +from kivy.core.clipboard import Clipboard +from kivy.app import App +from kivy.clock import Clock + +from electrum.gui.kivy.i18n import _ + Builder.load_string(''' <QRDialog@Popup> @@ -24,9 +30,12 @@ Builder.load_string(''' BoxLayout: size_hint: 1, None height: '48dp' - Widget: + Button: size_hint: 1, None height: '48dp' + text: _('Copy to clipboard') + on_release: + root.copy_to_clipboard() Button: size_hint: 1, None height: '48dp' @@ -36,12 +45,20 @@ Builder.load_string(''' ''') class QRDialog(Factory.Popup): - def __init__(self, title, data, show_text, failure_cb=None): + def __init__(self, title, data, show_text, *, + failure_cb=None, text_for_clipboard=None): Factory.Popup.__init__(self) + self.app = App.get_running_app() self.title = title self.data = data self.show_text = show_text self.failure_cb = failure_cb + self.text_for_clipboard = text_for_clipboard if text_for_clipboard else data def on_open(self): self.ids.qr.set_data(self.data, self.failure_cb) + + def copy_to_clipboard(self): + Clipboard.copy(self.text_for_clipboard) + msg = _('Text copied to clipboard.') + Clock.schedule_once(lambda dt: self.app.show_info(msg))