Browse Source

kivy network dialog: update server and proxy properly

Previously "proxy" would only get updated when closing and reopening
the network dialog. "server" would only get updated after successful
connection establishment to specified server.
3.3.3.1
SomberNight 6 years ago
parent
commit
b491a30dd9
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 13
      electrum/gui/kivy/main_window.py
  2. 5
      electrum/gui/kivy/uix/ui_screens/network.kv
  3. 1
      electrum/gui/kivy/uix/ui_screens/proxy.kv
  4. 4
      electrum/gui/kivy/uix/ui_screens/server.kv

13
electrum/gui/kivy/main_window.py

@ -109,6 +109,13 @@ class ElectrumWindow(App):
def toggle_oneserver(self, x):
self.oneserver = not self.oneserver
proxy_str = StringProperty('')
def update_proxy_str(self, proxy: dict):
mode = proxy.get('mode')
host = proxy.get('host')
port = proxy.get('port')
self.proxy_str = (host + ':' + port) if mode else _('None')
def choose_server_dialog(self, popup):
from .uix.dialogs.choice_dialog import ChoiceDialog
protocol = 's'
@ -288,6 +295,7 @@ class ElectrumWindow(App):
self.auto_connect = net_params.auto_connect
self.oneserver = net_params.oneserver
self.proxy_config = net_params.proxy if net_params.proxy else {}
self.update_proxy_str(self.proxy_config)
self.plugins = kwargs.get('plugins', [])
self.gui_object = kwargs.get('gui_object', None)
@ -667,6 +675,7 @@ class ElectrumWindow(App):
self.tabs = self.root.ids['tabs']
def update_interfaces(self, dt):
net_params = self.network.get_parameters()
self.num_nodes = len(self.network.get_interfaces())
self.num_chains = len(self.network.get_blockchains())
chain = self.network.blockchain()
@ -675,6 +684,10 @@ class ElectrumWindow(App):
interface = self.network.interface
if interface:
self.server_host = interface.host
else:
self.server_host = str(net_params.host) + ' (connecting...)'
self.proxy_config = net_params.proxy or {}
self.update_proxy_str(self.proxy_config)
def on_network_event(self, event, *args):
Logger.info('network event: '+ event)

5
electrum/gui/kivy/uix/ui_screens/network.kv

@ -24,10 +24,7 @@ Popup:
CardSeparator
SettingsItem:
proxy: app.proxy_config.get('mode')
host: app.proxy_config.get('host')
port: app.proxy_config.get('port')
title: _("Proxy") + ': ' + ((self.host +':' + self.port) if self.proxy else _('None'))
title: _("Proxy") + ': ' + app.proxy_str
description: _('Proxy configuration')
action: lambda x: app.popup_dialog('proxy')

1
electrum/gui/kivy/uix/ui_screens/proxy.kv

@ -73,5 +73,4 @@ Popup:
if proxy['mode']=='none': proxy = None
net_params = net_params._replace(proxy=proxy)
app.network.run_from_another_thread(app.network.set_parameters(net_params))
app.proxy_config = proxy if proxy else {}
nd.dismiss()

4
electrum/gui/kivy/uix/ui_screens/server.kv

@ -23,7 +23,7 @@ Popup:
height: '36dp'
size_hint_x: 3
size_hint_y: None
text: app.server_host
text: app.network.get_parameters().host
Label:
height: '36dp'
size_hint_x: 1
@ -36,7 +36,7 @@ Popup:
height: '36dp'
size_hint_x: 3
size_hint_y: None
text: app.server_port
text: app.network.get_parameters().port
Widget
Button:
id: chooser

Loading…
Cancel
Save