qml: show option for single server in ServerConfig
This commit is contained in:
@@ -44,6 +44,9 @@ ElDialog {
|
||||
onClicked: {
|
||||
Config.autoConnect = serverconfig.auto_connect
|
||||
Network.server = serverconfig.address
|
||||
Network.oneServer = serverconfig.auto_connect
|
||||
? false
|
||||
: serverconfig.one_server
|
||||
rootItem.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ Item {
|
||||
property bool showAutoselectServer: true
|
||||
property alias auto_connect: auto_server_cb.checked
|
||||
property alias address: address_tf.text
|
||||
property alias one_server: one_server_cb.checked
|
||||
|
||||
implicitHeight: rootLayout.height
|
||||
|
||||
@@ -26,7 +27,7 @@ Item {
|
||||
id: auto_server_cb
|
||||
visible: showAutoselectServer
|
||||
text: qsTr('Select server automatically')
|
||||
checked: true
|
||||
checked: !showAutoselectServer
|
||||
}
|
||||
|
||||
Label {
|
||||
@@ -45,6 +46,22 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
visible: !auto_server_cb.checked && address_tf.text
|
||||
|
||||
CheckBox {
|
||||
id: one_server_cb
|
||||
Layout.fillWidth: true
|
||||
text: qsTr('One server')
|
||||
}
|
||||
|
||||
HelpButton {
|
||||
heading: qsTr('One server')
|
||||
helptext: qsTr('Connect only to a single Electrum Server. This can help with privacy, but at the cost of detecting lagging and forks')
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Heading {
|
||||
text: qsTr('Servers')
|
||||
@@ -96,6 +113,7 @@ Item {
|
||||
Component.onCompleted: {
|
||||
root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false
|
||||
root.address = Network.server
|
||||
one_server_cb.checked = Network.oneServer
|
||||
// TODO: initial setup should not connect already, is Network.server defined?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ WizardComponent {
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = sc.address.trim() == ""
|
||||
wizard_data['server'] = sc.address
|
||||
wizard_data['one_server'] = sc.one_server
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
|
||||
@@ -254,6 +254,18 @@ class QENetwork(QObject, QtEventListener):
|
||||
def isProxyTor(self):
|
||||
return bool(self.network.is_proxy_tor)
|
||||
|
||||
@pyqtProperty(bool, notify=statusChanged)
|
||||
def oneServer(self):
|
||||
return self.network.oneserver
|
||||
|
||||
@oneServer.setter
|
||||
def oneServer(self, one_server: bool):
|
||||
if one_server != self.network.oneserver:
|
||||
net_params = self.network.get_parameters()
|
||||
net_params = net_params._replace(oneserver=one_server)
|
||||
self.network.run_from_another_thread(self.network.set_parameters(net_params))
|
||||
self.statusChanged.emit()
|
||||
|
||||
@pyqtProperty('QVariant', notify=feeHistogramUpdated)
|
||||
def feeHistogram(self):
|
||||
return self._fee_histogram
|
||||
|
||||
@@ -96,3 +96,4 @@ class WCServerConfig(WizardComponent):
|
||||
def apply(self):
|
||||
self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == ''
|
||||
self.wizard_data['server'] = self.sw.server_e.text()
|
||||
self.wizard_data['one_server'] = False
|
||||
|
||||
@@ -745,6 +745,7 @@ class ServerConnectWizard(AbstractWizard):
|
||||
self._logger.debug(f'configuring server: {wizard_data!r}')
|
||||
net_params = self._daemon.network.get_parameters()
|
||||
server = ''
|
||||
oneserver = wizard_data.get('one_server', False)
|
||||
if not wizard_data['autoconnect']:
|
||||
try:
|
||||
server = ServerAddr.from_str_with_inference(wizard_data['server'])
|
||||
@@ -752,7 +753,9 @@ class ServerConnectWizard(AbstractWizard):
|
||||
raise Exception('failed to parse server %s' % wizard_data['server'])
|
||||
except Exception:
|
||||
return
|
||||
net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'])
|
||||
else:
|
||||
oneserver = False
|
||||
net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'], oneserver=oneserver)
|
||||
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
|
||||
|
||||
def do_configure_autoconnect(self, wizard_data: dict):
|
||||
|
||||
Reference in New Issue
Block a user