kivy: fix #6280 (share btn in qr_dialog)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
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.core.clipboard import Clipboard
|
||||||
@@ -6,6 +8,9 @@ from kivy.clock import Clock
|
|||||||
|
|
||||||
from electrum.gui.kivy.i18n import _
|
from electrum.gui.kivy.i18n import _
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ...main_window import ElectrumWindow
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
<QRDialog@Popup>
|
<QRDialog@Popup>
|
||||||
@@ -45,7 +50,7 @@ Builder.load_string('''
|
|||||||
icon: 'atlas://electrum/gui/kivy/theming/light/share'
|
icon: 'atlas://electrum/gui/kivy/theming/light/share'
|
||||||
size_hint: 0.6, None
|
size_hint: 0.6, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
on_release: s.parent.do_share()
|
on_release: root.do_share()
|
||||||
Button:
|
Button:
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
@@ -58,7 +63,7 @@ class QRDialog(Factory.Popup):
|
|||||||
def __init__(self, title, data, show_text, *,
|
def __init__(self, title, data, show_text, *,
|
||||||
failure_cb=None, text_for_clipboard=None, help_text=None):
|
failure_cb=None, text_for_clipboard=None, help_text=None):
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
self.app = App.get_running_app()
|
self.app = App.get_running_app() # type: ElectrumWindow
|
||||||
self.title = title
|
self.title = title
|
||||||
self.data = data
|
self.data = data
|
||||||
self.help_text = (data if show_text else help_text) or ''
|
self.help_text = (data if show_text else help_text) or ''
|
||||||
@@ -72,3 +77,7 @@ class QRDialog(Factory.Popup):
|
|||||||
Clipboard.copy(self.text_for_clipboard)
|
Clipboard.copy(self.text_for_clipboard)
|
||||||
msg = _('Text copied to clipboard.')
|
msg = _('Text copied to clipboard.')
|
||||||
Clock.schedule_once(lambda dt: self.app.show_info(msg))
|
Clock.schedule_once(lambda dt: self.app.show_info(msg))
|
||||||
|
|
||||||
|
def do_share(self):
|
||||||
|
self.app.do_share(self.text_for_clipboard, self.title)
|
||||||
|
self.dismiss()
|
||||||
|
|||||||
Reference in New Issue
Block a user