Browse Source

kivy: offer to copy raw hex tx to clipboard

related: #5405
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
parent
commit
6cf7aefe28
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/kivy/main_window.py
  2. 21
      electrum/gui/kivy/uix/dialogs/qr_dialog.py

3
electrum/gui/kivy/main_window.py

@ -435,7 +435,8 @@ class ElectrumWindow(App):
msg += '\n' + _('Text copied to clipboard.') msg += '\n' + _('Text copied to clipboard.')
self._clipboard.copy(text_for_clipboard) self._clipboard.copy(text_for_clipboard)
Clock.schedule_once(lambda dt: self.show_info(msg)) 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() popup.open()
def scan_qr(self, on_complete): def scan_qr(self, on_complete):

21
electrum/gui/kivy/uix/dialogs/qr_dialog.py

@ -1,5 +1,11 @@
from kivy.factory import Factory from kivy.factory import Factory
from kivy.lang import Builder 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(''' Builder.load_string('''
<QRDialog@Popup> <QRDialog@Popup>
@ -24,9 +30,12 @@ Builder.load_string('''
BoxLayout: BoxLayout:
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
Widget: Button:
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
text: _('Copy to clipboard')
on_release:
root.copy_to_clipboard()
Button: Button:
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
@ -36,12 +45,20 @@ Builder.load_string('''
''') ''')
class QRDialog(Factory.Popup): 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) Factory.Popup.__init__(self)
self.app = App.get_running_app()
self.title = title self.title = title
self.data = data self.data = data
self.show_text = show_text self.show_text = show_text
self.failure_cb = failure_cb self.failure_cb = failure_cb
self.text_for_clipboard = text_for_clipboard if text_for_clipboard else data
def on_open(self): def on_open(self):
self.ids.qr.set_data(self.data, self.failure_cb) 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))

Loading…
Cancel
Save