commit 336cf81a6def88ae803c11926c93b56de2bed1b8
parent 27a9d02b8cf4110f67644a2442dd255d5a36e482
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 20 Aug 2019 18:20:54 +0200
kivy: add expiration button to receive screen
Diffstat:
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/electrum/gui/kivy/main.kv b/electrum/gui/kivy/main.kv
@@ -389,7 +389,7 @@
slide: 0
CleanHeader:
id: history_tab
- text: _('Balance')
+ text: _('History')
slide: 1
CleanHeader:
id: receive_tab
diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py
@@ -315,6 +315,7 @@ class SendScreen(CScreen):
return
if success:
self.app.show_info(_('Payment was sent'))
+ self.app._trigger_update_history()
else:
self.app.show_error(_('Payment failed'))
@@ -408,6 +409,7 @@ class ReceiveScreen(CScreen):
def __init__(self, **kwargs):
super(ReceiveScreen, self).__init__(**kwargs)
self.menu_actions = [(_('Show'), self.do_show), (_('Delete'), self.do_delete)]
+ self.expiration = self.app.electrum_config.get('request_expiration', 3600) # 1 hour
def clear(self):
self.screen.address = ''
@@ -450,7 +452,7 @@ class ReceiveScreen(CScreen):
amount = self.screen.amount
amount = self.app.get_amount(amount) if amount else 0
message = self.screen.message
- expiration = 3600 # 1 hour
+ expiration = self.expiration
if lightning:
payment_hash = self.app.wallet.lnworker.add_invoice(amount, message)
request, direction, is_paid = self.app.wallet.lnworker.invoices.get(payment_hash.hex())
@@ -497,17 +499,34 @@ class ReceiveScreen(CScreen):
def update(self):
_list = self.app.wallet.get_sorted_requests(self.app.electrum_config)
requests_container = self.screen.ids.requests_container
- requests_container.data = [self.get_card(item) for item in _list]
+ requests_container.data = [self.get_card(item) for item in _list if item.get('status') != PR_PAID]
def do_show(self, obj):
self.hide_menu()
self.app.show_request(obj.is_lightning, obj.key)
+ def expiration_dialog(self, obj):
+ from .dialogs.choice_dialog import ChoiceDialog
+ choices = {
+ 10*60: _('10 minutes'),
+ 60*60: _('1 hour'),
+ 24*60*60: _('1 day'),
+ 7*24*60*60: _('1 week')
+ }
+ def callback(c):
+ self.expiration = c
+ self.app.electrum_config.set_key('request_expiration', c)
+ d = ChoiceDialog(_('Expiration date'), choices, self.expiration, callback)
+ d.open()
+
def do_delete(self, req):
from .dialogs.question import Question
def cb(result):
if result:
- self.app.wallet.remove_payment_request(req.address, self.app.electrum_config)
+ if req.is_lightning:
+ self.app.wallet.lnworker.delete_invoice(req.key)
+ else:
+ self.app.wallet.remove_payment_request(req.key, self.app.electrum_config)
self.hide_menu()
self.update()
d = Question(_('Delete request'), cb)
diff --git a/electrum/gui/kivy/uix/ui_screens/receive.kv b/electrum/gui/kivy/uix/ui_screens/receive.kv
@@ -145,9 +145,11 @@ ReceiveScreen:
size_hint: 0.5, None
height: '48dp'
on_release: root.show_list = not root.show_list
- #Clock.schedule_once(lambda dt: app.requests_dialog(s))
- Widget:
+ IconButton:
+ icon: 'atlas://electrum/gui/kivy/theming/light/clock1'
size_hint: 0.5, None
+ height: '48dp'
+ on_release: Clock.schedule_once(lambda dt: s.expiration_dialog(s))
Button:
text: _('Clear')
size_hint: 1, None