kivy: allow manual server entry
This commit is contained in:
parent
51f8816ec7
commit
38d6c18b60
|
@ -53,9 +53,11 @@ class ChoiceDialog(Factory.Popup):
|
||||||
for k, v in sorted(choices.items()):
|
for k, v in sorted(choices.items()):
|
||||||
l = Label(text=v)
|
l = Label(text=v)
|
||||||
l.height = '48dp'
|
l.height = '48dp'
|
||||||
|
l.size_hint_x = 4
|
||||||
cb = CheckBox(group='choices')
|
cb = CheckBox(group='choices')
|
||||||
cb.value = k
|
cb.value = k
|
||||||
cb.height = '48dp'
|
cb.height = '48dp'
|
||||||
|
cb.size_hint_x = 1
|
||||||
def f(cb, x):
|
def f(cb, x):
|
||||||
if x: self.value = cb.value
|
if x: self.value = cb.value
|
||||||
cb.bind(active=f)
|
cb.bind(active=f)
|
||||||
|
|
|
@ -92,8 +92,8 @@ Builder.load_string('''
|
||||||
CardSeparator
|
CardSeparator
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: root.network_status()
|
status: root.network_status()
|
||||||
title: _('Network') + ': ' + self.status
|
title: _('Server') + ': ' + self.status
|
||||||
description: _("Network status and server selection.")
|
description: _("Select your history server.")
|
||||||
action: partial(root.network_dialog, self)
|
action: partial(root.network_dialog, self)
|
||||||
CardSeparator
|
CardSeparator
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
|
@ -236,18 +236,31 @@ class SettingsDialog(Factory.Popup):
|
||||||
self._proxy_dialog.open()
|
self._proxy_dialog.open()
|
||||||
|
|
||||||
def network_dialog(self, item, dt):
|
def network_dialog(self, item, dt):
|
||||||
|
host, port, protocol, proxy, auto_connect = self.app.network.get_parameters()
|
||||||
|
servers = self.app.network.get_servers()
|
||||||
if self._network_dialog is None:
|
if self._network_dialog is None:
|
||||||
server, port, protocol, proxy, auto_connect = self.app.network.get_parameters()
|
def cb1(popup):
|
||||||
def cb(popup):
|
host = str(popup.ids.host.text)
|
||||||
server = popup.ids.host.text
|
port = str(popup.ids.port.text)
|
||||||
auto_connect = popup.ids.auto_connect.active
|
auto_connect = popup.ids.auto_connect.active
|
||||||
self.app.network.set_parameters(server, port, protocol, proxy, auto_connect)
|
self.app.network.set_parameters(host, port, protocol, proxy, auto_connect)
|
||||||
item.status = self.network_status()
|
item.status = self.network_status()
|
||||||
|
def cb2(host):
|
||||||
|
from electrum.network import DEFAULT_PORTS
|
||||||
|
pp = servers.get(host, DEFAULT_PORTS)
|
||||||
|
port = pp.get(protocol, '')
|
||||||
|
popup.ids.host.text = host
|
||||||
|
popup.ids.port.text = port
|
||||||
|
def cb3():
|
||||||
|
ChoiceDialog(_('Choose a server'), sorted(servers), popup.ids.host.text, cb2).open()
|
||||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/network.kv')
|
popup = Builder.load_file('gui/kivy/uix/ui_screens/network.kv')
|
||||||
popup.ids.host.text = server
|
popup.ids.chooser.on_release = cb3
|
||||||
popup.ids.auto_connect.active = auto_connect
|
popup.on_dismiss = lambda: cb1(popup)
|
||||||
popup.on_dismiss = lambda: cb(popup)
|
|
||||||
self._network_dialog = popup
|
self._network_dialog = popup
|
||||||
|
|
||||||
|
self._network_dialog.ids.auto_connect.active = auto_connect
|
||||||
|
self._network_dialog.ids.host.text = host
|
||||||
|
self._network_dialog.ids.port.text = port
|
||||||
self._network_dialog.open()
|
self._network_dialog.open()
|
||||||
|
|
||||||
def network_status(self):
|
def network_status(self):
|
||||||
|
|
|
@ -1,33 +1,57 @@
|
||||||
Popup:
|
Popup:
|
||||||
id: nd
|
id: nd
|
||||||
title: _('Network')
|
title: _('Server')
|
||||||
is_connected: app.network.is_connected()
|
is_connected: app.network.is_connected()
|
||||||
server: app.network.interface.host
|
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
padding: '10dp'
|
padding: '10dp'
|
||||||
spacing: '10dp'
|
spacing: '10dp'
|
||||||
TopLabel:
|
TopLabel:
|
||||||
text: _("Connected to %s.")%root.server if root.is_connected else _("Not connected?")
|
text: _("Electrum retrieves your transaction history from a single server. The history is then checked against blockchain headers sent by other nodes, using Simple Payment Verification (SPV).")
|
||||||
|
font_size: '6pt'
|
||||||
|
Widget:
|
||||||
|
size_hint: 1, 0.8
|
||||||
|
GridLayout:
|
||||||
|
cols: 3
|
||||||
|
Label:
|
||||||
|
height: '36dp'
|
||||||
|
size_hint_x: 1
|
||||||
|
size_hint_y: None
|
||||||
|
text: _('Host') + ':'
|
||||||
|
TextInput:
|
||||||
|
id: host
|
||||||
|
height: '36dp'
|
||||||
|
size_hint_x: 3
|
||||||
|
size_hint_y: None
|
||||||
|
text: ''
|
||||||
|
disabled: auto_connect.active
|
||||||
|
Button:
|
||||||
|
id: chooser
|
||||||
|
text:'v'
|
||||||
|
height: '36dp'
|
||||||
|
size_hint_x: 0.5
|
||||||
|
size_hint_y: None
|
||||||
|
disabled: auto_connect.active
|
||||||
|
Label:
|
||||||
|
height: '36dp'
|
||||||
|
size_hint_x: 1
|
||||||
|
size_hint_y: None
|
||||||
|
text: _('Port') + ':'
|
||||||
|
TextInput:
|
||||||
|
id: port
|
||||||
|
input_type: 'number'
|
||||||
|
height: '36dp'
|
||||||
|
size_hint_x: 3
|
||||||
|
size_hint_y: None
|
||||||
|
text: ''
|
||||||
|
disabled: auto_connect.active
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
TopLabel:
|
TopLabel:
|
||||||
text: _("Electrum retrieves your wallet information from a single server. In addition, it connects to a number of extra nodes, in order to fetch block headers. Block headers are used to verify the information sent by the address server, using Simple Payment Verification (SPV).")
|
text: _("If auto-connect is checked, your history server will be selected automatically.")
|
||||||
font_size: '6pt'
|
font_size: '6pt'
|
||||||
Widget:
|
BoxLayout:
|
||||||
size_hint: 1, 0.1
|
|
||||||
GridLayout:
|
|
||||||
cols: 2
|
|
||||||
Label:
|
|
||||||
text: _('Server')
|
|
||||||
Spinner:
|
|
||||||
id: host
|
|
||||||
height: '48dp'
|
|
||||||
size_hint_y: None
|
|
||||||
text: ''
|
|
||||||
values: sorted(app.network.get_servers())
|
|
||||||
disabled: auto_connect.active
|
|
||||||
Label:
|
Label:
|
||||||
text: _('Auto-connect')
|
text: _('Auto-connect')
|
||||||
CheckBox:
|
CheckBox:
|
||||||
|
@ -35,12 +59,6 @@ Popup:
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
TopLabel:
|
|
||||||
text: _("If auto-connect is checked, the address server will be selected automatically.")
|
|
||||||
font_size: '6pt'
|
|
||||||
Widget:
|
|
||||||
size_hint: 1, 0.1
|
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
|
|
Loading…
Reference in New Issue