Browse Source

kivy: fixes

283
ThomasV 9 years ago
parent
commit
a190d1dbe6
  1. 6
      gui/kivy/main_window.py
  2. 35
      gui/kivy/uix/screens.py
  3. 68
      gui/kivy/uix/ui_screens/history.kv
  4. 2
      gui/kivy/uix/ui_screens/invoices.kv
  5. 9
      gui/kivy/uix/ui_screens/receive.kv
  6. 2
      gui/kivy/uix/ui_screens/requests.kv

6
gui/kivy/main_window.py

@ -240,7 +240,6 @@ class ElectrumWindow(App):
self.update_screen('receive') self.update_screen('receive')
receive_tab = self.tabs.ids.receive_tab receive_tab = self.tabs.ids.receive_tab
self.tabs.ids.panel.switch_to(receive_tab) self.tabs.ids.panel.switch_to(receive_tab)
req = self.wallet.receive_requests.get(addr)
def scan_qr(self, on_complete): def scan_qr(self, on_complete):
from jnius import autoclass from jnius import autoclass
@ -715,11 +714,14 @@ class ElectrumWindow(App):
pos = (win.center[0], win.center[1] - (info_bubble.height/2)) pos = (win.center[0], win.center[1] - (info_bubble.height/2))
info_bubble.show(pos, duration, width, modal=modal, exit=exit) info_bubble.show(pos, duration, width, modal=modal, exit=exit)
def tx_dialog(self, obj): def tx_details_dialog(self, obj):
popup = Builder.load_file('gui/kivy/uix/ui_screens/transaction.kv') popup = Builder.load_file('gui/kivy/uix/ui_screens/transaction.kv')
popup.tx_hash = obj.tx_hash popup.tx_hash = obj.tx_hash
popup.open() popup.open()
def tx_label_dialog(self, obj):
pass
def address_dialog(self, screen): def address_dialog(self, screen):
pass pass

35
gui/kivy/uix/screens.py

@ -95,7 +95,7 @@ class HistoryScreen(CScreen):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.ra_dialog = None self.ra_dialog = None
super(HistoryScreen, self).__init__(**kwargs) super(HistoryScreen, self).__init__(**kwargs)
self.menu_actions = [(_('Details'), self.app.tx_dialog)] self.menu_actions = [ (_('Label'), self.app.tx_label_dialog), (_('Details'), self.app.tx_details_dialog)]
def get_history_rate(self, btc_balance, timestamp): def get_history_rate(self, btc_balance, timestamp):
date = timestamp_to_datetime(timestamp) date = timestamp_to_datetime(timestamp)
@ -288,8 +288,8 @@ class ReceiveScreen(CScreen):
self.screen.address = addr self.screen.address = addr
req = self.app.wallet.receive_requests.get(addr) req = self.app.wallet.receive_requests.get(addr)
if req: if req:
self.screen.message = req.get('memo')
self.screen.amount = self.app.format_amount_and_units(req.get('amount')) self.screen.amount = self.app.format_amount_and_units(req.get('amount'))
self.screen.message = unicode(req.get('memo', ''))
def amount_callback(self, popup): def amount_callback(self, popup):
amount_label = self.screen.ids.get('amount') amount_label = self.screen.ids.get('amount')
@ -318,24 +318,27 @@ class ReceiveScreen(CScreen):
def do_save(self): def do_save(self):
addr = str(self.screen.address) addr = str(self.screen.address)
amount = str(self.screen.amount) amount = str(self.screen.amount)
message = unicode(self.screen.message) message = str(self.screen.message) #.ids.message_input.text)
if not message and not amount: if not message and not amount:
self.app.show_error(_('No message or amount')) self.app.show_error(_('No message or amount'))
return False return
amount = self.app.get_amount(amount) if amount:
amount = self.app.get_amount(amount)
else:
amount = 0
print "saving", amount, message
req = self.app.wallet.make_payment_request(addr, amount, message, None) req = self.app.wallet.make_payment_request(addr, amount, message, None)
self.app.wallet.add_payment_request(req, self.app.electrum_config) self.app.wallet.add_payment_request(req, self.app.electrum_config)
self.app.show_error(_('Request saved')) self.app.show_error(_('Request saved'))
self.app.update_screen('requests') self.app.update_screen('requests')
def do_clear(self): def do_new(self):
self.app.receive_address = None self.app.receive_address = None
self.screen.amount = '' self.screen.amount = ''
self.screen.message = '' self.screen.message = ''
self.update() self.update()
class ContactsScreen(CScreen): class ContactsScreen(CScreen):
kvname = 'contacts' kvname = 'contacts'
@ -380,12 +383,11 @@ class InvoicesScreen(CScreen):
ci.amount = self.app.format_amount_and_units(pr.get_amount()) ci.amount = self.app.format_amount_and_units(pr.get_amount())
status = self.app.invoices.get_status(ci.key) status = self.app.invoices.get_status(ci.key)
if status == PR_PAID: if status == PR_PAID:
icon = "atlas://gui/kivy/theming/light/confirmed" ci.icon = "atlas://gui/kivy/theming/light/confirmed"
elif status == PR_EXPIRED: elif status == PR_EXPIRED:
icon = "atlas://gui/kivy/theming/light/important" ci.icon = "atlas://gui/kivy/theming/light/important"
else: else:
icon = "atlas://gui/kivy/theming/light/important" ci.icon = "atlas://gui/kivy/theming/light/important"
exp = pr.get_expiration_date() exp = pr.get_expiration_date()
ci.date = format_time(exp) if exp else _('Never') ci.date = format_time(exp) if exp else _('Never')
ci.screen = self ci.screen = self
@ -416,15 +418,16 @@ class RequestsScreen(CScreen):
signature = req.get('sig') signature = req.get('sig')
ci = Factory.RequestItem() ci = Factory.RequestItem()
ci.address = req['address'] ci.address = req['address']
ci.memo = req.get('memo', '') label, is_default = self.app.wallet.get_label(address)
if label:
ci.memo = label
status = req.get('status') status = req.get('status')
if status == PR_PAID: if status == PR_PAID:
icon = "atlas://gui/kivy/theming/light/confirmed" ci.icon = "atlas://gui/kivy/theming/light/confirmed"
elif status == PR_EXPIRED: elif status == PR_EXPIRED:
icon = "atlas://gui/kivy/theming/light/important" ci.icon = "atlas://gui/kivy/theming/light/important"
else: else:
icon = "atlas://gui/kivy/theming/light/important" ci.icon = "atlas://gui/kivy/theming/light/important"
ci.amount = self.app.format_amount_and_units(amount) if amount else '' ci.amount = self.app.format_amount_and_units(amount) if amount else ''
ci.date = format_time(timestamp) ci.date = format_time(timestamp)
ci.screen = self ci.screen = self

68
gui/kivy/uix/ui_screens/history.kv

@ -23,46 +23,40 @@
amount: app.format_amount(self.value, True) if self.value is not None else '--' amount: app.format_amount(self.value, True) if self.value is not None else '--'
amount_color: '#FF6657' if self.value < 0 else '#2EA442' amount_color: '#FF6657' if self.value < 0 else '#2EA442'
confirmations: 0 confirmations: 0
date: '0/0/0' date: ''
quote_text: '.' quote_text: ''
spacing: '9dp' spacing: '9dp'
cols: 1 Image:
id: icon
source: root.icon
size_hint: None, 1
width: self.height *.54
mipmap: True
BoxLayout: BoxLayout:
size_hint: 1, None orientation: 'vertical'
spacing: '8dp' Widget
height: '32dp'
Image:
id: icon
source: root.icon
size_hint: None, 1
width: self.height *.54
mipmap: True
BoxLayout:
orientation: 'vertical'
Widget
CardLabel:
color: .699, .699, .699, 1
text: root.date
font_size: '14sp'
CardLabel:
shorten: True
text: root.message
markup: False
text_size: self.size
Widget
CardLabel: CardLabel:
halign: 'right' text: root.date
font_size: '15sp' font_size: '14sp'
size_hint: None, 1 CardLabel:
width: '110sp' color: .699, .699, .699, 1
markup: True font_size: '13sp'
font_name: font_light shorten: True
text: text: root.message if root.message else ' '
u'[color={amount_color}]{sign}{amount} {unit}[/color]\n'\ Widget
u'[color=#B2B3B3][size=13sp]{qt}[/size]'\ CardLabel:
u'[/color]'.format(amount_color=root.amount_color,\ halign: 'right'
amount=root.amount[1:], qt=root.quote_text, sign=root.amount[0],\ font_size: '15sp'
unit=app.base_unit) size_hint: None, 1
width: '110sp'
markup: True
font_name: font_light
text:
u'[color={amount_color}]{sign}{amount} {unit}[/color]\n'\
u'[color=#B2B3B3][size=13sp]{qt}[/size]'\
u'[/color]'.format(amount_color=root.amount_color,\
amount=root.amount[1:], qt=root.quote_text, sign=root.amount[0],\
unit=app.base_unit)
HistoryScreen: HistoryScreen:

2
gui/kivy/uix/ui_screens/invoices.kv

@ -35,7 +35,7 @@
halign: 'right' halign: 'right'
font_size: '15sp' font_size: '15sp'
size_hint: None, 1 size_hint: None, 1
width: '80sp' width: '110sp'
text: root.amount text: root.amount
InvoicesScreen: InvoicesScreen:

9
gui/kivy/uix/ui_screens/receive.kv

@ -79,7 +79,6 @@ ReceiveScreen:
hint_text: 'Description' hint_text: 'Description'
text: s.message text: s.message
on_text_validate: s.message = self.text on_text_validate: s.message = self.text
BoxLayout: BoxLayout:
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
@ -89,14 +88,14 @@ ReceiveScreen:
height: '48dp' height: '48dp'
on_release: s.parent.do_copy() on_release: s.parent.do_copy()
Button: Button:
text: _('New') text: _('Save')
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
on_release: s.parent.do_clear() on_release: s.parent.do_save()
Button: Button:
text: _('Save') text: _('New')
size_hint: 1, None size_hint: 1, None
height: '48dp' height: '48dp'
on_release: s.parent.do_save() on_release: s.parent.do_new()
Widget: Widget:
size_hint: 1, 0.3 size_hint: 1, 0.3

2
gui/kivy/uix/ui_screens/requests.kv

@ -35,7 +35,7 @@
halign: 'right' halign: 'right'
font_size: '15sp' font_size: '15sp'
size_hint: None, 1 size_hint: None, 1
width: '80sp' width: '110sp'
text: root.amount text: root.amount

Loading…
Cancel
Save