commit fb6a1a0720dea8aec4fbd9e42a29eb78b1c7e50d
parent f1c9aa66034365ee1c91ea993ecccb08c58c350e
Author: thomasv <thomasv@gitorious>
Date: Fri, 19 Oct 2012 10:41:20 +0200
better protocol handling in gui
Diffstat:
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/lib/gui_qt.py b/lib/gui_qt.py
@@ -1425,9 +1425,6 @@ class ElectrumWindow(QMainWindow):
server_protocol.addItems(protocol_names)
host, port, protocol = server.split(':')
- server_host.setText(host)
- server_port.setText(port)
- server_protocol.setCurrentIndex(protocol_letters.index(protocol))
grid.addWidget(QLabel(_('Server') + ':'), 0, 0)
grid.addWidget(server_protocol, 0, 1)
@@ -1458,14 +1455,21 @@ class ElectrumWindow(QMainWindow):
for host in plist.keys():
servers_list_widget.addTopLevelItem(QTreeWidgetItem( [ host ] ))
- def change_server(x):
- host = unicode(x.text(0))
+ def change_server(host, protocol=None):
+
pp = plist[host]
- if 't' in pp.keys():
- protocol = 't'
- else:
- protocol = pp.keys()[0]
- port = pp[protocol]
+ if protocol:
+ port = pp.get(protocol)
+ if not port: protocol = None
+
+ if not protocol:
+ if 't' in pp.keys():
+ protocol = 't'
+ else:
+ protocol = pp.keys()[0]
+ port = pp.get(protocol)
+
+
server_host.setText( host )
server_port.setText( port )
server_protocol.setCurrentIndex(protocol_letters.index(protocol))
@@ -1478,8 +1482,10 @@ class ElectrumWindow(QMainWindow):
else:
server_protocol.model().setData(j, QtCore.QVariant(0,False), QtCore.Qt.UserRole-1)
+ change_server(host,protocol)
+
- servers_list_widget.connect(servers_list_widget, SIGNAL('itemClicked(QTreeWidgetItem*, int)'), change_server)
+ servers_list_widget.connect(servers_list_widget, SIGNAL('itemClicked(QTreeWidgetItem*, int)'), lambda x: change_server(unicode(x.text(0))))
grid.addWidget(servers_list_widget, 1, 1, 1, 3)
if not wallet.config.is_modifiable('server'):