Skip to content

Commit

Permalink
qml: Add Ping360EthernetConfiguration
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Mar 20, 2020
1 parent 37d806d commit 30b15af
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
118 changes: 118 additions & 0 deletions qml/Ping360EthernetConfiguration.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import QtQml.Models 2.2

import DeviceManager 1.0
import Ping360HelperService 1.0
import StyleManager 1.0

PingPopup {
id: root

closePolicy: Popup.NoAutoClose
property var connection: undefined

// Default size
width: 300
height: 280

function configureConnection(connection) {
open()
root.connection = connection
}

Label {
id: title
text: "Ping360 Ethetnet configuration"
anchors.horizontalCenter: parent.horizontalCenter
}

ListModel {
id: ethernetModes
ListElement {
name: "DHCP Client"
info: "Allows to connect as a normal ethernet client to a DHCP server."
}
ListElement {
name: "Static IP"
info: "Used to set a fixed IP address in a personalized network environment.<br>⚠ <strong>Ensure to configure your subnet if necessary</strong> ⚠"
}
}

GridLayout {
id: grid
columns: 2
anchors.top: title.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom

RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
Label {
text: "Type:"
}
PingComboBox {
id: comboBox
model: ethernetModes
textRole: "name"
Layout.fillWidth: true
}
}

Text {
text: ethernetModes.get(comboBox.currentIndex).info
color: comboBox.currentIndex == 1 ? "red" : "black"
horizontalAlignment: Text.AlignHCenter | Text.AlignJustify
wrapMode: Text.Wrap
Layout.columnSpan: 2
Layout.fillWidth: true
}

PingTextField {
id: ipTextField
title: "IP address:"
text: "192.168.2.4"
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
visible: comboBox.currentIndex == 1
// TODO: Move to RegularExpressionValidator when using Qt 5.14+
// Check for valid IPV4 (0.0.0.0, 192.168.0.2)
validator: RegExpValidator {
regExp: /^(?!\.)((^|\.)([1-9]?\d|1\d\d|2(5[0-5]|[0-4]\d))){4}$/gm
}
}

Button {
id: confirmButton
text: "Confirm"
Layout.fillWidth: true
onClicked: {
let ip = connection.argsAsConst()[0];
if (comboBox.currentIndex == 0) {
Ping360HelperService.setDHCPServer(ip);
} else {
Ping360HelperService.setStaticIP(ip, ipTextField.text);
}

// Reset model to remove old results
DeviceManager.clear()

root.close()
deviceManagerViewer.open()
}
}
Button {
id: cancelButton
text: "Cancel"
Layout.fillWidth: true
onClicked: {
root.close()
deviceManagerViewer.open()
}
}
}
}
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<file alias="MainPage.qml">qml/MainPage.qml</file>
<file alias="NoControlPanel.qml">qml/NoControlPanel.qml</file>
<file alias="Ping1DVisualizer.qml">qml/Ping1DVisualizer.qml</file>
<file alias="Ping360EthernetConfiguration.qml">qml/Ping360EthernetConfiguration.qml</file>
<file alias="Ping360Visualizer.qml">qml/Ping360Visualizer.qml</file>
<file alias="PingButton.qml">qml/PingButton.qml</file>
<file alias="PingComboBox.qml">qml/PingComboBox.qml</file>
Expand Down

0 comments on commit 30b15af

Please sign in to comment.