278 lines
8.3 KiB
QML
Raw Normal View History

2020-10-18 06:50:26 -05:00
/*
2023-01-22 23:51:35 -06:00
* Copyright (c) 2020-2023 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.
*/
2024-04-01 02:42:21 -05:00
import QtCore
2022-05-02 04:31:32 -05:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
2020-10-18 06:50:26 -05:00
import SerialStudio
2021-09-25 21:48:06 -05:00
import "SetupPanes" as SetupPanes
2024-08-11 18:20:03 -05:00
import "../../Widgets" as Widgets
2020-10-18 06:50:26 -05:00
2024-08-11 18:20:03 -05:00
Widgets.Pane {
id: root
title: qsTr("Setup")
icon: "qrc:/rcc/icons/panes/setup.svg"
2024-11-11 17:35:53 -05:00
implicitHeight: layout.implicitHeight + 32
//
// Custom properties
//
property int setupMargin: 0
2024-09-23 02:44:59 -05:00
property int displayedWidth: 360
2024-11-11 17:35:53 -05:00
readonly property int maxItemWidth: layout.width - 8
2020-10-18 06:50:26 -05:00
//
// Displays the setup panel
//
function show() {
setupMargin = 0
}
//
// Hides the setup panel
//
function hide() {
setupMargin = -1 * displayedWidth
}
//
// Animations
//
visible: setupMargin > -1 * displayedWidth
Behavior on setupMargin {NumberAnimation{}}
//
// Save settings
//
Settings {
category: "SetupPanel"
property alias tabIndex: tab.currentIndex
property alias csvExport: csvLogging.checked
2024-09-20 02:11:46 -05:00
property alias driver: driverCombo.currentIndex
property alias language: settings.language
property alias tcpPlugins: settings.tcpPlugins
}
//
2024-09-18 21:48:57 -05:00
// Use page item to set application palette
//
2024-09-18 21:48:57 -05:00
Page {
implicitWidth: 0
anchors.fill: parent
2024-11-03 00:43:04 -05:00
anchors.topMargin: -16
anchors.leftMargin: -9
anchors.rightMargin: -9
anchors.bottomMargin: -9
2024-09-19 16:51:27 -05:00
palette.mid: Cpp_ThemeManager.colors["mid"]
palette.dark: Cpp_ThemeManager.colors["dark"]
2024-09-18 21:48:57 -05:00
palette.text: Cpp_ThemeManager.colors["text"]
2024-09-19 16:51:27 -05:00
palette.base: Cpp_ThemeManager.colors["base"]
palette.link: Cpp_ThemeManager.colors["link"]
palette.light: Cpp_ThemeManager.colors["light"]
2024-09-18 21:48:57 -05:00
palette.window: Cpp_ThemeManager.colors["window"]
2024-09-19 16:51:27 -05:00
palette.shadow: Cpp_ThemeManager.colors["shadow"]
palette.accent: Cpp_ThemeManager.colors["accent"]
palette.button: Cpp_ThemeManager.colors["button"]
palette.midlight: Cpp_ThemeManager.colors["midlight"]
palette.highlight: Cpp_ThemeManager.colors["highlight"]
palette.windowText: Cpp_ThemeManager.colors["window_text"]
palette.brightText: Cpp_ThemeManager.colors["bright_text"]
2024-09-18 21:48:57 -05:00
palette.buttonText: Cpp_ThemeManager.colors["button_text"]
2024-09-19 16:51:27 -05:00
palette.toolTipBase: Cpp_ThemeManager.colors["tooltip_base"]
palette.toolTipText: Cpp_ThemeManager.colors["tooltip_text"]
palette.linkVisited: Cpp_ThemeManager.colors["link_visited"]
palette.alternateBase: Cpp_ThemeManager.colors["alternate_base"]
2024-09-18 21:48:57 -05:00
palette.placeholderText: Cpp_ThemeManager.colors["placeholder_text"]
palette.highlightedText: Cpp_ThemeManager.colors["highlighted_text"]
2021-09-13 11:51:35 -05:00
//
2024-09-18 21:48:57 -05:00
// Control arrangement
2021-09-13 11:51:35 -05:00
//
2024-09-18 21:48:57 -05:00
ColumnLayout {
2024-11-11 17:35:53 -05:00
id: layout
2024-09-18 21:48:57 -05:00
spacing: 4
2024-11-03 00:43:04 -05:00
anchors {
fill: parent
topMargin: 10
leftMargin: 9
rightMargin: 9
bottomMargin: 9
}
2024-09-18 21:48:57 -05:00
//
// Device type selector
//
Label {
text: qsTr("Device Setup") + ":"
font: Cpp_Misc_CommonFonts.customUiFont(0.8, true)
2024-09-18 21:48:57 -05:00
color: Cpp_ThemeManager.colors["pane_section_label"]
Component.onCompleted: font.capitalization = Font.AllUppercase
} ComboBox {
2024-09-20 02:11:46 -05:00
id: driverCombo
2024-09-18 21:48:57 -05:00
Layout.fillWidth: true
model: Cpp_IO_Manager.availableBuses
2024-09-18 21:48:57 -05:00
displayText: qsTr("I/O Interface: %1").arg(currentText)
2024-09-20 02:11:46 -05:00
onCurrentIndexChanged: {
if (Cpp_IO_Manager.busType !== currentIndex)
Cpp_IO_Manager.busType = currentIndex
2024-09-20 02:11:46 -05:00
}
}
2021-02-01 18:55:15 -05:00
2024-09-18 21:48:57 -05:00
//
// CSV generator
//
Switch {
id: csvLogging
Layout.leftMargin: -6
text: qsTr("Create CSV File")
Layout.alignment: Qt.AlignLeft
checked: Cpp_CSV_Export.exportEnabled
palette.highlight: Cpp_ThemeManager.colors["csv_switch"]
2021-02-01 18:55:15 -05:00
2024-09-18 21:48:57 -05:00
onCheckedChanged: {
if (Cpp_CSV_Export.exportEnabled !== checked)
Cpp_CSV_Export.exportEnabled = checked
}
2024-08-11 18:20:03 -05:00
}
2021-02-01 18:55:15 -05:00
2024-09-18 21:48:57 -05:00
//
// Spacer
//
Item {
2024-10-14 15:10:00 -05:00
implicitHeight: 4
2024-09-18 21:48:57 -05:00
}
2020-10-18 06:50:26 -05:00
2024-09-18 21:48:57 -05:00
//
// Comm mode selector
//
Label {
text: qsTr("Frame Parsing") + ":"
font: Cpp_Misc_CommonFonts.customUiFont(0.8, true)
2024-09-18 21:48:57 -05:00
color: Cpp_ThemeManager.colors["pane_section_label"]
Component.onCompleted: font.capitalization = Font.AllUppercase
} RadioButton {
Layout.maximumHeight: 18
Layout.maximumWidth: root.maxItemWidth
text: qsTr("No Parsing (Device Sends JSON Data)")
checked: Cpp_JSON_FrameBuilder.operationMode === SerialStudio.DeviceSendsJSON
2024-09-18 21:48:57 -05:00
onCheckedChanged: {
const shouldChange = Cpp_JSON_FrameBuilder.operationMode !== SerialStudio.DeviceSendsJSON
2024-10-09 16:19:50 -05:00
if (checked && shouldChange)
Cpp_JSON_FrameBuilder.operationMode = SerialStudio.DeviceSendsJSON
2024-09-18 21:48:57 -05:00
}
} RadioButton {
Layout.maximumHeight: 18
Layout.maximumWidth: root.maxItemWidth
text: qsTr("Quick Plot (Comma Separated Values)")
checked: Cpp_JSON_FrameBuilder.operationMode === SerialStudio.QuickPlot
onCheckedChanged: {
const shouldChange = Cpp_JSON_FrameBuilder.operationMode !== SerialStudio.QuickPlot
2024-10-09 16:19:50 -05:00
if (checked && shouldChange)
Cpp_JSON_FrameBuilder.operationMode = SerialStudio.QuickPlot
}
2024-10-09 16:19:50 -05:00
} RadioButton {
2024-09-18 21:48:57 -05:00
Layout.maximumHeight: 18
Layout.maximumWidth: root.maxItemWidth
text: qsTr("Parse via JSON Project File")
checked: Cpp_JSON_FrameBuilder.operationMode === SerialStudio.ProjectFile
2024-09-18 21:48:57 -05:00
onCheckedChanged: {
const shouldChange = Cpp_JSON_FrameBuilder.operationMode !== SerialStudio.ProjectFile
2024-10-09 16:19:50 -05:00
if (checked && shouldChange)
Cpp_JSON_FrameBuilder.operationMode = SerialStudio.ProjectFile
2024-09-18 21:48:57 -05:00
}
}
2021-01-04 22:11:59 -06:00
2024-09-18 21:48:57 -05:00
//
// Map file selector button
//
Button {
Layout.fillWidth: true
opacity: enabled ? 1 : 0.5
Layout.maximumWidth: root.maxItemWidth
onClicked: Cpp_JSON_FrameBuilder.loadJsonMap()
enabled: Cpp_JSON_FrameBuilder.operationMode === SerialStudio.ProjectFile
text: (Cpp_JSON_FrameBuilder.jsonMapFilename.length ?
qsTr("Change Project File (%1)").arg(Cpp_JSON_FrameBuilder.jsonMapFilename) :
2024-09-18 21:48:57 -05:00
qsTr("Select Project File") + "...")
}
2024-09-18 21:48:57 -05:00
//
// Spacer
//
Item {
2024-10-14 15:10:00 -05:00
implicitHeight: 4
}
2024-09-18 21:48:57 -05:00
//
// Tab bar
//
TabBar {
id: tab
2024-10-14 15:10:00 -05:00
implicitHeight: 24
Layout.fillWidth: true
2024-09-18 21:48:57 -05:00
Layout.maximumWidth: root.maxItemWidth
TabButton {
text: qsTr("Device")
height: tab.height + 3
width: implicitWidth + 2 * 8
}
TabButton {
text: qsTr("Settings")
height: tab.height + 3
width: implicitWidth + 2 * 8
}
}
2021-01-04 22:11:59 -06:00
2024-09-18 21:48:57 -05:00
//
// Tab bar contents
//
StackLayout {
id: stack
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
2024-09-18 21:48:57 -05:00
currentIndex: tab.currentIndex
Layout.topMargin: -parent.spacing - 1
2024-11-11 17:35:53 -05:00
implicitHeight: Math.max(hardware.implicitHeight, settings.implicitHeight)
2024-09-18 21:48:57 -05:00
SetupPanes.Hardware {
id: hardware
Layout.fillWidth: true
Layout.fillHeight: true
}
SetupPanes.Settings {
id: settings
Layout.fillWidth: true
Layout.fillHeight: true
2020-10-18 06:50:26 -05:00
}
}
2020-10-18 06:50:26 -05:00
}
}
2020-10-18 06:50:26 -05:00
}