auto_cycle option
authorthomasv <thomasv@gitorious>
Thu, 3 Jan 2013 16:39:51 +0000 (17:39 +0100)
committerthomasv <thomasv@gitorious>
Thu, 3 Jan 2013 16:39:51 +0000 (17:39 +0100)
lib/gui_qt.py
lib/interface.py

index 1be3f86..9ed25d2 100644 (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):
index 9caa88d..c79762b 100644 (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 )