qml: show option for single server in ServerConfig
This commit is contained in:
@@ -44,6 +44,9 @@ ElDialog {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
Config.autoConnect = serverconfig.auto_connect
|
Config.autoConnect = serverconfig.auto_connect
|
||||||
Network.server = serverconfig.address
|
Network.server = serverconfig.address
|
||||||
|
Network.oneServer = serverconfig.auto_connect
|
||||||
|
? false
|
||||||
|
: serverconfig.one_server
|
||||||
rootItem.close()
|
rootItem.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ Item {
|
|||||||
property bool showAutoselectServer: true
|
property bool showAutoselectServer: true
|
||||||
property alias auto_connect: auto_server_cb.checked
|
property alias auto_connect: auto_server_cb.checked
|
||||||
property alias address: address_tf.text
|
property alias address: address_tf.text
|
||||||
|
property alias one_server: one_server_cb.checked
|
||||||
|
|
||||||
implicitHeight: rootLayout.height
|
implicitHeight: rootLayout.height
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ Item {
|
|||||||
id: auto_server_cb
|
id: auto_server_cb
|
||||||
visible: showAutoselectServer
|
visible: showAutoselectServer
|
||||||
text: qsTr('Select server automatically')
|
text: qsTr('Select server automatically')
|
||||||
checked: true
|
checked: !showAutoselectServer
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
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 {
|
ColumnLayout {
|
||||||
Heading {
|
Heading {
|
||||||
text: qsTr('Servers')
|
text: qsTr('Servers')
|
||||||
@@ -96,6 +113,7 @@ Item {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false
|
root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false
|
||||||
root.address = Network.server
|
root.address = Network.server
|
||||||
|
one_server_cb.checked = Network.oneServer
|
||||||
// TODO: initial setup should not connect already, is Network.server defined?
|
// TODO: initial setup should not connect already, is Network.server defined?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ WizardComponent {
|
|||||||
function apply() {
|
function apply() {
|
||||||
wizard_data['autoconnect'] = sc.address.trim() == ""
|
wizard_data['autoconnect'] = sc.address.trim() == ""
|
||||||
wizard_data['server'] = sc.address
|
wizard_data['server'] = sc.address
|
||||||
|
wizard_data['one_server'] = sc.one_server
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|||||||
@@ -254,6 +254,18 @@ class QENetwork(QObject, QtEventListener):
|
|||||||
def isProxyTor(self):
|
def isProxyTor(self):
|
||||||
return bool(self.network.is_proxy_tor)
|
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)
|
@pyqtProperty('QVariant', notify=feeHistogramUpdated)
|
||||||
def feeHistogram(self):
|
def feeHistogram(self):
|
||||||
return self._fee_histogram
|
return self._fee_histogram
|
||||||
|
|||||||
@@ -96,3 +96,4 @@ class WCServerConfig(WizardComponent):
|
|||||||
def apply(self):
|
def apply(self):
|
||||||
self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == ''
|
self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == ''
|
||||||
self.wizard_data['server'] = self.sw.server_e.text()
|
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}')
|
self._logger.debug(f'configuring server: {wizard_data!r}')
|
||||||
net_params = self._daemon.network.get_parameters()
|
net_params = self._daemon.network.get_parameters()
|
||||||
server = ''
|
server = ''
|
||||||
|
oneserver = wizard_data.get('one_server', False)
|
||||||
if not wizard_data['autoconnect']:
|
if not wizard_data['autoconnect']:
|
||||||
try:
|
try:
|
||||||
server = ServerAddr.from_str_with_inference(wizard_data['server'])
|
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'])
|
raise Exception('failed to parse server %s' % wizard_data['server'])
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
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))
|
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
|
||||||
|
|
||||||
def do_configure_autoconnect(self, wizard_data: dict):
|
def do_configure_autoconnect(self, wizard_data: dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user