qml: oneserver, auto-connect combobox
This commit is contained in:
@@ -42,10 +42,8 @@ ElDialog {
|
|||||||
text: qsTr('Ok')
|
text: qsTr('Ok')
|
||||||
icon.source: '../../icons/confirmed.png'
|
icon.source: '../../icons/confirmed.png'
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Network.oneServer = serverconfig.auto_connect
|
Network.oneServer = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Single
|
||||||
? false
|
Config.autoConnect = serverconfig.serverConnectMode == ServerConnectModeComboBox.Mode.Autoconnect
|
||||||
: serverconfig.one_server
|
|
||||||
Config.autoConnect = serverconfig.auto_connect
|
|
||||||
Network.server = serverconfig.address
|
Network.server = serverconfig.address
|
||||||
rootItem.close()
|
rootItem.close()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool showAutoselectServer: true
|
property bool showAutoselectServer: true
|
||||||
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
|
property alias serverConnectMode: server_connect_mode_cb.currentValue
|
||||||
|
|
||||||
implicitHeight: rootLayout.height
|
implicitHeight: rootLayout.height
|
||||||
|
|
||||||
@@ -23,12 +22,32 @@ Item {
|
|||||||
height: parent.height
|
height: parent.height
|
||||||
spacing: constants.paddingLarge
|
spacing: constants.paddingLarge
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: auto_server_cb
|
RowLayout {
|
||||||
visible: showAutoselectServer
|
Layout.fillWidth: true
|
||||||
text: Config.shortDescFor('NETWORK_AUTO_CONNECT')
|
|
||||||
checked: !showAutoselectServer
|
ServerConnectModeComboBox {
|
||||||
enabled: !one_server_cb.checked
|
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 {
|
Label {
|
||||||
@@ -41,28 +60,12 @@ Item {
|
|||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: address_tf
|
id: address_tf
|
||||||
enabled: !auto_server_cb.checked
|
enabled: server_connect_mode_cb.currentValue != ServerConnectModeComboBox.Mode.Autoconnect
|
||||||
width: parent.width
|
width: parent.width
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
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 {
|
ColumnLayout {
|
||||||
Heading {
|
Heading {
|
||||||
text: qsTr('Servers')
|
text: qsTr('Servers')
|
||||||
@@ -112,9 +115,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
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?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@ WizardComponent {
|
|||||||
title: qsTr('Server')
|
title: qsTr('Server')
|
||||||
|
|
||||||
function apply() {
|
function apply() {
|
||||||
wizard_data['autoconnect'] = sc.address.trim() == ""
|
|
||||||
wizard_data['server'] = sc.address
|
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 {
|
ColumnLayout {
|
||||||
@@ -21,7 +21,6 @@ WizardComponent {
|
|||||||
|
|
||||||
ServerConfig {
|
ServerConfig {
|
||||||
id: sc
|
id: sc
|
||||||
showAutoselectServer: false
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user