Browse Source

qml: fix autoconnect/single server selection, tapping server selects.

master
Sander van Grieken 3 years ago
parent
commit
d52afee635
  1. 60
      electrum/gui/qml/components/ServerConfigDialog.qml
  2. 1
      electrum/gui/qml/components/ServerConnectWizard.qml
  3. 72
      electrum/gui/qml/components/controls/ServerConfig.qml
  4. 5
      electrum/gui/qml/components/wizard/WCServerConfig.qml
  5. 2
      electrum/gui/qml/qenetwork.py

60
electrum/gui/qml/components/ServerConfigDialog.qml

@ -39,56 +39,9 @@ ElDialog {
ServerConfig {
id: serverconfig
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.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 {
@ -96,17 +49,12 @@ ElDialog {
text: qsTr('Ok')
icon.source: '../../icons/confirmed.png'
onClicked: {
Config.autoConnect = serverconfig.auto_server
if (!serverconfig.auto_server) {
Network.server = serverconfig.address
}
Config.autoConnect = serverconfig.auto_connect
Config.serverString = serverconfig.address
Network.server = serverconfig.address
rootItem.close()
}
}
}
Component.onCompleted: {
serverconfig.auto_server = Config.autoConnect
serverconfig.address = Network.server
}
}

1
electrum/gui/qml/components/ServerConnectWizard.qml

@ -23,6 +23,7 @@ Wizard {
Config.autoConnect = wizard_data['autoconnect']
if (!wizard_data['autoconnect']) {
Network.server = wizard_data['server']
Config.serverString = wizard_data['server']
}
}

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

@ -1,17 +1,23 @@
import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.0
import org.electrum 1.0
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
height: rootLayout.height
implicitHeight: rootLayout.height
ColumnLayout {
id: rootLayout
width: parent.width
height: parent.height
spacing: constants.paddingLarge
CheckBox {
@ -35,5 +41,67 @@ Item {
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?
}
}

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

@ -9,12 +9,12 @@ WizardComponent {
last: true
function apply() {
wizard_data['oneserver'] = !sc.auto_server
wizard_data['autoconnect'] = !sc.auto_connect
wizard_data['server'] = sc.address
}
ColumnLayout {
width: parent.width
anchors.fill: parent
spacing: constants.paddingLarge
Label {
@ -24,6 +24,7 @@ WizardComponent {
ServerConfig {
id: sc
width: parent.width
Layout.fillHeight: true
}
}
}

2
electrum/gui/qml/qenetwork.py

@ -138,7 +138,7 @@ class QENetwork(QObject, QtEventListener):
if not server: raise Exception("failed to parse")
except Exception:
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))
@pyqtProperty(str, notify=statusChanged)

Loading…
Cancel
Save