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) } }