1
0

qml: oneserver, auto-connect combobox

This commit is contained in:
Sander van Grieken
2025-06-02 13:27:28 +02:00
parent 30d6228cac
commit b5170a3fa6
4 changed files with 70 additions and 35 deletions

View File

@@ -42,10 +42,8 @@ ElDialog {
text: qsTr('Ok')
icon.source: '../../icons/confirmed.png'
onClicked: {
Network.oneServer = serverconfig.auto_connect
? false
: serverconfig.one_server
Config.autoConnect = serverconfig.auto_connect
Network.oneServer = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Single
Config.autoConnect = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Autoconnect
Network.server = serverconfig.address
rootItem.close()
}

View File

@@ -10,9 +10,8 @@ Item {
id: root
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
property alias serverConnectMode: server_connect_mode_cb.currentValue
implicitHeight: rootLayout.height
@@ -23,12 +22,32 @@ Item {
height: parent.height
spacing: constants.paddingLarge
CheckBox {
id: auto_server_cb
visible: showAutoselectServer
text: Config.shortDescFor('NETWORK_AUTO_CONNECT')
checked: !showAutoselectServer
enabled: !one_server_cb.checked
RowLayout {
Layout.fillWidth: true
ServerConnectModeComboBox {
id: server_connect_mode_cb
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: 1
}
HelpButton {
Layout.alignment: Qt.AlignRight
heading: qsTr('Connection mode')+':'
helptext: Config.getTranslatedMessage('MSG_CONNECTMODE_SERVER_HELP') + '<br/><br/>' +
Config.getTranslatedMessage('MSG_CONNECTMODE_NODES_HELP') + '<ul>' +
'<li><b>' + Config.getTranslatedMessage('MSG_CONNECTMODE_AUTOCONNECT') +
'</b>: ' + Config.getTranslatedMessage('MSG_CONNECTMODE_AUTOCONNECT_HELP') + '</li>' +
'<li><b>' + Config.getTranslatedMessage('MSG_CONNECTMODE_MANUAL') +
'</b>: ' + Config.getTranslatedMessage('MSG_CONNECTMODE_MANUAL_HELP') + '</li>' +
'<li><b>' + Config.getTranslatedMessage('MSG_CONNECTMODE_ONESERVER') +
'</b>: ' + Config.getTranslatedMessage('MSG_CONNECTMODE_ONESERVER_HELP') + '</li>' +
'</ul>'
}
}
Label {
@@ -41,28 +60,12 @@ Item {
TextField {
id: address_tf
enabled: !auto_server_cb.checked
enabled: server_connect_mode_cb.currentValue != ServerConnectModeComboBox.Mode.Autoconnect
width: parent.width
inputMethodHints: Qt.ImhNoPredictiveText
}
}
RowLayout {
Layout.fillWidth: true
visible: !auto_server_cb.checked && address_tf.text
CheckBox {
id: one_server_cb
Layout.fillWidth: true
text: Config.shortDescFor('NETWORK_ONESERVER')
}
HelpButton {
heading: Config.shortDescFor('NETWORK_ONESERVER')
helptext: Config.longDescFor('NETWORK_ONESERVER')
}
}
ColumnLayout {
Heading {
text: qsTr('Servers')
@@ -112,9 +115,6 @@ 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?
}
}

View File

@@ -0,0 +1,38 @@
import QtQuick
import QtQuick.Controls
import org.electrum 1.0
ElComboBox {
id: control
enum Mode {
Autoconnect,
Manual,
Single
}
textRole: 'text'
valueRole: 'value'
model: [
{ text: qsTr('Auto-connect'), value: ServerConnectModeComboBox.Mode.Autoconnect },
{ text: qsTr('Manual server selection'), value: ServerConnectModeComboBox.Mode.Manual },
{ text: qsTr('Connect only to a single server'), value: ServerConnectModeComboBox.Mode.Single }
]
Component.onCompleted: {
if (!Config.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
? ServerConnectModeComboBox.Mode.Autoconnect
: Network.oneServer
? ServerConnectModeComboBox.Mode.Single
: ServerConnectModeComboBox.Mode.Manual
)
}
}
}

View File

@@ -10,9 +10,9 @@ WizardComponent {
title: qsTr('Server')
function apply() {
wizard_data['autoconnect'] = sc.address.trim() == ""
wizard_data['server'] = sc.address
wizard_data['one_server'] = sc.one_server
wizard_data['autoconnect'] = sc.serverConnectMode == ServerConnectModeComboBox.Mode.Autoconnect
wizard_data['one_server'] = sc.serverConnectMode == ServerConnectModeComboBox.Mode.Single
}
ColumnLayout {
@@ -21,7 +21,6 @@ WizardComponent {
ServerConfig {
id: sc
showAutoselectServer: false
Layout.fillWidth: true
Layout.fillHeight: true
}