166 lines
5.3 KiB
QML
Raw Normal View History

/*
* Copyright (c) 2020-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.
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
2020-12-27 17:21:19 -06:00
import QtQuick.Controls 2.12
2020-12-26 01:30:18 -06:00
import "../Widgets" as Widgets
Control {
2020-12-27 17:21:19 -06:00
id: root
background: Rectangle {
color: app.windowBackgroundColor
}
2020-12-26 01:30:18 -06:00
//
2020-12-27 17:21:19 -06:00
// Custom properties
2020-12-26 01:30:18 -06:00
//
2020-12-30 16:11:51 -06:00
readonly property int minimumWidgetSize: 320
2020-12-25 15:33:12 -06:00
2020-12-27 00:00:31 -06:00
//
// Group/dataset updating
//
Connections {
2021-01-22 12:46:11 -05:00
target: CppWidgetProvider
2020-12-27 00:00:31 -06:00
function onDataChanged() {
// Generate accelerometer widgets
2021-01-22 12:46:11 -05:00
if (accGenerator.model !== CppWidgetProvider.accelerometerGroupCount()) {
2020-12-27 00:00:31 -06:00
accGenerator.model = 0
2021-01-22 12:46:11 -05:00
accGenerator.model = CppWidgetProvider.accelerometerGroupCount()
2020-12-27 00:00:31 -06:00
}
2020-12-26 22:53:16 -06:00
2020-12-27 00:00:31 -06:00
// Generate gyro widgets
2021-01-22 12:46:11 -05:00
if (gyroGenerator.model !== CppWidgetProvider.gyroGroupCount()) {
2020-12-27 00:00:31 -06:00
gyroGenerator.model = 0
2021-01-22 12:46:11 -05:00
gyroGenerator.model = CppWidgetProvider.gyroGroupCount()
2020-12-27 00:00:31 -06:00
}
2020-12-26 22:53:16 -06:00
2020-12-27 00:00:31 -06:00
// Generate bar widgets
2021-01-22 12:46:11 -05:00
if (barGenerator.model !== CppWidgetProvider.barDatasetCount()) {
2020-12-27 00:00:31 -06:00
barGenerator.model = 0
2021-01-22 12:46:11 -05:00
barGenerator.model = CppWidgetProvider.barDatasetCount()
2020-12-27 00:00:31 -06:00
}
2020-12-26 22:53:16 -06:00
2020-12-27 00:00:31 -06:00
// Generate map widgets
2021-01-22 12:46:11 -05:00
if (mapGenerator.model !== CppWidgetProvider.mapGroupCount()) {
2020-12-27 00:00:31 -06:00
mapGenerator.model = 0
2021-01-22 12:46:11 -05:00
mapGenerator.model = CppWidgetProvider.mapGroupCount()
2020-12-27 00:00:31 -06:00
}
2020-12-26 22:53:16 -06:00
}
2020-12-27 00:00:31 -06:00
}
//
// UI inside scrollview
//
ScrollView {
z: 0
id: _sv
clip: false
contentWidth: -1
anchors.fill: parent
2020-12-30 16:11:51 -06:00
anchors.rightMargin: 5
2020-12-27 17:21:19 -06:00
anchors.margins: app.spacing * 1.5
2020-12-27 00:00:31 -06:00
ColumnLayout {
2020-12-30 16:11:51 -06:00
x: 0
width: _sv.width - 15
2020-12-27 00:00:31 -06:00
GridLayout {
Layout.fillWidth: true
Layout.fillHeight: true
rowSpacing: app.spacing
columnSpacing: app.spacing
2020-12-27 17:21:19 -06:00
columns: Math.floor(_sv.width / (root.minimumWidgetSize + 2 * app.spacing))
2020-12-27 00:00:31 -06:00
Repeater {
2020-12-27 20:50:17 -06:00
id: gyroGenerator
2020-12-27 00:00:31 -06:00
delegate: Item {
Layout.fillWidth: true
Layout.fillHeight: true
2020-12-27 17:21:19 -06:00
Layout.minimumWidth: root.minimumWidgetSize
Layout.minimumHeight: root.minimumWidgetSize
2020-12-27 00:00:31 -06:00
2020-12-27 20:50:17 -06:00
Widgets.GyroDelegate {
groupIndex: index
2020-12-27 00:00:31 -06:00
anchors.fill: parent
}
}
}
Repeater {
2020-12-27 20:50:17 -06:00
id: accGenerator
2020-12-27 00:00:31 -06:00
delegate: Item {
Layout.fillWidth: true
Layout.fillHeight: true
2020-12-27 17:21:19 -06:00
Layout.minimumWidth: root.minimumWidgetSize
Layout.minimumHeight: root.minimumWidgetSize
2020-12-27 20:50:17 -06:00
Widgets.AccelerometerDelegate {
groupIndex: index
2020-12-27 17:21:19 -06:00
anchors.fill: parent
}
2020-12-27 00:00:31 -06:00
}
}
Repeater {
2020-12-27 20:50:17 -06:00
id: mapGenerator
2020-12-27 00:00:31 -06:00
delegate: Item {
Layout.fillWidth: true
Layout.fillHeight: true
2020-12-27 17:21:19 -06:00
Layout.minimumWidth: root.minimumWidgetSize
Layout.minimumHeight: root.minimumWidgetSize
2020-12-27 00:00:31 -06:00
2020-12-27 20:50:17 -06:00
Widgets.MapDelegate {
groupIndex: index
2020-12-27 00:00:31 -06:00
anchors.fill: parent
}
}
}
Repeater {
2020-12-27 20:50:17 -06:00
id: barGenerator
2020-12-27 00:00:31 -06:00
delegate: Item {
Layout.fillWidth: true
Layout.fillHeight: true
2020-12-27 17:21:19 -06:00
Layout.minimumWidth: root.minimumWidgetSize
Layout.minimumHeight: root.minimumWidgetSize
2020-12-27 00:00:31 -06:00
2020-12-27 20:50:17 -06:00
Widgets.BarDelegate {
datasetIndex: index
2020-12-27 00:00:31 -06:00
anchors.fill: parent
2020-12-27 17:21:19 -06:00
}
2020-12-27 00:00:31 -06:00
}
}
}
2020-12-26 22:53:16 -06:00
2020-12-27 00:00:31 -06:00
Item {
Layout.minimumHeight: 10
}
2020-12-26 22:53:16 -06:00
}
}
}