commit d56ec05b9bc381f0d5d443980215e208fc177b07
parent 27ecab9ef018c7c0f4e500ff0f15efbf5a58d62c
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 15 Feb 2016 13:49:33 +0100
kivy: show payment request details
Diffstat:
4 files changed, 79 insertions(+), 33 deletions(-)
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -278,6 +278,32 @@ class ElectrumWindow(App):
self.switch_to('receive')
self.receive_screen.screen.address = addr
+ def show_pr_details(self, req, status, is_invoice):
+ from electrum.util import format_time
+ requestor = req.get('requestor')
+ exp = req.get('exp')
+ memo = req.get('memo')
+ amount = req.get('amount')
+ popup = Builder.load_file('gui/kivy/uix/ui_screens/invoice.kv')
+ if is_invoice:
+ popup.title = _('Invoice')
+ popup.ids.requestor_label.text = _("Requestor") + ': ' + requestor
+ else:
+ popup.title = _('Request')
+ popup.ids.requestor_label.text = _("Address") + ': ' + req.get('address')
+
+ popup.ids.amount_label.text = _('Amount') + ': ' + self.format_amount_and_units(amount) if amount else ''
+ popup.ids.expiration_label.text = _('Expires') + ': ' + format_time(exp) if exp else ''
+ popup.ids.memo_label.text = _("Description") + ': ' + memo if memo else _("No Description")
+ popup.ids.signature_label.text = req.get('signature', '')
+
+ popup.ids.txid_label.text = status
+ txid = req.get('txid')
+ if txid:
+ popup.ids.txid_label.text += '\n' + _("Transaction ID") + ':\n' + ' '.join(map(''.join, zip(*[iter(txid)]*4)))
+ popup.open()
+
+
def qr_dialog(self, title, data):
from uix.dialogs.qr_dialog import QRDialog
popup = QRDialog(title, data)
diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
@@ -444,19 +444,8 @@ class InvoicesScreen(CScreen):
def do_view(self, obj):
pr = self.app.invoices.get(obj.key)
pr.verify({})
- exp = pr.get_expiration_date()
- memo = pr.get_memo()
- amount = pr.get_amount()
- popup = Builder.load_file('gui/kivy/uix/ui_screens/invoice.kv')
- popup.ids.requestor_label.text = _("Requestor") + ': ' + pr.get_requestor()
- popup.ids.amount_label.text = _('Amount') + ': ' + self.app.format_amount_and_units(amount) if amount else ''
- popup.ids.expiration_label.text = _('Expires') + ': ' + (format_time(exp) if exp else _('Never'))
- popup.ids.memo_label.text = _("Description") + ': ' + memo if memo else _("No Description")
- popup.ids.signature_label.text = pr.get_verify_status()
- if pr.tx:
- popup.ids.txid_label.text = _("Transaction ID") + ':\n' + ' '.join(map(''.join, zip(*[iter(pr.tx)]*4)))
-
- popup.open()
+ status = _('Status') + ': ' + obj.status
+ self.app.show_pr_details(pr.get_dict(), status, True)
def do_delete(self, obj):
from dialogs.question import Question
@@ -472,7 +461,8 @@ class RequestsScreen(CScreen):
def update(self):
- self.menu_actions = [('View/Edit', self.do_show), ('Delete', self.do_delete)]
+ self.menu_actions = [('Show', self.do_show), ('Details', self.do_view), ('Delete', self.do_delete)]
+
requests_list = self.screen.ids.requests_container
requests_list.clear_widgets()
_list = self.app.wallet.get_sorted_requests(self.app.electrum_config)
@@ -507,6 +497,20 @@ class RequestsScreen(CScreen):
def do_show(self, obj):
self.app.show_request(obj.address)
+ def do_view(self, obj):
+ req = self.app.wallet.get_payment_request(obj.address, self.app.electrum_config)
+ status = req.get('status')
+ amount = req.get('amount')
+ address = req['address']
+ if amount:
+ status = req.get('status')
+ status = _('Status') + ': ' + request_text[status]
+ else:
+ received = self.app.wallet.get_addr_received(address)
+ status = _('Amount received') + ': ' + self.app.format_amount_and_units(amount)
+
+ self.app.show_pr_details(req, status, False)
+
def do_delete(self, obj):
from dialogs.question import Question
def cb():
diff --git a/gui/kivy/uix/ui_screens/invoice.kv b/gui/kivy/uix/ui_screens/invoice.kv
@@ -3,10 +3,15 @@
Popup:
id: popup
title: _('Invoice')
- AnchorLayout:
- anchor_x: 'center'
- BoxLayout:
- orientation: 'vertical'
+ BoxLayout:
+ orientation: 'vertical'
+ spacing: '1dp'
+ Widget:
+ size_hint: 1, 0.1
+
+ GridLayout:
+ cols:1
+ size_hint: 1, 1
Label:
id: requestor_label
text_size: self.width, None
@@ -16,32 +21,33 @@ Popup:
text_size: self.width, None
size_hint: 1, 0.3
Label:
- id: expiration_label
+ id: signature_label
text_size: self.width, None
size_hint: 1, 0.3
Label:
- id: memo_label
+ id: expiration_label
text_size: self.width, None
size_hint: 1, 0.3
Label:
- id: signature_label
+ id: memo_label
text_size: self.width, None
size_hint: 1, 0.3
Label:
id: txid_label
text_size: self.width, None
size: self.texture_size
- Widget:
- size_hint: 1, 0.3
- BoxLayout:
- size_hint: 1, None
+ Widget:
+ size_hint: 1, 0.5
+
+ BoxLayout:
+ size_hint: 1, None
+ height: '48dp'
+ Widget:
+ size_hint: 0.5, None
+ height: '48dp'
+ Button:
+ size_hint: 0.5, None
height: '48dp'
- Widget:
- size_hint: 0.5, None
- height: '48dp'
- Button:
- size_hint: 0.5, None
- height: '48dp'
- text: _('OK')
- on_release: popup.dismiss()
+ text: _('Close')
+ on_release: popup.dismiss()
diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py
@@ -200,6 +200,16 @@ class PaymentRequest:
def get_memo(self):
return self.memo
+ def get_dict(self):
+ return {
+ 'requestor': self.get_requestor(),
+ 'memo':self.get_memo(),
+ 'exp': self.get_expiration_date(),
+ 'amount': self.get_amount(),
+ 'signature': self.get_verify_status(),
+ 'txid': self.tx
+ }
+
def get_id(self):
return self.id if self.requestor else self.get_address()