electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1b0e29d385ccd62dbb55a47e768a32e5f0125358
parent 8e7c5a180fd9ad80a2d9af7bd79e7442f24a7d1f
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 10 Dec 2015 11:33:58 +0100

kivy: add screens for invoices and requests, disable contacts

Diffstat:
Mgui/kivy/main.kv | 24+++++++++++++++++++-----
Mgui/kivy/main_window.py | 2++
Mgui/kivy/uix/screens.py | 42+++++++++++++++++++++++++++++++++++++++++-
Agui/kivy/uix/ui_screens/invoices.kv | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Agui/kivy/uix/ui_screens/requests.kv | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 165 insertions(+), 6 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -292,9 +292,15 @@ ReceiveScreen: id: receive_screen tab: receive_tab - ContactsScreen: - id: contacts_screen - tab: contacts_tab + InvoicesScreen: + id: invoices_screen + tab: invoices_tab + RequestsScreen: + id: requests_screen + tab: requests_tab + #ContactsScreen: + # id: contacts_screen + # tab: contacts_tab CleanHeader: id: history_tab text: _('History') @@ -308,9 +314,17 @@ text: _('Receive') slide: 2 CleanHeader: - id: contacts_tab - text: _('Contacts') + id: invoices_tab + text: _('Invoices') slide: 3 + CleanHeader: + id: requests_tab + text: _('Requests') + slide: 4 + #CleanHeader: + # id: contacts_tab + # text: _('Contacts') + # slide: 4 <ActionOvrButton@ActionButton> on_release: diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -9,6 +9,7 @@ import electrum from electrum import WalletStorage, Wallet from electrum.i18n import _, set_language from electrum.contacts import Contacts +from electrum.paymentrequest import InvoiceStore from electrum.util import profiler, InvalidPassword from electrum.plugins import run_hook from electrum.util import format_satoshis, format_satoshis_plain @@ -176,6 +177,7 @@ class ElectrumWindow(App): #self.config = self.gui_object.config self.contacts = Contacts(self.electrum_config) + self.invoices = InvoiceStore(self.electrum_config) self.bind(url=self.set_URI) # were we sent a url? diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -17,7 +17,7 @@ from kivy.lang import Builder from kivy.factory import Factory from electrum.i18n import _ -from electrum.util import profiler, parse_URI +from electrum.util import profiler, parse_URI, format_time from electrum import bitcoin from electrum.util import timestamp_to_datetime from electrum.plugins import run_hook @@ -311,6 +311,46 @@ class ContactsScreen(CScreen): contact_list.add_widget(ci) +class InvoicesScreen(CScreen): + kvname = 'invoices' + + def update(self): + invoices_list = self.screen.ids.invoices_container + invoices_list.clear_widgets() + for pr in self.app.invoices.sorted_list(): + ci = Factory.InvoiceItem() + ci.key = pr.get_id() + ci.requestor = pr.get_requestor() + ci.memo = pr.memo + ci.amount = self.app.format_amount(pr.get_amount()) + #ci.status = self.invoices.get_status(key) + exp = pr.get_expiration_date() + ci.date = format_time(exp) if exp else _('Never') + invoices_list.add_widget(ci) + +class RequestsScreen(CScreen): + kvname = 'requests' + + def update(self): + requests_list = self.screen.ids.requests_container + requests_list.clear_widgets() + for req in self.app.wallet.get_sorted_requests(self.app.electrum_config): + address = req['address'] + timestamp = req.get('time', 0) + amount = req.get('amount') + expiration = req.get('exp', None) + status = req.get('status') + signature = req.get('sig') + + ci = Factory.RequestItem() + ci.address = req['address'] + ci.memo = req.get('memo', '') + #ci.status = req.get('status') + ci.amount = self.app.format_amount(amount) if amount else '' + ci.date = format_time(timestamp) + requests_list.add_widget(ci) + + class CSpinner(Factory.Spinner): '''CustomDropDown that allows fading out the dropdown diff --git a/gui/kivy/uix/ui_screens/invoices.kv b/gui/kivy/uix/ui_screens/invoices.kv @@ -0,0 +1,50 @@ +<InvoicesLabel@Label> + #color: .305, .309, .309, 1 + text_size: self.size + halign: 'left' + valign: 'middle' + +<InvoiceItem@BoxLayout> + requestor: '' + memo: '' + amount: '' + status: '' + date: '' + size_hint_y: None + height: '65dp' + padding: dp(12) + spacing: dp(5) + canvas.before: + Color: + rgba: 0.3, 0.3, 0.3, 1 + Rectangle: + size: self.size + pos: self.pos + InvoicesLabel: + text: root.requestor + InvoicesLabel: + text: root.memo + InvoicesLabel: + text: root.amount + +InvoicesScreen: + name: 'invoices' + on_activate: + if not self.action_view:\ + self.action_view = app.root.main_screen.ids.tabs.ids.screen_dashboard.action_view + BoxLayout: + orientation: 'vertical' + spacing: '1dp' + ScrollView: + canvas.before: + Color: + rgba: .8901, .8901, .8901, 0 + Rectangle: + size: self.size + pos: self.pos + GridLayout: + cols: 1 + id: invoices_container + size_hint_y: None + height: self.minimum_height + spacing: '1dp' diff --git a/gui/kivy/uix/ui_screens/requests.kv b/gui/kivy/uix/ui_screens/requests.kv @@ -0,0 +1,53 @@ +<InvoicesLabel@Label> + #color: .305, .309, .309, 1 + text_size: self.size + halign: 'left' + valign: 'middle' + +<RequestItem@BoxLayout> + address: '' + memo: '' + amount: '' + status: '' + date: '' + size_hint_y: None + height: '65dp' + padding: dp(12) + spacing: dp(5) + canvas.before: + Color: + rgba: 0.3, 0.3, 0.3, 1 + Rectangle: + size: self.size + pos: self.pos + InvoicesLabel: + text: root.address + font_size: '13dp' + InvoicesLabel: + text: root.memo + InvoicesLabel: + text: root.amount + #InvoicesLabel: + # text: root.status + +RequestsScreen: + name: 'requests' + on_activate: + if not self.action_view:\ + self.action_view = app.root.main_screen.ids.tabs.ids.screen_dashboard.action_view + BoxLayout: + orientation: 'vertical' + spacing: '1dp' + ScrollView: + canvas.before: + Color: + rgba: .8901, .8901, .8901, 0 + Rectangle: + size: self.size + pos: self.pos + GridLayout: + cols: 1 + id: requests_container + size_hint_y: None + height: self.minimum_height + spacing: '1dp'