Serial-Studio/assets/qml/Dashboard/ViewOptions.qml

333 lines
10 KiB
QML
Raw Normal View History

/*
2021-09-25 03:52:03 -05:00
* Copyright (c) 2021 Alex Spataru <https://github.com/alex-spataru>
*
* 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
2021-10-06 14:44:34 -05:00
import Qt.labs.settings 1.0
import "../Widgets" as Widgets
Widgets.Window {
id: root
//
// Window properties
//
gradient: true
title: qsTr("View")
headerDoubleClickEnabled: false
icon.source: "qrc:/icons/visibility.svg"
2021-10-06 16:58:35 -05:00
backgroundColor: Cpp_ThemeManager.paneWindowBackground
//
// Signals
//
signal widgetSizeChanged(var maxSize)
2021-10-06 14:44:34 -05:00
//
// Maps the slider position to points
// https://stackoverflow.com/a/846249
//
function logslider(position) {
var minp = 0
var maxp = 100
var minv = Math.log(10)
var maxv = Math.log(10000)
var scale = (maxv - minv) / (maxp - minp);
return Math.exp(minv + scale * (position - minp)).toFixed(0);
}
//
// Maps the points value to the slider position
// https://stackoverflow.com/a/846249
//
function logposition(value) {
var minp = 0
var maxp = 100
var minv = Math.log(10)
var maxv = Math.log(10000)
var scale = (maxv - minv) / (maxp - minp)
var result = (Math.log(value) - minv) / scale + minp;
return result.toFixed(0)
}
//
// Settings
//
Settings {
property alias points: plotPoints.value
property alias widgetSize: widgetSize.value
property alias decimalPlaces: decimalPlaces.value
2021-10-06 14:44:34 -05:00
}
//
// Put all items inside a scrollview
//
ScrollView {
clip: true
contentWidth: -1
anchors.fill: parent
anchors.margins: app.spacing
anchors.topMargin: root.borderWidth
anchors.bottomMargin: root.borderWidth
//
// Main layout
//
ColumnLayout {
2021-10-06 14:44:34 -05:00
id: layout
x: app.spacing
2021-09-26 05:42:22 -05:00
spacing: app.spacing / 2
width: parent.width - 10 - 2 * app.spacing
//
// Spacer
//
Item {
height: app.spacing
}
2021-10-06 14:44:34 -05:00
//
2021-11-01 02:23:06 -06:00
// View options title
2021-10-06 14:44:34 -05:00
//
RowLayout {
spacing: app.spacing
Layout.fillWidth: true
visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0
Widgets.Icon {
width: 18
height: 18
color: palette.text
source: "qrc:/icons/visibility.svg"
2021-10-06 14:44:34 -05:00
}
Label {
font.bold: true
2021-11-01 02:23:06 -06:00
text: qsTr("Visualization options")
2021-10-06 14:44:34 -05:00
}
Item {
Layout.fillWidth: true
}
}
//
// Spacer
2021-10-06 14:44:34 -05:00
//
Item {
height: app.spacing
}
//
2021-11-01 02:23:06 -06:00
// Visualization controls
//
2021-11-01 02:23:06 -06:00
GridLayout {
columns: 3
rowSpacing: app.spacing
columnSpacing: app.spacing
2021-11-01 02:23:06 -06:00
//
// Number of plot points slider
//
Label {
text: qsTr("Points:")
2021-11-01 02:23:06 -06:00
} Slider {
id: plotPoints
from: 0
to: 100
Layout.fillWidth: true
value: logposition(100)
visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0
onValueChanged: {
var log = logslider(value)
if (Cpp_UI_Dashboard.points !== log)
Cpp_UI_Dashboard.points = log
}
2021-11-01 02:23:06 -06:00
} Label {
text: logslider(plotPoints.value)
}
2021-11-01 02:23:06 -06:00
//
// Number of decimal places
//
Label {
text: qsTr("Decimal places:")
2021-11-01 02:23:06 -06:00
} Slider {
id: decimalPlaces
to: 6
from: 0
value: 2
Layout.fillWidth: true
onValueChanged: Cpp_UI_Dashboard.precision = value
2021-11-01 02:23:06 -06:00
} Label {
text: Cpp_UI_Dashboard.precision
}
2021-11-01 02:23:06 -06:00
//
// Number of plot points slider
//
Label {
2021-11-01 01:30:38 -06:00
text: qsTr("Widget size:")
2021-11-01 02:23:06 -06:00
} Slider {
id: widgetSize
to: 720
from: 400
value: 480
Layout.fillWidth: true
onValueChanged: widgetSizeChanged(value)
2021-11-01 02:23:06 -06:00
} Item {}
2021-10-06 14:44:34 -05:00
}
//
// Spacer
//
Item {
height: app.spacing
}
//
// Groups
//
ViewOptionsDelegate {
title: qsTr("Datasets")
icon: "qrc:/icons/group.svg"
count: Cpp_UI_Dashboard.groupCount
titles: Cpp_UI_Dashboard.groupTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setGroupVisible(index, checked)
}
//
// Multiplots
//
ViewOptionsDelegate {
title: qsTr("Multiple data plots")
icon: "qrc:/icons/multiplot.svg"
count: Cpp_UI_Dashboard.multiPlotCount
titles: Cpp_UI_Dashboard.multiPlotTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setMultiplotVisible(index, checked)
}
2021-10-21 22:37:23 -05:00
//
// LEDs
//
ViewOptionsDelegate {
title: qsTr("LED Panels")
icon: "qrc:/icons/led.svg"
count: Cpp_UI_Dashboard.ledCount
titles: Cpp_UI_Dashboard.ledTitles
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setLedVisible(index, checked)
}
2021-10-07 02:13:17 -05:00
//
// FFT
//
ViewOptionsDelegate {
title: qsTr("FFT plots")
icon: "qrc:/icons/fft.svg"
count: Cpp_UI_Dashboard.fftCount
titles: Cpp_UI_Dashboard.fftTitles
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setFFTVisible(index, checked)
}
//
// Plots
//
ViewOptionsDelegate {
title: qsTr("Data plots")
icon: "qrc:/icons/plot.svg"
count: Cpp_UI_Dashboard.plotCount
titles: Cpp_UI_Dashboard.plotTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setPlotVisible(index, checked)
}
//
// Bars
//
ViewOptionsDelegate {
title: qsTr("Bars")
icon: "qrc:/icons/bar.svg"
count: Cpp_UI_Dashboard.barCount
titles: Cpp_UI_Dashboard.barTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setBarVisible(index, checked)
}
//
// Gauges
//
ViewOptionsDelegate {
title: qsTr("Gauges")
icon: "qrc:/icons/gauge.svg"
count: Cpp_UI_Dashboard.gaugeCount
titles: Cpp_UI_Dashboard.gaugeTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setGaugeVisible(index, checked)
}
//
// Compasses
//
ViewOptionsDelegate {
title: qsTr("Compasses")
icon: "qrc:/icons/compass.svg"
count: Cpp_UI_Dashboard.compassCount
titles: Cpp_UI_Dashboard.compassTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setCompassVisible(index, checked)
}
//
// Gyroscopes
//
ViewOptionsDelegate {
title: qsTr("Gyroscopes")
icon: "qrc:/icons/gyro.svg"
count: Cpp_UI_Dashboard.gyroscopeCount
titles: Cpp_UI_Dashboard.gyroscopeTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setGyroscopeVisible(index, checked)
}
//
// Accelerometers
//
ViewOptionsDelegate {
title: qsTr("Accelerometers")
icon: "qrc:/icons/accelerometer.svg"
count: Cpp_UI_Dashboard.accelerometerCount
titles: Cpp_UI_Dashboard.accelerometerTitles
2021-09-28 14:43:06 -05:00
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setAccelerometerVisible(index, checked)
}
//
// Maps
//
ViewOptionsDelegate {
2021-10-19 16:44:17 -05:00
title: qsTr("GPS")
icon: "qrc:/icons/gps.svg"
count: Cpp_UI_Dashboard.gpsCount
titles: Cpp_UI_Dashboard.gpsTitles
onCheckedChanged: (index, checked) => Cpp_UI_Dashboard.setGpsVisible(index, checked)
}
}
}
}