Skip to content

Commit da16613

Browse files
committed
qml: show option for single server in ServerConfig
1 parent acc8396 commit da16613

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

electrum/gui/qml/components/ServerConfigDialog.qml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ ElDialog {
4444
onClicked: {
4545
Config.autoConnect = serverconfig.auto_connect
4646
Network.server = serverconfig.address
47+
Network.oneServer = serverconfig.auto_connect
48+
? false
49+
: serverconfig.one_server
4750
rootItem.close()
4851
}
4952
}

electrum/gui/qml/components/controls/ServerConfig.qml

+19-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Item {
1212
property bool showAutoselectServer: true
1313
property alias auto_connect: auto_server_cb.checked
1414
property alias address: address_tf.text
15+
property alias one_server: one_server_cb.checked
1516

1617
implicitHeight: rootLayout.height
1718

@@ -26,7 +27,7 @@ Item {
2627
id: auto_server_cb
2728
visible: showAutoselectServer
2829
text: qsTr('Select server automatically')
29-
checked: true
30+
checked: !showAutoselectServer
3031
}
3132

3233
Label {
@@ -45,6 +46,22 @@ Item {
4546
}
4647
}
4748

49+
RowLayout {
50+
Layout.fillWidth: true
51+
visible: !auto_server_cb.checked && address_tf.text
52+
53+
CheckBox {
54+
id: one_server_cb
55+
Layout.fillWidth: true
56+
text: qsTr('One server')
57+
}
58+
59+
HelpButton {
60+
heading: qsTr('One server')
61+
helptext: qsTr('Connect only to a single Electrum Server. This can help with privacy, but at the cost of detecting lagging and forks')
62+
}
63+
}
64+
4865
ColumnLayout {
4966
Heading {
5067
text: qsTr('Servers')
@@ -96,6 +113,7 @@ Item {
96113
Component.onCompleted: {
97114
root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false
98115
root.address = Network.server
116+
one_server_cb.checked = Network.oneServer
99117
// TODO: initial setup should not connect already, is Network.server defined?
100118
}
101119
}

electrum/gui/qml/components/wizard/WCServerConfig.qml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ WizardComponent {
1212
function apply() {
1313
wizard_data['autoconnect'] = sc.address.trim() == ""
1414
wizard_data['server'] = sc.address
15+
wizard_data['one_server'] = sc.one_server
1516
}
1617

1718
ColumnLayout {

electrum/gui/qml/qenetwork.py

+12
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ def proxy(self, proxy_settings):
269269
def isProxyTor(self):
270270
return bool(self.network.is_proxy_tor)
271271

272+
@pyqtProperty(bool, notify=statusChanged)
273+
def oneServer(self):
274+
return self.network.oneserver
275+
276+
@oneServer.setter
277+
def oneServer(self, one_server: bool):
278+
if one_server != self.network.oneserver:
279+
net_params = self.network.get_parameters()
280+
net_params = net_params._replace(oneserver=one_server)
281+
self.network.run_from_another_thread(self.network.set_parameters(net_params))
282+
self.statusChanged.emit()
283+
272284
@pyqtProperty('QVariant', notify=feeHistogramUpdated)
273285
def feeHistogram(self):
274286
return self._fee_histogram

electrum/gui/qt/wizard/server_connect.py

+1
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@ def __init__(self, parent, wizard):
110110
def apply(self):
111111
self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == ''
112112
self.wizard_data['server'] = self.sw.server_e.text()
113+
self.wizard_data['one_server'] = False

electrum/wizard.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -704,14 +704,17 @@ def do_configure_server(self, wizard_data: dict):
704704
self._logger.debug(f'configuring server: {wizard_data!r}')
705705
net_params = self._daemon.network.get_parameters()
706706
server = ''
707+
oneserver = wizard_data.get('one_server', False)
707708
if not wizard_data['autoconnect']:
708709
try:
709710
server = ServerAddr.from_str_with_inference(wizard_data['server'])
710711
if not server:
711712
raise Exception('failed to parse server %s' % wizard_data['server'])
712713
except Exception:
713714
return
714-
net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'])
715+
else:
716+
oneserver = False
717+
net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'], oneserver=oneserver)
715718
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
716719

717720
def do_configure_autoconnect(self, wizard_data: dict):

0 commit comments

Comments
 (0)