2020-10-18 06:50:26 -05:00
|
|
|
/*
|
2021-01-05 22:48:49 -05:00
|
|
|
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
|
2020-10-18 06:50:26 -05:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2021-09-30 19:07:39 -05:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Controls
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-30 19:07:39 -05:00
|
|
|
import Qt.labs.settings
|
2020-10-18 06:50:26 -05:00
|
|
|
|
|
|
|
import "../Widgets" as Widgets
|
2021-09-25 21:48:06 -05:00
|
|
|
import "SetupPanes" as SetupPanes
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
Item {
|
2021-09-13 11:51:35 -05:00
|
|
|
id: root
|
2021-09-24 23:07:31 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// Custom properties
|
|
|
|
//
|
|
|
|
property int setupMargin: 0
|
|
|
|
property int displayedWidth: 340 + app.spacing * 1.5
|
2021-09-24 15:07:43 -05:00
|
|
|
readonly property int maxItemWidth: column.width - 2 * spacing
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-24 23:07:31 -05:00
|
|
|
//
|
|
|
|
// Displays the setup panel
|
|
|
|
//
|
|
|
|
function show() {
|
|
|
|
opacity = 1
|
|
|
|
setupMargin = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hides the setup panel
|
|
|
|
//
|
|
|
|
function hide() {
|
|
|
|
opacity = 0
|
|
|
|
setupMargin = -1 * displayedWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Animations
|
|
|
|
//
|
|
|
|
visible: opacity > 0
|
|
|
|
Behavior on opacity {NumberAnimation{}}
|
|
|
|
Behavior on setupMargin {NumberAnimation{}}
|
|
|
|
|
2021-09-13 11:51:35 -05:00
|
|
|
//
|
|
|
|
// Save settings
|
|
|
|
//
|
|
|
|
Settings {
|
2020-10-18 06:50:26 -05:00
|
|
|
//
|
2021-09-13 11:51:35 -05:00
|
|
|
// Misc settings
|
2020-12-24 14:13:44 -06:00
|
|
|
//
|
2021-09-13 11:51:35 -05:00
|
|
|
property alias auto: commAuto.checked
|
|
|
|
property alias manual: commManual.checked
|
|
|
|
property alias tabIndex: tab.currentIndex
|
|
|
|
property alias csvExport: csvLogging.checked
|
2021-09-12 22:42:02 -05:00
|
|
|
|
2021-09-13 11:51:35 -05:00
|
|
|
//
|
|
|
|
// Serial settings
|
|
|
|
//
|
|
|
|
property alias parity: serial.parity
|
|
|
|
property alias baudRate: serial.baudRate
|
|
|
|
property alias dataBits: serial.dataBits
|
|
|
|
property alias stopBits: serial.stopBits
|
|
|
|
property alias flowControl: serial.flowControl
|
2021-09-24 15:07:43 -05:00
|
|
|
property alias autoReconnect: serial.autoReconnect
|
2021-09-12 22:42:02 -05:00
|
|
|
|
2021-09-13 11:51:35 -05:00
|
|
|
//
|
|
|
|
// Network settings
|
|
|
|
//
|
|
|
|
property alias port: network.port
|
|
|
|
property alias address: network.address
|
|
|
|
property alias socketType: network.socketType
|
2021-10-08 00:02:11 -05:00
|
|
|
property alias udpMulticastEnabled: network.udpMulticastEnabled
|
2021-09-12 22:42:02 -05:00
|
|
|
|
2021-09-13 11:51:35 -05:00
|
|
|
//
|
|
|
|
// MQTT settings
|
|
|
|
//
|
|
|
|
property alias mqttHost: mqtt.host
|
|
|
|
property alias mqttPort: mqtt.port
|
|
|
|
property alias mqttUser: mqtt.user
|
|
|
|
property alias mqttMode: mqtt.mode
|
|
|
|
property alias mqttTopic: mqtt.topic
|
|
|
|
property alias mqttVersion: mqtt.version
|
|
|
|
property alias mqttPassword: mqtt.password
|
2020-12-24 14:13:44 -06:00
|
|
|
|
|
|
|
//
|
2021-09-13 11:51:35 -05:00
|
|
|
// App settings
|
2021-02-01 18:55:15 -05:00
|
|
|
//
|
2021-09-13 11:51:35 -05:00
|
|
|
property alias language: settings.language
|
|
|
|
property alias endSequence: settings.endSequence
|
|
|
|
property alias startSequence: settings.startSequence
|
|
|
|
property alias tcpPlugins: settings.tcpPlugins
|
2021-09-17 19:44:59 -05:00
|
|
|
property alias separatorSequence: settings.separatorSequence
|
2021-09-18 19:07:42 -05:00
|
|
|
property alias uiRefreshRate: settings.uiRefreshRate
|
2021-09-13 11:51:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update manual/auto checkboxes
|
|
|
|
//
|
|
|
|
Connections {
|
|
|
|
target: Cpp_JSON_Generator
|
|
|
|
function onOperationModeChanged() {
|
2021-09-30 23:15:32 -05:00
|
|
|
commAuto.checked = (Cpp_JSON_Generator.operationMode === 1)
|
|
|
|
commManual.checked = (Cpp_JSON_Generator.operationMode === 0)
|
2021-02-04 23:40:32 -05:00
|
|
|
}
|
2021-09-13 11:51:35 -05:00
|
|
|
}
|
|
|
|
|
2021-10-07 03:12:37 -05:00
|
|
|
//
|
|
|
|
// Window shadow (must go before window declaration
|
|
|
|
// to avoid blurry artifacts & glitches).
|
|
|
|
//
|
|
|
|
Widgets.Shadow {
|
|
|
|
source: window
|
|
|
|
anchors.fill: window
|
|
|
|
}
|
|
|
|
|
2021-09-13 11:51:35 -05:00
|
|
|
//
|
|
|
|
// Window
|
|
|
|
//
|
|
|
|
Widgets.Window {
|
|
|
|
id: window
|
|
|
|
gradient: true
|
|
|
|
title: qsTr("Setup")
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
headerDoubleClickEnabled: false
|
|
|
|
anchors.margins: app.spacing * 1.5
|
|
|
|
icon.source: "qrc:/icons/settings.svg"
|
2021-10-06 16:58:35 -05:00
|
|
|
backgroundColor: Cpp_ThemeManager.paneWindowBackground
|
2021-02-04 23:40:32 -05:00
|
|
|
|
|
|
|
//
|
2021-09-12 22:42:02 -05:00
|
|
|
// Control arrangement
|
2021-02-01 18:55:15 -05:00
|
|
|
//
|
2021-09-12 22:42:02 -05:00
|
|
|
ColumnLayout {
|
|
|
|
id: column
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: app.spacing / 2
|
|
|
|
anchors.margins: app.spacing * 1.5
|
|
|
|
|
|
|
|
//
|
|
|
|
// Comm mode selector
|
|
|
|
//
|
|
|
|
Label {
|
|
|
|
font.bold: true
|
|
|
|
text: qsTr("Communication Mode") + ":"
|
|
|
|
} RadioButton {
|
|
|
|
id: commAuto
|
|
|
|
checked: true
|
2021-09-24 15:07:43 -05:00
|
|
|
Layout.maximumWidth: root.maxItemWidth
|
2021-09-23 22:56:03 -05:00
|
|
|
text: qsTr("No parsing (device sends JSON data)")
|
2021-09-12 22:42:02 -05:00
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked)
|
|
|
|
Cpp_JSON_Generator.setOperationMode(1)
|
|
|
|
else
|
|
|
|
Cpp_JSON_Generator.setOperationMode(0)
|
|
|
|
}
|
|
|
|
} RadioButton {
|
|
|
|
id: commManual
|
|
|
|
checked: false
|
2021-09-24 15:07:43 -05:00
|
|
|
Layout.maximumWidth: root.maxItemWidth
|
2021-09-23 22:56:03 -05:00
|
|
|
text: qsTr("Parse via JSON project file")
|
2021-09-12 22:42:02 -05:00
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked)
|
|
|
|
Cpp_JSON_Generator.setOperationMode(0)
|
|
|
|
else
|
|
|
|
Cpp_JSON_Generator.setOperationMode(1)
|
2021-02-17 14:36:39 -05:00
|
|
|
}
|
2021-02-01 18:55:15 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Map file selector button
|
|
|
|
//
|
|
|
|
Button {
|
2021-02-01 18:55:15 -05:00
|
|
|
Layout.fillWidth: true
|
2021-09-12 22:42:02 -05:00
|
|
|
opacity: enabled ? 1 : 0.5
|
|
|
|
enabled: commManual.checked
|
2021-09-24 15:07:43 -05:00
|
|
|
Layout.maximumWidth: root.maxItemWidth
|
2021-09-12 22:42:02 -05:00
|
|
|
onClicked: Cpp_JSON_Generator.loadJsonMap()
|
|
|
|
Behavior on opacity {NumberAnimation{}}
|
2021-09-23 22:56:03 -05:00
|
|
|
text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change project file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) :
|
|
|
|
qsTr("Select project file") + "...")
|
2021-02-04 23:40:32 -05:00
|
|
|
}
|
2021-02-01 18:55:15 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Spacer
|
|
|
|
//
|
|
|
|
Item {
|
|
|
|
height: app.spacing / 2
|
2021-02-01 18:55:15 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Enable/disable CSV logging
|
|
|
|
//
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
2020-12-24 14:13:44 -06:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
Switch {
|
|
|
|
id: csvLogging
|
|
|
|
text: qsTr("Create CSV file")
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
checked: Cpp_CSV_Export.exportEnabled
|
2021-09-24 15:07:43 -05:00
|
|
|
Layout.maximumWidth: root.maxItemWidth
|
2021-10-06 16:58:35 -05:00
|
|
|
palette.highlight: Cpp_ThemeManager.csvCheckbox
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
onCheckedChanged: {
|
|
|
|
if (Cpp_CSV_Export.exportEnabled !== checked)
|
|
|
|
Cpp_CSV_Export.exportEnabled = checked
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-01-04 22:11:59 -06:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
RoundButton {
|
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
|
|
|
icon.color: Cpp_ThemeManager.text
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
icon.source: "qrc:/icons/help.svg"
|
|
|
|
onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki")
|
|
|
|
}
|
2021-02-27 01:50:42 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Spacer
|
|
|
|
//
|
|
|
|
Item {
|
|
|
|
height: app.spacing / 2
|
2021-01-27 04:54:30 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Tab bar
|
|
|
|
//
|
|
|
|
TabBar {
|
|
|
|
height: 24
|
|
|
|
id: tab
|
|
|
|
Layout.fillWidth: true
|
2021-09-24 15:07:43 -05:00
|
|
|
Layout.maximumWidth: root.maxItemWidth
|
2021-09-12 22:42:02 -05:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
if (currentIndex < 2 && currentIndex !== Cpp_IO_Manager.dataSource)
|
|
|
|
Cpp_IO_Manager.dataSource = currentIndex
|
2021-02-16 01:17:25 -05:00
|
|
|
}
|
2021-01-27 04:54:30 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("Serial")
|
|
|
|
height: tab.height + 3
|
|
|
|
width: implicitWidth + 2 * app.spacing
|
2021-02-15 16:53:00 -05:00
|
|
|
}
|
2021-02-10 21:03:32 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("Network")
|
|
|
|
height: tab.height + 3
|
|
|
|
width: implicitWidth + 2 * app.spacing
|
2021-02-15 16:53:00 -05:00
|
|
|
}
|
2021-02-10 21:03:32 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("MQTT")
|
|
|
|
height: tab.height + 3
|
|
|
|
width: implicitWidth + 2 * app.spacing
|
2021-02-27 01:50:42 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("Settings")
|
|
|
|
height: tab.height + 3
|
|
|
|
width: implicitWidth + 2 * app.spacing
|
2021-02-15 16:53:00 -05:00
|
|
|
}
|
2021-02-10 21:03:32 -05:00
|
|
|
}
|
2021-01-04 22:11:59 -06:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// Tab bar contents
|
|
|
|
//
|
|
|
|
StackLayout {
|
|
|
|
id: stack
|
|
|
|
clip: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: false
|
|
|
|
currentIndex: tab.currentIndex
|
|
|
|
Layout.topMargin: -parent.spacing - 1
|
|
|
|
Layout.minimumHeight: implicitHeight
|
|
|
|
Layout.maximumHeight: implicitHeight
|
|
|
|
Layout.preferredHeight: implicitHeight
|
|
|
|
onCurrentIndexChanged: getImplicitHeight()
|
|
|
|
Component.onCompleted: getImplicitHeight()
|
|
|
|
|
|
|
|
function getImplicitHeight() {
|
|
|
|
stack.implicitHeight = 0
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
switch (currentIndex) {
|
|
|
|
case 0:
|
|
|
|
stack.implicitHeight = serial.implicitHeight
|
|
|
|
break
|
|
|
|
case 1:
|
|
|
|
stack.implicitHeight = network.implicitHeight
|
|
|
|
break
|
|
|
|
case 2:
|
|
|
|
stack.implicitHeight = mqtt.implicitHeight
|
|
|
|
break
|
|
|
|
case 3:
|
|
|
|
stack.implicitHeight = settings.implicitHeight
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
stack.implicitHeight = 0
|
|
|
|
break
|
2020-10-18 06:50:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
SetupPanes.Serial {
|
|
|
|
id: serial
|
|
|
|
background: TextField {
|
|
|
|
enabled: false
|
|
|
|
palette.base: Cpp_ThemeManager.setupPanelBackground
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
SetupPanes.Network {
|
|
|
|
id: network
|
|
|
|
background: TextField {
|
|
|
|
enabled: false
|
|
|
|
palette.base: Cpp_ThemeManager.setupPanelBackground
|
|
|
|
}
|
2020-10-18 06:50:26 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
SetupPanes.MQTT {
|
|
|
|
id: mqtt
|
|
|
|
background: TextField {
|
|
|
|
enabled: false
|
|
|
|
palette.base: Cpp_ThemeManager.setupPanelBackground
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetupPanes.Settings {
|
|
|
|
id: settings
|
|
|
|
background: TextField {
|
|
|
|
enabled: false
|
|
|
|
palette.base: Cpp_ThemeManager.setupPanelBackground
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 06:50:26 -05:00
|
|
|
}
|
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
//
|
|
|
|
// RX/TX LEDs
|
|
|
|
//
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: app.spacing
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Widgets.LED {
|
|
|
|
id: _rx
|
|
|
|
enabled: false
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: Cpp_IO_Manager
|
|
|
|
function onRx() {
|
|
|
|
_rx.flash()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 06:50:26 -05:00
|
|
|
|
2021-09-12 22:42:02 -05:00
|
|
|
Label {
|
|
|
|
text: "RX"
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 18
|
|
|
|
font.family: app.monoFont
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-10-05 04:15:48 -05:00
|
|
|
color: _rx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
|
2021-09-12 22:42:02 -05:00
|
|
|
}
|
|
|
|
|
2021-09-28 14:43:06 -05:00
|
|
|
Widgets.Icon {
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2021-09-12 22:42:02 -05:00
|
|
|
source: "qrc:/icons/ethernet.svg"
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-09-28 14:43:06 -05:00
|
|
|
color: Cpp_ThemeManager.ledDisabled
|
2021-09-12 22:42:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: "TX"
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 18
|
|
|
|
font.family: app.monoFont
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-10-05 04:15:48 -05:00
|
|
|
color: _tx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
|
2021-09-12 22:42:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Widgets.LED {
|
|
|
|
id: _tx
|
|
|
|
enabled: false
|
|
|
|
layoutDirection: Qt.RightToLeft
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: Cpp_IO_Manager
|
|
|
|
function onTx() {
|
|
|
|
_tx.flash()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
2020-10-18 06:50:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|