-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTrackingPanelQuickCommands.qml
More file actions
166 lines (146 loc) · 6.62 KB
/
TrackingPanelQuickCommands.qml
File metadata and controls
166 lines (146 loc) · 6.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import "qrc:/gcsStyle" as GcsStyle
import "./components" as Components
Rectangle {
id: root
property var commandDrone: null // The drone that the user has selected to command
property string activeAction: "" // The action that the user is currently performing
width: 70 // Width of the panel
height: commandColumn.implicitHeight + 6 // Height of the panel
color: GcsStyle.PanelStyle.primaryColor // Color of the panel
radius: GcsStyle.PanelStyle.cornerRadius // Radius of the panel
border.color: GcsStyle.PanelStyle.defaultBorderColor // Border color of the panel
border.width: GcsStyle.PanelStyle.defaultBorderWidth // Border width of the panel
ListModel {
id: buttonModel
ListElement { label: "Arm"; icon: "qrc:/resources/armIcon.svg"; action: "arm" }
ListElement { label: "Guided"; icon: "qrc:/resources/guidedModeIcon.svg"; action: "guided" }
ListElement { label: "Takeoff"; icon: "qrc:/resources/takeoffIcon.svg"; action: "takeoff" }
ListElement { label: "Return"; icon: "qrc:/resources/returnHomeIcon.svg"; action: "return" }
}
// Column layout for the buttons
Column {
id: commandColumn
anchors.centerIn: parent
// Repeater that iterates over the buttonModel and creates a column for each button
Repeater {
model: buttonModel
delegate: Column {
width: root.width
Item {
width: parent.width
height: GcsStyle.PanelStyle.buttonSize + 14
opacity: root.commandDrone !== null ? 1.0 : 0.35
property bool hovered: false
property bool isActive: root.activeAction === model.action
// Hover/active highlight
Rectangle {
anchors.centerIn: parent
width: parent.width - 10
height: parent.height - 6
radius: 8
color: parent.isActive
? GcsStyle.PanelStyle.listItemSelectedColor
: parent.hovered
? GcsStyle.PanelStyle.listItemHoverColor
: "transparent"
}
// Button icon and label
ColumnLayout {
anchors.centerIn: parent
spacing: 2
Image {
Layout.alignment: Qt.AlignHCenter
source: model.icon
sourceSize.width: GcsStyle.PanelStyle.iconSize
sourceSize.height: GcsStyle.PanelStyle.iconSize
}
Text {
Layout.alignment: Qt.AlignHCenter
text: model.label
color: GcsStyle.PanelStyle.textOnPrimaryColor
font.pixelSize: GcsStyle.PanelStyle.fontSizeXXS
font.family: GcsStyle.PanelStyle.fontFamily
}
}
// Hover enabler and click handler for each button
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.hovered = true
onExited: parent.hovered = false
onClicked: {
if (!root.commandDrone) return
root.activeAction = model.action
switch (model.action) {
case "arm": armConfirmation.open(); break
case "guided": guidedConfirmation.open(); break
case "takeoff": takeoffConfirmation.open(); break
case "return": returnConfirmation.open(); break
}
}
}
}
// Divider line between buttons
Rectangle {
width: parent.width * 0.7
height: 1
anchors.horizontalCenter: parent.horizontalCenter
color: GcsStyle.PanelStyle.defaultBorderColor
visible: index < buttonModel.count - 1 // Only show the divider between buttons, not after the last one
}
}
}
}
// Confirmation popups for each action
Components.UniversalPopup {
id: armConfirmation
onClosed: root.activeAction = ""
popupTitle: "Arm the UAV?"
popupMessage: root.commandDrone && root.commandDrone.name
? "Are you sure you want to arm " + root.commandDrone.name + "?"
: "No UAV selected"
onAccepted: {
if (root.commandDrone)
droneController.sendArm(root.commandDrone.xbeeAddress, true)
}
}
Components.UniversalPopup {
id: guidedConfirmation
onClosed: root.activeAction = ""
popupTitle: "Set UAV to Guided Mode"
popupMessage: root.commandDrone && root.commandDrone.name
? "Are you sure you want to set " + root.commandDrone.name + " to guided mode?"
: "No UAV selected"
onAccepted: {
if (root.commandDrone)
droneController.sendGuidedMode(root.commandDrone.xbeeAddress, true)
}
}
Components.UniversalPopup {
id: takeoffConfirmation
onClosed: root.activeAction = ""
popupTitle: "Takeoff"
popupMessage: root.commandDrone && root.commandDrone.name
? "Are you sure you want to takeoff " + root.commandDrone.name + "?"
: "No UAV selected"
onAccepted: {
if (root.commandDrone)
droneController.sendTakeoffCmd(root.commandDrone.xbeeAddress, true)
}
}
Components.UniversalPopup {
id: returnConfirmation
onClosed: root.activeAction = ""
popupTitle: "Return Home"
popupMessage: root.commandDrone && root.commandDrone.name
? "Send " + root.commandDrone.name + " back to home location?"
: "No UAV selected"
onAccepted: {
console.log("[TrackingPanelQuickCommands] Return Home: backend not yet implemented")
}
}
}