commit ee4ccd9b1be300f4e4a0801effeec2cb4a75df04
parent e46b00bb39a8f3b324a72d6fc4f7015a9cff4402
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 18 Dec 2015 15:03:38 +0100
kivy: move wallets dialog
Diffstat:
5 files changed, 91 insertions(+), 61 deletions(-)
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -332,10 +332,6 @@ class ElectrumWindow(App):
d = LabelDialog(_('Enter wallet name'), '', f)
d.open()
- def settings_dialog(self):
- from uix.dialogs.settings import SettingsDialog
- d = SettingsDialog(self)
- d.open()
def on_stop(self):
self.stop_wallet()
@@ -395,7 +391,13 @@ class ElectrumWindow(App):
def popup_dialog(self, name):
if name == 'settings':
- self.settings_dialog()
+ from uix.dialogs.settings import SettingsDialog
+ d = SettingsDialog(self)
+ d.open()
+ elif name == 'wallets':
+ from uix.dialogs.wallets import WalletDialog
+ d = WalletDialog()
+ d.open()
else:
popup = Builder.load_file('gui/kivy/uix/ui_screens/'+name+'.kv')
popup.open()
diff --git a/gui/kivy/uix/dialogs/wallets.py b/gui/kivy/uix/dialogs/wallets.py
@@ -0,0 +1,76 @@
+from kivy.app import App
+from kivy.factory import Factory
+from kivy.properties import ObjectProperty
+from kivy.lang import Builder
+
+from electrum.i18n import _
+from electrum.util import base_units
+
+import os
+from label_dialog import LabelDialog
+
+Builder.load_string('''
+#:import os os
+<WalletDialog@Popup>:
+ title: _('Wallets')
+ id: popup
+ path: app.wallet.storage.path
+ on_path:
+ button.text = _('Open') if os.path.exists(popup.path) else _('Create')
+ BoxLayout:
+ orientation: 'vertical'
+ BoxLayout:
+ height: '48dp'
+ size_hint_y: None
+ orientation: 'horizontal'
+ Label:
+ text: _('Wallet') + ': '
+ height: '48dp'
+ size_hint_y: None
+ Button:
+ id: wallet_name
+ height: '48dp'
+ size_hint_y: None
+ text: os.path.basename(app.wallet.storage.path)
+ on_release:
+ root.name_dialog()
+ on_text:
+ popup.path = os.path.join(wallet_selector.path, self.text)
+ Widget
+ size_hint_y: None
+ FileChooserListView:
+ id: wallet_selector
+ path: os.path.dirname(app.wallet.storage.path)
+ on_selection:
+ wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
+ size_hint_y: 0.5
+ Widget
+ size_hint_y: 0.1
+
+ GridLayout:
+ cols: 2
+ size_hint_y: None
+ Button:
+ size_hint: 0.5, None
+ height: '48dp'
+ text: _('Cancel')
+ on_release:
+ popup.dismiss()
+ Button:
+ id: button
+ size_hint: 0.5, None
+ height: '48dp'
+ text: _('Open') if os.path.exists(popup.path) else _('Create')
+ on_release:
+ popup.dismiss()
+ app.load_wallet_by_name(popup.path)
+''')
+
+class WalletDialog(Factory.Popup):
+ def name_dialog(self):
+ def cb(text):
+ if text:
+ self.ids.wallet_name.text = text
+ d = LabelDialog(_('Enter wallet name'), '', cb)
+ d.open()
+
diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
@@ -337,7 +337,7 @@ class ReceiveScreen(CScreen):
req = self.app.wallet.make_payment_request(addr, amount, message, None)
self.app.wallet.add_payment_request(req, self.app.electrum_config)
self.app.show_error(_('Request saved'))
- self.app.update_screen('requests')
+ self.app.update_tab('requests')
def do_new(self):
self.app.receive_address = None
@@ -405,7 +405,7 @@ class InvoicesScreen(CScreen):
def do_delete(self, obj):
self.app.invoices.remove(obj.key)
- self.app.update_screen('invoices')
+ self.app.update_tab('invoices')
class RequestsScreen(CScreen):
kvname = 'requests'
diff --git a/gui/kivy/uix/ui_screens/status.kv b/gui/kivy/uix/ui_screens/status.kv
@@ -1,3 +1,5 @@
+#:import os os
+
Popup:
title: "Balance"
confirmed: 0
@@ -11,6 +13,10 @@ Popup:
GridLayout:
cols:2
Label:
+ text: _("Wallet:")
+ Label:
+ text: os.path.basename(app.wallet.storage.path)
+ Label:
text: _("Confirmed:")
Label:
text: app.format_amount_and_units(root.confirmed)
diff --git a/gui/kivy/uix/ui_screens/wallets.kv b/gui/kivy/uix/ui_screens/wallets.kv
@@ -1,54 +0,0 @@
-#:import os os
-
-Popup:
- title: _('Wallets')
- id: popup
- path: app.wallet.storage.path
- on_path:
- button.text = _('Open') if os.path.exists(popup.path) else _('Create')
- BoxLayout:
- orientation: 'vertical'
- BoxLayout:
- height: '48dp'
- size_hint_y: None
- orientation: 'horizontal'
- Label:
- text: _('Wallet') + ': '
- height: '48dp'
- size_hint_y: None
- Button:
- id: wallet_name
- height: '48dp'
- size_hint_y: None
- text: os.path.basename(app.wallet.storage.path)
- on_release:
- app.create_wallet_dialog(self)
- on_text:
- popup.path = os.path.join(wallet_selector.path, self.text)
- Widget
- size_hint_y: None
- FileChooserListView:
- id: wallet_selector
- path: os.path.dirname(app.wallet.storage.path)
- on_selection:
- wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
- size_hint_y: 0.5
- Widget
- size_hint_y: 0.1
- GridLayout:
- cols: 2
- size_hint_y: None
- Button:
- size_hint: 0.5, None
- height: '48dp'
- text: _('Cancel')
- on_release:
- popup.dismiss()
- Button:
- id: button
- size_hint: 0.5, None
- height: '48dp'
- text: _('Open') if os.path.exists(popup.path) else _('Create')
- on_release:
- popup.dismiss()
- app.load_wallet_by_name(popup.path)