QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ConfigRow.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7/// One row of a row-based setup page: a separator, an identity column (status dot, title, parameter names, then any
8/// children) and the row's cells, which wrap instead of widening the page.
9ColumnLayout {
10 id: control
11
12 property alias title: titleLabel.text
13 property var params: []
14 property bool active: false
15 property color activeColor: qgcPal.colorGreen
16 property bool showSeparator: false
17
18 default property alias identityData: identityColumn.data
19 property alias cellsData: cellFlow.data
20
21 readonly property real _cellPadding: ScreenTools.defaultFontPixelWidth * 1.5
22
23 Layout.fillWidth: true
24 spacing: ScreenTools.defaultFontPixelHeight * 0.5
25
26 QGCPalette { id: qgcPal }
27
28 Rectangle {
29 objectName: "configRowSeparator"
30 Layout.fillWidth: true
31 implicitHeight: 1
32 color: qgcPal.borderSubtle
33 visible: control.showSeparator
34 }
35
36 RowLayout {
37 Layout.fillWidth: true
38 spacing: ScreenTools.defaultFontPixelHeight * 0.5
39
40 ColumnLayout {
41 id: identityColumn
42 Layout.alignment: Qt.AlignTop
43 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 30
44 Layout.maximumWidth: Layout.preferredWidth
45 Layout.topMargin: control._cellPadding
46 spacing: ScreenTools.defaultFontPixelHeight * 0.25
47
48 RowLayout {
49 spacing: ScreenTools.defaultFontPixelWidth
50
51 Rectangle {
52 implicitWidth: ScreenTools.defaultFontPixelHeight * 0.5
53 implicitHeight: implicitWidth
54 radius: implicitWidth / 2
55 color: control.active ? control.activeColor : "transparent"
56 border.color: control.active ? color : qgcPal.textSecondary
57 }
58
59 QGCLabel {
60 id: titleLabel
61 Layout.fillWidth: true
62 wrapMode: Text.WordWrap
63 font.bold: true
64 font.capitalization: Font.AllUppercase
65 font.letterSpacing: ScreenTools.defaultFontPixelWidth * 0.1
66 }
67 }
68
69 Flow {
70 Layout.fillWidth: true
71 spacing: ScreenTools.defaultFontPixelWidth
72
73 Repeater {
74 model: control.params
75
76 QGCLabel {
77 text: modelData
78 font.family: ScreenTools.fixedFontFamily
79 font.pointSize: ScreenTools.smallFontPointSize
80 color: qgcPal.textSecondary
81
82 required property string modelData
83 }
84 }
85 }
86 }
87
88 // Cells wrap instead of widening the page, so the column only needs its widest single cell
89 Flow {
90 id: cellFlow
91 Layout.alignment: Qt.AlignTop
92 Layout.fillWidth: true
93 Layout.minimumWidth: _widestChildWidth
94 Layout.preferredWidth: _widestChildWidth
95 spacing: ScreenTools.defaultFontPixelHeight * 0.5
96
97 readonly property real _widestChildWidth: {
98 let widest = 0
99 for (let i = 0; i < children.length; i++) {
100 if (children[i].visible) {
101 widest = Math.max(widest, children[i].implicitWidth)
102 }
103 }
104 return widest
105 }
106 }
107 }
108}