QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ToolStrip.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7Rectangle {
8 id: _root
9 color: qgcPal.windowTransparent
10 width: ScreenTools.defaultFontPixelWidth * 7
11 height: Math.min(maxHeight, toolStripColumn.height + (flickable.anchors.margins * 2))
12 radius: ScreenTools.defaultFontPixelWidth / 2
13
14 property alias model: repeater.model
15 property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter
16 property var fontSize: ScreenTools.smallFontPointSize
17
18 property var _dropPanel: dropPanel
19
20 function simulateClick(buttonIndex) {
21 var button = toolStripColumn.children[buttonIndex]
22 if (button.checkable) {
23 button.checked = !button.checked
24 }
25 button.clicked()
26 }
27
28 signal dropped(int index)
29
30 DeadMouseArea {
31 anchors.fill: parent
32 }
33
34 QGCFlickable {
35 id: flickable
36 anchors.margins: ScreenTools.defaultFontPixelWidth * 0.4
37 anchors.fill: parent
38 contentHeight: toolStripColumn.height
39 flickableDirection: Flickable.VerticalFlick
40 clip: true
41
42 Column {
43 id: toolStripColumn
44 anchors.left: parent.left
45 anchors.right: parent.right
46 spacing: ScreenTools.defaultFontPixelWidth * 0.25
47
48 Repeater {
49 id: repeater
50
51 ToolStripHoverButton {
52 id: buttonTemplate
53 anchors.left: toolStripColumn.left
54 anchors.right: toolStripColumn.right
55 height: width
56 radius: ScreenTools.defaultFontPixelWidth / 2
57 fontPointSize: _root.fontSize
58 toolStripAction: modelData
59 dropPanel: _dropPanel
60 onDropped: (index) => _root.dropped(index)
61
62 onCheckedChanged: {
63 // We deal with exclusive check state manually since usinug autoExclusive caused all sorts of crazt problems
64 if (checked) {
65 for (var i=0; i<repeater.count; i++) {
66 if (i != index) {
67 var button = repeater.itemAt(i)
68 if (button.checked) {
69 button.checked = false
70 }
71 }
72 }
73 }
74 }
75 }
76 }
77 }
78 }
79
80 ToolStripDropPanel {
81 id: dropPanel
82 toolStrip: _root
83 }
84}