Implemented network settings
This commit is contained in:
@@ -22,6 +22,12 @@ RowLayout {
|
||||
property string title: qsTr("Firmware update")
|
||||
}
|
||||
|
||||
Screens.NetworkSettingsScreen {
|
||||
id: networkSettingsScreen
|
||||
property string title: qsTr("Network settings")
|
||||
}
|
||||
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
@@ -30,7 +36,7 @@ RowLayout {
|
||||
spacing: 20
|
||||
|
||||
Repeater {
|
||||
model: [terminalScreen.title, firmwareUpdateScreen.title]
|
||||
model: [terminalScreen.title, firmwareUpdateScreen.title, networkSettingsScreen.title]
|
||||
delegate: Controls.LinkLabel {
|
||||
text: modelData
|
||||
onClicked: stack.currentIndex = index
|
||||
@@ -41,6 +47,7 @@ RowLayout {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
Layout.preferredWidth: 180
|
||||
Layout.minimumWidth: 180
|
||||
Layout.maximumWidth: 180
|
||||
}
|
||||
}
|
||||
|
||||
212
qml/Screens/NetworkSettingsScreen.qml
Normal file
212
qml/Screens/NetworkSettingsScreen.qml
Normal file
@@ -0,0 +1,212 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import Controls 1.0 as Controls
|
||||
import Cubo 1.0
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
|
||||
Controls.Frame {
|
||||
padding: 35
|
||||
topPadding: 20
|
||||
bottomPadding: 20
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
id: firstUrlLabel
|
||||
text: qsTr("Url 1")
|
||||
|
||||
TextMetrics {
|
||||
id: firstUrlMetrics
|
||||
font: firstUrlLabel.font
|
||||
text: firstUrlLabel.text
|
||||
}
|
||||
|
||||
Layout.preferredWidth: getMaxLabelWidth()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: firstUrlField
|
||||
validator: RegExpValidator { regExp: /.{0,250}/ }
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 35
|
||||
topPadding: 20
|
||||
bottomPadding: 20
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
id: secondUrlLabel
|
||||
text: qsTr("Url 2")
|
||||
|
||||
TextMetrics {
|
||||
id: secondUrlMetrics
|
||||
font: secondUrlLabel.font
|
||||
text: secondUrlLabel.text
|
||||
}
|
||||
|
||||
Layout.preferredWidth: getMaxLabelWidth()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: secondUrlField
|
||||
validator: RegExpValidator { regExp: /.{0,250}/ }
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 35
|
||||
topPadding: 20
|
||||
bottomPadding: 20
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
id: apnLabel
|
||||
text: qsTr("APN")
|
||||
|
||||
TextMetrics {
|
||||
id: apnMetrics
|
||||
font: apnLabel.font
|
||||
text: apnLabel.text
|
||||
}
|
||||
|
||||
Layout.preferredWidth: getMaxLabelWidth()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: apnField
|
||||
validator: RegExpValidator { regExp: /.{0,50}/ }
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 35
|
||||
topPadding: 20
|
||||
bottomPadding: 20
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
id: userLabel
|
||||
text: qsTr("User")
|
||||
|
||||
TextMetrics {
|
||||
id: userMetrics
|
||||
font: userLabel.font
|
||||
text: userLabel.text
|
||||
}
|
||||
|
||||
Layout.preferredWidth: getMaxLabelWidth()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: userField
|
||||
validator: RegExpValidator { regExp: /.{0,50}/ }
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 35
|
||||
topPadding: 20
|
||||
bottomPadding: 20
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
id: passwordLabel
|
||||
text: qsTr("Password")
|
||||
|
||||
TextMetrics {
|
||||
id: passwordMetrics
|
||||
font: passwordLabel.font
|
||||
text: passwordLabel.text
|
||||
}
|
||||
|
||||
Layout.preferredWidth: getMaxLabelWidth()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: passwordField
|
||||
validator: RegExpValidator { regExp: /.{0,50}/ }
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
text: qsTr("Apply")
|
||||
onClicked: {
|
||||
if (!BmsInterface.isPortConnected())
|
||||
return
|
||||
|
||||
var settings = [
|
||||
firstUrlField.text,
|
||||
secondUrlField.text,
|
||||
apnField.text,
|
||||
userField.text,
|
||||
passwordField.text,
|
||||
]
|
||||
|
||||
BmsInterface.commands().setNetSettings(settings)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: BmsInterface.commands()
|
||||
onNetSettingsReceived: {
|
||||
if (settings.length < 5) {
|
||||
return
|
||||
}
|
||||
|
||||
firstUrlField.text = settings[0]
|
||||
secondUrlField.text = settings[1]
|
||||
apnField.text = settings[2]
|
||||
userField.text = settings[3]
|
||||
passwordField.text = settings[4]
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: if (visible) {
|
||||
if (BmsInterface.isPortConnected()) {
|
||||
BmsInterface.commands().getNetSettings()
|
||||
}
|
||||
}
|
||||
|
||||
function getMaxLabelWidth() {
|
||||
return Math.max(firstUrlMetrics.width, secondUrlMetrics.width, apnMetrics.width, userMetrics.width, passwordMetrics.width)
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,4 @@ MessageDialog 1.0 MessageDialog.qml
|
||||
StatusPopup 1.0 StatusPopup.qml
|
||||
TerminalScreen 1.0 TerminalScreen.qml
|
||||
FirmwareUpdateScreen 1.0 FirmwareUpdateScreen.qml
|
||||
NetworkSettingsScreen 1.0 NetworkSettingsScreen.qml
|
||||
|
||||
@@ -44,5 +44,6 @@
|
||||
<file>Screens/TerminalScreen.qml</file>
|
||||
<file>Screens/FirmwareUpdateScreen.qml</file>
|
||||
<file>Controls/ProgressBar.qml</file>
|
||||
<file>Screens/NetworkSettingsScreen.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user