mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 20:35:13 +00:00
network_dialog: save parameters in follow_branch, follow_server
This commit is contained in:
parent
c8e4b7a42e
commit
b31f4ca133
1 changed files with 19 additions and 5 deletions
|
@ -74,10 +74,10 @@ class NodesListWidget(QTreeWidget):
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
if is_server:
|
if is_server:
|
||||||
server = unicode(item.data(1, Qt.UserRole).toString())
|
server = unicode(item.data(1, Qt.UserRole).toString())
|
||||||
menu.addAction(_("Use as server"), lambda: self.parent.network.switch_to_interface(server))
|
menu.addAction(_("Use as server"), lambda: self.parent.follow_server(server))
|
||||||
else:
|
else:
|
||||||
index = item.data(1, Qt.UserRole).toInt()[0]
|
index = item.data(1, Qt.UserRole).toInt()[0]
|
||||||
menu.addAction(_("Follow this branch"), lambda: self.parent.network.follow_chain(index))
|
menu.addAction(_("Follow this branch"), lambda: self.parent.follow_branch(index))
|
||||||
menu.exec_(self.viewport().mapToGlobal(position))
|
menu.exec_(self.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
|
@ -99,7 +99,7 @@ class NodesListWidget(QTreeWidget):
|
||||||
if n_chains > 1:
|
if n_chains > 1:
|
||||||
for b in network.blockchains.values():
|
for b in network.blockchains.values():
|
||||||
name = network.get_blockchain_name(b)
|
name = network.get_blockchain_name(b)
|
||||||
x = QTreeWidgetItem([name, '%d'%checkpoint])
|
x = QTreeWidgetItem([name + '@%d'%checkpoint, '%d'%b.height()])
|
||||||
x.setData(0, Qt.UserRole, 1)
|
x.setData(0, Qt.UserRole, 1)
|
||||||
x.setData(1, Qt.UserRole, b.checkpoint)
|
x.setData(1, Qt.UserRole, b.checkpoint)
|
||||||
for i in network.interfaces.values():
|
for i in network.interfaces.values():
|
||||||
|
@ -296,7 +296,7 @@ class NetworkChoiceLayout(object):
|
||||||
self.proxy_user.setText(proxy_config.get("user", ""))
|
self.proxy_user.setText(proxy_config.get("user", ""))
|
||||||
self.proxy_password.setText(proxy_config.get("password", ""))
|
self.proxy_password.setText(proxy_config.get("password", ""))
|
||||||
|
|
||||||
height_str = "%d "%(self.network.get_local_height()) + _("blocks")
|
height_str = "%d "%(self.network.get_local_height())
|
||||||
self.height_label.setText(height_str)
|
self.height_label.setText(height_str)
|
||||||
n = len(self.network.get_interfaces())
|
n = len(self.network.get_interfaces())
|
||||||
status = _("Connected to %d nodes.")%n if n else _("Not connected")
|
status = _("Connected to %d nodes.")%n if n else _("Not connected")
|
||||||
|
@ -304,7 +304,8 @@ class NetworkChoiceLayout(object):
|
||||||
if len(self.network.blockchains)>1:
|
if len(self.network.blockchains)>1:
|
||||||
checkpoint = self.network.get_checkpoint()
|
checkpoint = self.network.get_checkpoint()
|
||||||
name = self.network.get_blockchain_name(self.network.blockchain())
|
name = self.network.get_blockchain_name(self.network.blockchain())
|
||||||
msg = _('Chain split detected at block %d')%checkpoint + '\n' + _('You are on branch') + ' ' + name
|
msg = _('Chain split detected at block %d')%checkpoint
|
||||||
|
msg += '\n' + _('Your server is on branch') + ' ' + name
|
||||||
else:
|
else:
|
||||||
msg = ''
|
msg = ''
|
||||||
self.split_label.setText(msg)
|
self.split_label.setText(msg)
|
||||||
|
@ -337,6 +338,19 @@ class NetworkChoiceLayout(object):
|
||||||
self.set_protocol(p)
|
self.set_protocol(p)
|
||||||
self.set_server()
|
self.set_server()
|
||||||
|
|
||||||
|
def follow_branch(self, index):
|
||||||
|
self.network.follow_chain(index)
|
||||||
|
host, port, protocol, proxy, auto_connect = self.network.get_parameters()
|
||||||
|
auto_connect = True
|
||||||
|
self.network.set_parameters(host, port, protocol, proxy, auto_connect)
|
||||||
|
|
||||||
|
def follow_server(self, server):
|
||||||
|
self.network.switch_to_interface(server)
|
||||||
|
host, port, protocol, proxy, auto_connect = self.network.get_parameters()
|
||||||
|
host, port, protocol = server.split(':')
|
||||||
|
auto_connect = False
|
||||||
|
self.network.set_parameters(host, port, protocol, proxy, auto_connect)
|
||||||
|
|
||||||
def server_changed(self, x):
|
def server_changed(self, x):
|
||||||
if x:
|
if x:
|
||||||
self.change_server(str(x.text(0)), self.protocol)
|
self.change_server(str(x.text(0)), self.protocol)
|
||||||
|
|
Loading…
Add table
Reference in a new issue