Merge pull request #9895 from accumulator/qml_network_settings_update_fix
qml: fix updating network settings
This commit is contained in:
@@ -34,7 +34,6 @@ ElDialog {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FlatButton {
|
||||
@@ -42,9 +41,10 @@ ElDialog {
|
||||
text: qsTr('Ok')
|
||||
icon.source: '../../icons/confirmed.png'
|
||||
onClicked: {
|
||||
Network.oneServer = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Single
|
||||
Config.autoConnect = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Autoconnect
|
||||
Network.server = serverconfig.address
|
||||
let auto_connect = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Autoconnect
|
||||
let server = serverconfig.address
|
||||
let one_server = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Single
|
||||
Network.setServerParameters(server, auto_connect, one_server)
|
||||
rootItem.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ Wizard {
|
||||
} else {
|
||||
Network.proxy = {'enabled': false}
|
||||
}
|
||||
Config.autoConnect = wizard_data['autoconnect']
|
||||
if (!wizard_data['autoconnect']) {
|
||||
Network.server = wizard_data['server']
|
||||
}
|
||||
Network.setServerParameters(wizard_data['server'], wizard_data['autoconnect'], wizard_data['one_server'])
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
@@ -22,12 +22,12 @@ ElComboBox {
|
||||
]
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!Config.autoConnectDefined) { // initial setup
|
||||
if (!Network.autoConnectDefined) { // initial setup
|
||||
server_connect_mode_cb.currentIndex = server_connect_mode_cb.indexOfValue(
|
||||
ServerConnectModeComboBox.Mode.Manual)
|
||||
} else {
|
||||
server_connect_mode_cb.currentIndex = server_connect_mode_cb.indexOfValue(
|
||||
Config.autoConnect
|
||||
Network.autoConnect
|
||||
? ServerConnectModeComboBox.Mode.Autoconnect
|
||||
: Network.oneServer
|
||||
? ServerConnectModeComboBox.Mode.Single
|
||||
|
||||
@@ -526,7 +526,7 @@ ApplicationWindow
|
||||
}
|
||||
|
||||
function continueWithServerConnection() {
|
||||
if (!Config.autoConnectDefined) {
|
||||
if (!Network.autoConnectDefined) {
|
||||
var dialog = serverConnectWizard.createObject(app)
|
||||
// without completed serverConnectWizard we can't start
|
||||
dialog.rejected.connect(function() {
|
||||
|
||||
@@ -82,21 +82,6 @@ class QEConfig(AuthMixin, QObject):
|
||||
self.config.TERMS_OF_USE_ACCEPTED = 0
|
||||
self.termsOfUseChanged.emit()
|
||||
|
||||
autoConnectChanged = pyqtSignal()
|
||||
@pyqtProperty(bool, notify=autoConnectChanged)
|
||||
def autoConnect(self):
|
||||
return self.config.NETWORK_AUTO_CONNECT
|
||||
|
||||
@autoConnect.setter
|
||||
def autoConnect(self, auto_connect):
|
||||
self.config.NETWORK_AUTO_CONNECT = auto_connect
|
||||
self.autoConnectChanged.emit()
|
||||
|
||||
# auto_connect is actually a tri-state, expose the undefined case
|
||||
@pyqtProperty(bool, notify=autoConnectChanged)
|
||||
def autoConnectDefined(self):
|
||||
return self.config.cv.NETWORK_AUTO_CONNECT.is_set()
|
||||
|
||||
baseUnitChanged = pyqtSignal()
|
||||
@pyqtProperty(str, notify=baseUnitChanged)
|
||||
def baseUnit(self):
|
||||
|
||||
@@ -184,20 +184,39 @@ class QENetwork(QObject, QtEventListener):
|
||||
def serverHeight(self):
|
||||
return self._server_height
|
||||
|
||||
autoConnectChanged = pyqtSignal()
|
||||
@pyqtProperty(bool, notify=autoConnectChanged)
|
||||
def autoConnect(self):
|
||||
return self.network.config.NETWORK_AUTO_CONNECT
|
||||
|
||||
# auto_connect is actually a tri-state, expose the undefined case
|
||||
@pyqtProperty(bool, notify=autoConnectChanged)
|
||||
def autoConnectDefined(self):
|
||||
return self.network.config.cv.NETWORK_AUTO_CONNECT.is_set()
|
||||
|
||||
@pyqtProperty(str, notify=statusChanged)
|
||||
def server(self):
|
||||
return self._server
|
||||
|
||||
@server.setter
|
||||
def server(self, server: str):
|
||||
@pyqtSlot(str, bool, bool)
|
||||
def setServerParameters(self, server: str, auto_connect: bool, one_server: bool):
|
||||
net_params = self.network.get_parameters()
|
||||
try:
|
||||
server = ServerAddr.from_str_with_inference(server)
|
||||
if not server:
|
||||
raise Exception('failed to parse')
|
||||
except Exception:
|
||||
if server == net_params.server and auto_connect == net_params.auto_connect and one_server == net_params.oneserver:
|
||||
return
|
||||
net_params = net_params._replace(server=server, auto_connect=QEConfig.instance.autoConnect)
|
||||
if server != str(net_params.server):
|
||||
try:
|
||||
server = ServerAddr.from_str_with_inference(server)
|
||||
if not server:
|
||||
raise Exception('failed to parse')
|
||||
except Exception:
|
||||
if not auto_connect:
|
||||
return
|
||||
server = net_params.server
|
||||
self.statusChanged.emit()
|
||||
if auto_connect != net_params.auto_connect:
|
||||
self.network.config.NETWORK_AUTO_CONNECT = auto_connect
|
||||
self.autoConnectChanged.emit()
|
||||
net_params = net_params._replace(server=server, auto_connect=auto_connect, oneserver=one_server)
|
||||
self.network.run_from_another_thread(self.network.set_parameters(net_params))
|
||||
|
||||
@pyqtProperty(str, notify=statusChanged)
|
||||
@@ -258,14 +277,6 @@ class QENetwork(QObject, QtEventListener):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user