auto_cycle option

This commit is contained in:
thomasv 2013-01-03 17:39:51 +01:00
parent 4180a426c5
commit 2962c63001
2 changed files with 12 additions and 3 deletions

View File

@ -1791,6 +1791,12 @@ class ElectrumWindow(QMainWindow):
if not wallet.config.is_modifiable('server'):
for w in [server_host, server_port, server_protocol, servers_list_widget]: w.setEnabled(False)
# auto cycle
autocycle_cb = QCheckBox('Try random servers if disconnected')
autocycle_cb.setChecked(wallet.config.get('auto_cycle', False))
grid.addWidget(autocycle_cb, 3, 1, 3, 2)
if not wallet.config.is_modifiable('auto_cycle'): autocycle_cb.setEnabled(False)
# proxy setting
proxy_mode = QComboBox()
proxy_host = QLineEdit()
@ -1838,7 +1844,7 @@ class ElectrumWindow(QMainWindow):
wallet.config.set_key("proxy", proxy, True)
wallet.config.set_key("server", server, True)
interface.set_server(server, proxy)
wallet.config.set_key('auto_cycle', autocycle_cb.isChecked(), True)
return True
def closeEvent(self, event):

View File

@ -382,9 +382,12 @@ class Interface(threading.Thread):
def init_interface(self):
if self.config.get('server'):
self.init_with_server(self.config)
else:
if self.config.get('auto_cycle') is None:
self.config.set_key('auto_cycle', True, False)
if not self.is_connected:
print "Using random server..."
if not self.is_connected and self.config.get('auto_cycle'):
print_msg("Using random server...")
servers = DEFAULT_SERVERS[:]
while servers:
server = random.choice( servers )