qml: fix autoconnect/single server selection, tapping server selects.
This commit is contained in:
@@ -39,56 +39,9 @@ ElDialog {
|
|||||||
ServerConfig {
|
ServerConfig {
|
||||||
id: serverconfig
|
id: serverconfig
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Servers')
|
|
||||||
font.pixelSize: constants.fontSizeLarge
|
|
||||||
color: Material.accentColor
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: 1
|
|
||||||
color: Material.accentColor
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame {
|
|
||||||
background: PaneInsetBackground { baseColor: Material.dialogColor }
|
|
||||||
clip: true
|
|
||||||
verticalPadding: 0
|
|
||||||
horizontalPadding: 0
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.bottomMargin: constants.paddingLarge
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: serversListView
|
|
||||||
anchors.fill: parent
|
|
||||||
model: Network.serverListModel
|
|
||||||
delegate: ServerDelegate {}
|
|
||||||
|
|
||||||
section.property: 'chain'
|
|
||||||
section.criteria: ViewSection.FullString
|
|
||||||
section.delegate: RowLayout {
|
|
||||||
width: ListView.view.width
|
|
||||||
required property string section
|
|
||||||
Label {
|
|
||||||
text: section
|
|
||||||
? serversListView.model.chaintips > 1
|
|
||||||
? qsTr('Connected @%1').arg(section)
|
|
||||||
: qsTr('Connected')
|
|
||||||
: qsTr('Disconnected')
|
|
||||||
Layout.alignment: Qt.AlignLeft
|
|
||||||
Layout.topMargin: constants.paddingXSmall
|
|
||||||
Layout.leftMargin: constants.paddingSmall
|
|
||||||
font.pixelSize: constants.fontSizeMedium
|
|
||||||
color: Material.accentColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatButton {
|
FlatButton {
|
||||||
@@ -96,17 +49,12 @@ ElDialog {
|
|||||||
text: qsTr('Ok')
|
text: qsTr('Ok')
|
||||||
icon.source: '../../icons/confirmed.png'
|
icon.source: '../../icons/confirmed.png'
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Config.autoConnect = serverconfig.auto_server
|
Config.autoConnect = serverconfig.auto_connect
|
||||||
if (!serverconfig.auto_server) {
|
Config.serverString = serverconfig.address
|
||||||
Network.server = serverconfig.address
|
Network.server = serverconfig.address
|
||||||
}
|
|
||||||
rootItem.close()
|
rootItem.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
serverconfig.auto_server = Config.autoConnect
|
|
||||||
serverconfig.address = Network.server
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ Wizard {
|
|||||||
Config.autoConnect = wizard_data['autoconnect']
|
Config.autoConnect = wizard_data['autoconnect']
|
||||||
if (!wizard_data['autoconnect']) {
|
if (!wizard_data['autoconnect']) {
|
||||||
Network.server = wizard_data['server']
|
Network.server = wizard_data['server']
|
||||||
|
Config.serverString = wizard_data['server']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import QtQuick.Layouts 1.0
|
import QtQuick.Layouts 1.0
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Controls.Material 2.0
|
||||||
|
|
||||||
|
import org.electrum 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property alias auto_server: auto_server_cb.checked
|
id: root
|
||||||
|
|
||||||
|
property alias auto_connect: auto_server_cb.checked
|
||||||
property alias address: address_tf.text
|
property alias address: address_tf.text
|
||||||
|
|
||||||
height: rootLayout.height
|
implicitHeight: rootLayout.height
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: rootLayout
|
id: rootLayout
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
spacing: constants.paddingLarge
|
spacing: constants.paddingLarge
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
@@ -35,5 +41,67 @@ Item {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Label {
|
||||||
|
text: qsTr('Servers')
|
||||||
|
font.pixelSize: constants.fontSizeLarge
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 1
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
|
||||||
|
Frame {
|
||||||
|
background: PaneInsetBackground { baseColor: Material.dialogColor }
|
||||||
|
clip: true
|
||||||
|
verticalPadding: 0
|
||||||
|
horizontalPadding: 0
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: constants.paddingLarge
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: serversListView
|
||||||
|
anchors.fill: parent
|
||||||
|
model: Network.serverListModel
|
||||||
|
delegate: ServerDelegate {
|
||||||
|
onClicked: {
|
||||||
|
address_tf.text = model.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section.property: 'chain'
|
||||||
|
section.criteria: ViewSection.FullString
|
||||||
|
section.delegate: RowLayout {
|
||||||
|
width: ListView.view.width
|
||||||
|
required property string section
|
||||||
|
Label {
|
||||||
|
text: section
|
||||||
|
? serversListView.model.chaintips > 1
|
||||||
|
? qsTr('Connected @%1').arg(section)
|
||||||
|
: qsTr('Connected')
|
||||||
|
: qsTr('Other known servers')
|
||||||
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
Layout.topMargin: constants.paddingXSmall
|
||||||
|
Layout.leftMargin: constants.paddingSmall
|
||||||
|
font.pixelSize: constants.fontSizeMedium
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
root.auto_connect = Config.autoConnectDefined ? Config.autoConnect : false
|
||||||
|
root.address = Config.serverString ? Config.serverString : Network.server
|
||||||
|
// TODO: initial setup should not connect already, is Network.server defined?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ WizardComponent {
|
|||||||
last: true
|
last: true
|
||||||
|
|
||||||
function apply() {
|
function apply() {
|
||||||
wizard_data['oneserver'] = !sc.auto_server
|
wizard_data['autoconnect'] = !sc.auto_connect
|
||||||
wizard_data['server'] = sc.address
|
wizard_data['server'] = sc.address
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
width: parent.width
|
anchors.fill: parent
|
||||||
spacing: constants.paddingLarge
|
spacing: constants.paddingLarge
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -24,6 +24,7 @@ WizardComponent {
|
|||||||
ServerConfig {
|
ServerConfig {
|
||||||
id: sc
|
id: sc
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class QENetwork(QObject, QtEventListener):
|
|||||||
if not server: raise Exception("failed to parse")
|
if not server: raise Exception("failed to parse")
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
net_params = net_params._replace(server=server)
|
net_params = net_params._replace(server=server, auto_connect=self._qeconfig.autoConnect, oneserver=not self._qeconfig.autoConnect)
|
||||||
self.network.run_from_another_thread(self.network.set_parameters(net_params))
|
self.network.run_from_another_thread(self.network.set_parameters(net_params))
|
||||||
|
|
||||||
@pyqtProperty(str, notify=statusChanged)
|
@pyqtProperty(str, notify=statusChanged)
|
||||||
|
|||||||
Reference in New Issue
Block a user