kivy: Move network dialog to settings. Add coin chooser to settings

This commit is contained in:
ThomasV 2016-02-22 10:50:27 +01:00
parent cb8d504c42
commit 75db90ffa5
3 changed files with 55 additions and 26 deletions

View File

@ -378,19 +378,16 @@ BoxLayout:
ActionOvrButton:
name: 'about'
text: _('About')
ActionOvrButton:
name: 'network'
text: _('Network')
on_parent:
# when widget overflow drop down is shown, adjust the width
parent = args[1]
if parent: ao._dropdown.width = sp(200)
ActionOvrButton:
name: 'wallets'
text: _('Wallets')
ActionOvrButton:
name: 'settings'
text: _('Settings')
on_parent:
# when widget overflow drop down is shown, adjust the width
parent = args[1]
if parent: ao._dropdown.width = sp(200)
ScreenManager:
id: manager
ScreenTabs:

View File

@ -9,6 +9,8 @@ from electrum_gui.kivy.i18n import _
from electrum.plugins import run_hook
from electrum.bitcoin import RECOMMENDED_FEE
from choice_dialog import ChoiceDialog
Builder.load_string('''
#:import partial functools.partial
#:import _ electrum_gui.kivy.i18n._
@ -82,15 +84,21 @@ Builder.load_string('''
title: _('Fiat Currency') + ': ' + self.status
description: _("Display amounts in fiat currency.")
action: partial(root.fx_dialog, self)
SettingsItem:
status: root.network_status()
title: _('Network') + ': ' + self.status
description: _("Network status and server selection.")
action: partial(root.network_dialog, self)
SettingsItem:
status: 'ON' if bool(app.plugins.get('labels')) else 'OFF'
title: _('Labels Sync') + ': ' + self.status
description: "Synchronize labels."
action: partial(root.plugin_dialog, 'labels', self)
#SettingsItem:
# title: _('OpenAlias')
# description: "DNS record that stores one of your Bitcoin addresses."
# action: partial(root.openalias_dialog, self)
SettingsItem:
status: root.coinselect_status()
title: _('Coin selection') + ': ' + self.status
description: "Coin selection method"
action: partial(root.coinselect_dialog, self)
BoxLayout:
size_hint: 1, 0.1
Widget:
@ -120,7 +128,6 @@ class SettingsDialog(Factory.Popup):
self.app.change_password()
def language_dialog(self, item, dt):
from choice_dialog import ChoiceDialog
l = self.config.get('language', 'en_UK')
def cb(key):
self.config.set_key("language", key, True)
@ -130,13 +137,25 @@ class SettingsDialog(Factory.Popup):
d.open()
def unit_dialog(self, item, dt):
from choice_dialog import ChoiceDialog
def cb(text):
self.app._set_bu(text)
item.bu = self.app.base_unit
d = ChoiceDialog(_('Denomination'), base_units.keys(), self.app.base_unit, cb)
d.open()
def coinselect_status(self):
return self.app.wallet.coin_chooser_name(self.app.electrum_config)
def coinselect_dialog(self, item, dt):
from electrum import COIN_CHOOSERS
choosers = sorted(COIN_CHOOSERS.keys())
chooser_name = self.app.wallet.coin_chooser_name(self.config)
def cb(text):
self.config.set_key('coin_chooser', text)
item.status = text
d = ChoiceDialog(_('Coin selection'), choosers, chooser_name, cb)
d.open()
def openalias_dialog(self, label, dt):
from label_dialog import LabelDialog
def callback(text):
@ -144,6 +163,14 @@ class SettingsDialog(Factory.Popup):
d = LabelDialog(_('OpenAlias'), '', callback)
d.open()
def network_dialog(self, label, dt):
popup = Builder.load_file('gui/kivy/uix/ui_screens/network.kv')
popup.open()
def network_status(self):
server, port, protocol, proxy, auto_connect = self.app.network.get_parameters()
return 'auto-connect' if auto_connect else server
def plugin_dialog(self, name, label, dt):
from checkbox_dialog import CheckBoxDialog
def callback(status):

View File

@ -1,31 +1,37 @@
Popup:
id: nd
title: _('Network')
n_nodes: len(app.network.get_interfaces())
blockchain_height: app.network.get_local_height()
is_connected: app.network.is_connected()
on_open:
host.text, nd.port, nd.protocol, nd.proxy, auto_connect.active = app.network.get_parameters()
BoxLayout:
orientation: 'vertical'
TopLabel:
s1: _("Connected to %d nodes.")%root.n_nodes if root.n_nodes else _("Not connected?")
s2: _("Blockchain length") + ": %d "%root.blockchain_height + _("blocks")
text: self.s1 + '\n' + self.s2
Widget:
size_hint: 1, 0.1
GridLayout:
cols: 2
Label:
text: _('Address server')
Spinner:
id: host
height: '48dp'
text: ''
values: sorted(app.network.get_servers())
disabled: auto_connect.active
Label:
text: _('Auto-connect')
CheckBox:
id: auto_connect
size_hint_y: None
Label:
text: _('Server')
Spinner:
id: host
text: ''
values: sorted(app.network.get_servers())
disabled: auto_connect.active
Widget:
size_hint: 1, 1
size_hint: 1, 0.1
BoxLayout:
Widget:
size_hint: 0.5, None
@ -36,4 +42,3 @@ Popup:
on_release:
app.network.set_parameters(host.text, nd.port, nd.protocol, nd.proxy, auto_connect.active)
nd.dismiss()