Browse Source

kivy: improve layout of invoice and about dialogs

283
ThomasV 9 years ago
parent
commit
f89a90016e
  1. 6
      gui/kivy/main.kv
  2. 23
      gui/kivy/main_window.py
  3. 3
      gui/kivy/uix/dialogs/tx_dialog.py
  4. 7
      gui/kivy/uix/screens.py
  5. 32
      gui/kivy/uix/ui_screens/about.kv
  6. 71
      gui/kivy/uix/ui_screens/invoice.kv

6
gui/kivy/main.kv

@ -26,6 +26,12 @@
# Custom Global Widgets # Custom Global Widgets
<TopLabel@Label>
valign: 'top'
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
<EmptyLabel@Label> <EmptyLabel@Label>
color: (0.8, 0.8, 0.8, 1) color: (0.8, 0.8, 0.8, 1)
size_hint_y: None size_hint_y: None

23
gui/kivy/main_window.py

@ -285,25 +285,18 @@ class ElectrumWindow(App):
memo = req.get('memo') memo = req.get('memo')
amount = req.get('amount') amount = req.get('amount')
popup = Builder.load_file('gui/kivy/uix/ui_screens/invoice.kv') popup = Builder.load_file('gui/kivy/uix/ui_screens/invoice.kv')
if is_invoice: popup.is_invoice = is_invoice
popup.title = _('Invoice') popup.amount = amount
popup.ids.requestor_label.text = _("Requestor") + ': ' + requestor popup.requestor = requestor if is_invoice else req.get('address')
else: popup.exp = format_time(exp) if exp else ''
popup.title = _('Request') popup.description = memo if memo else ''
popup.ids.requestor_label.text = _("Address") + ': ' + req.get('address') popup.signature = req.get('signature', '')
popup.status = status
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') txid = req.get('txid')
if txid: if txid:
popup.ids.txid_label.text += '\n' + _("Transaction ID") + ':\n' + ' '.join(map(''.join, zip(*[iter(txid)]*4))) popup.ids.txid_label.text = _("Transaction ID") + ':\n' + ' '.join(map(''.join, zip(*[iter(txid)]*4)))
popup.open() popup.open()
def qr_dialog(self, title, data): def qr_dialog(self, title, data):
from uix.dialogs.qr_dialog import QRDialog from uix.dialogs.qr_dialog import QRDialog
popup = QRDialog(title, data) popup = QRDialog(title, data)

3
gui/kivy/uix/dialogs/tx_dialog.py

@ -24,8 +24,7 @@ Builder.load_string('''
Label: Label:
id: status_label id: status_label
text: root.status_str text: root.status_str
text_size: self.width, None text_size: self.size
size: self.texture_size
Label: Label:
id: amount_label id: amount_label
text: root.amount_str text: root.amount_str

7
gui/kivy/uix/screens.py

@ -444,8 +444,7 @@ class InvoicesScreen(CScreen):
def do_view(self, obj): def do_view(self, obj):
pr = self.app.invoices.get(obj.key) pr = self.app.invoices.get(obj.key)
pr.verify({}) pr.verify({})
status = _('Status') + ': ' + obj.status self.app.show_pr_details(pr.get_dict(), obj.status, True)
self.app.show_pr_details(pr.get_dict(), status, True)
def do_delete(self, obj): def do_delete(self, obj):
from dialogs.question import Question from dialogs.question import Question
@ -504,10 +503,10 @@ class RequestsScreen(CScreen):
address = req['address'] address = req['address']
if amount: if amount:
status = req.get('status') status = req.get('status')
status = _('Status') + ': ' + request_text[status] status = request_text[status]
else: else:
received = self.app.wallet.get_addr_received(address) received = self.app.wallet.get_addr_received(address)
status = _('Amount received') + ': ' + self.app.format_amount_and_units(amount) status = self.app.format_amount_and_units(amount)
self.app.show_pr_details(req, status, False) self.app.show_pr_details(req, status, False)

32
gui/kivy/uix/ui_screens/about.kv

@ -1,10 +1,5 @@
#:import VERSION electrum.version.ELECTRUM_VERSION #:import VERSION electrum.version.ELECTRUM_VERSION
<TopLabel@Label>
valign: 'top'
font_size: '6pt'
text_size: self.size
Popup: Popup:
title: _("About Electrum") title: _("About Electrum")
BoxLayout: BoxLayout:
@ -13,33 +8,48 @@ Popup:
padding: '10dp' padding: '10dp'
GridLayout: GridLayout:
cols: 2 cols: 2
spacing: '10dp'
TopLabel: TopLabel:
text: _('Version') text: _('Version')
size_hint_x: 0.4
TopLabel: TopLabel:
text: VERSION text: VERSION
size_hint_x: 0.6
TopLabel: TopLabel:
text: _('Licence') text: _('Licence')
size_hint_x: 0.4
TopLabel: TopLabel:
text: "GNU GPL v3" text: "GNU GPL v3"
size_hint_x: 0.6
TopLabel: TopLabel:
text: _('Homepage') text: _('Homepage')
size_hint_x: 0.4
TopLabel: TopLabel:
markup: True markup: True
text: '[color=6666ff][ref=x]https://electrum.org[/ref][/color]' text: '[color=6666ff][ref=x]https://electrum.org[/ref][/color]'
on_ref_press: on_ref_press:
import webbrowser import webbrowser
webbrowser.open("https://electrum.org") webbrowser.open("https://electrum.org")
size_hint_x: 0.6
TopLabel: TopLabel:
text: _('Developers') text: _('Developers')
Label: size_hint_x: 0.4
TopLabel:
text: '\n'.join(['Thomas Voegtlin', 'Neil Booth', 'Akshay Arora']) text: '\n'.join(['Thomas Voegtlin', 'Neil Booth', 'Akshay Arora'])
valign: 'top' size_hint_x: 0.6
font_size: '6pt'
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
TopLabel: TopLabel:
text: _('Distributed by Electrum Technologies GmbH') text: _('Distributed by Electrum Technologies GmbH')
padding: '0dp', '20dp' padding: '0dp', '20dp'
Widget: Widget:
size_hint: None, 0.5 size_hint: None, 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'
text: _('Close')
on_release: root.dismiss()

71
gui/kivy/uix/ui_screens/invoice.kv

@ -1,44 +1,51 @@
#:import Decimal decimal.Decimal #:import Decimal decimal.Decimal
Popup: Popup:
id: popup id: popup
title: _('Invoice') is_invoice: True
amount: 0
requestor: ''
exp: ''
description: ''
status: ''
signature: ''
title: _('Invoice') if popup.is_invoice else _('Request')
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
spacing: '1dp'
Widget:
size_hint: 1, 0.1
GridLayout: GridLayout:
cols:1 spacing: '10dp'
size_hint: 1, 1 cols: 2
Label: TopLabel:
id: requestor_label text: _('Requestor') if popup.is_invoice else _('Address')
text_size: self.width, None TopLabel:
size_hint: 1, 0.3 text: root.requestor
Label: TopLabel:
id: amount_label text: _('Amount') if root.amount else ''
text_size: self.width, None TopLabel:
size_hint: 1, 0.3 text: app.format_amount_and_units(root.amount) if root.amount else ''
Label: TopLabel:
id: signature_label text: _('Signature') if root.signature else ''
text_size: self.width, None TopLabel:
size_hint: 1, 0.3 text: root.signature
Label: TopLabel:
id: expiration_label text: _('Expiration') if root.exp else ''
text_size: self.width, None TopLabel:
size_hint: 1, 0.3 text: root.exp
Label: TopLabel:
id: memo_label text: _('Description') if root.description else ''
text_size: self.width, None TopLabel:
size_hint: 1, 0.3 text: root.description
Label: TopLabel:
id: txid_label text: _('Status') if popup.amount or popup.is_invoice else _('Amount received')
text_size: self.width, None TopLabel:
size: self.texture_size text: root.status
TopLabel:
id: txid_label
Widget: Widget:
size_hint: 1, 0.5 size_hint: 1, 0.1
BoxLayout: BoxLayout:
size_hint: 1, None size_hint: 1, None

Loading…
Cancel
Save