Browse Source

network dialog

283
thomasv 13 years ago
parent
commit
a7345418be
  1. 9
      client/gui.py
  2. 61
      client/gui_qt.py
  3. 6
      client/interface.py

9
client/gui.py

@ -354,12 +354,9 @@ def run_network_dialog( wallet, parent ):
else:
return
if host!= wallet.interface.host or port!=wallet.interface.port:
wallet.interface.host = host
wallet.interface.set_port( port )
wallet.interface.is_connected = False
if parent:
wallet.save()
wallet.interface.set_server(host, port)
if parent:
wallet.save()

61
client/gui_qt.py

@ -376,6 +376,7 @@ class ElectrumWindow(QMainWindow):
b.setToolTip("Network")
b.setFlat(True)
b.setMaximumWidth(25)
b.clicked.connect(self.network_dialog)
hbox.addWidget(b)
sb.addPermanentWidget(buttons)
@ -537,6 +538,66 @@ class ElectrumWindow(QMainWindow):
self.wallet.fee = fee
self.wallet.save()
def network_dialog(self, parent=True):
wallet = self.wallet
if parent:
if wallet.interface.is_connected:
status = "Connected to %s.\n%d blocks\nresponse time: %f"%(wallet.interface.host, wallet.interface.blocks, wallet.interface.rtime)
else:
status = "Not connected"
host = wallet.interface.host
port = wallet.interface.port
else:
import random
status = "Please choose a server."
host = random.choice( wallet.interface.servers )
port = 50000
d = QDialog(self)
d.setModal(1)
grid = QGridLayout()
grid.setSpacing(8)
grid.addWidget(QLabel(status), 0, 0, 1, 2)
host_line = QLineEdit()
host_line.setText("%s:%d"% (host,port) )
grid.addWidget(QLabel('Server'), 2, 0)
grid.addWidget(host_line, 2, 1)
b = QPushButton("Cancel")
grid.addWidget(b, 5, 1)
b.clicked.connect(d.reject)
b = QPushButton("OK")
grid.addWidget(b, 5, 2)
b.clicked.connect(d.accept)
d.setLayout(grid)
if not d.exec_(): return
hh = str( host_line.text() )
try:
if ':' in hh:
host, port = hh.split(':')
port = int(port)
else:
host = hh
port = 50000
except:
show_message("error")
if parent == None:
sys.exit(1)
else:
return
wallet.interface.set_server(host, port)
if parent:
wallet.save()
class BitcoinGUI():

6
client/interface.py

@ -201,3 +201,9 @@ class Interface:
def get_servers(self):
thread.start_new_thread(self.update_servers_thread, ())
def set_server(self, host, port):
if host!= self.host or port!=self.port:
self.host = host
self.set_port( port )
self.is_connected = False

Loading…
Cancel
Save