QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GuidedActionConfirm.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Item {
9 id: control
10 width: mainLayout.width
11 visible: false
12
13 property var guidedController
14 property var guidedValueSlider
15 property var messageDisplay
16 property string title
17 property string message
18 property int action
19 property var actionData
20 property bool hideTrigger: false
21 property var mapIndicator
22 property alias optionText: optionCheckBox.text
23 property alias optionChecked: optionCheckBox.checked
24
25 property real _margins: 2
26 property bool _emergencyAction: action === guidedController.actionEmergencyStop
27
28 Component.onCompleted: guidedController.confirmDialog = this
29
30 onHideTriggerChanged: {
31 if (hideTrigger) {
32 confirmCancelled()
33 }
34 }
35
36 function show(immediate) {
37 if (immediate) {
38 _reallyShow()
39 } else {
40 // We delay showing the confirmation for a small amount in order for any other state
41 // changes to propogate through the system. This way only the final state shows up.
42 visibleTimer.restart()
43 }
44 }
45
46 function confirmCancelled() {
47 guidedValueSlider.visible = false
48 visible = false
49 hideTrigger = false
50 visibleTimer.stop()
51 messageDisplay.opacity = 1.0
52 messageFadeTimer.stop()
53 messageOpacityAnimation.stop()
54 if (mapIndicator) {
55 mapIndicator.actionCancelled()
56 mapIndicator = undefined
57 }
58 }
59
60 function _reallyShow() {
61 visible = true
62 messageDisplay.opacity = 1.0
63 messageFadeTimer.start()
64 }
65
66 Timer {
67 id: visibleTimer
68 interval: 1000
69 repeat: false
70 onTriggered: _reallyShow()
71 }
72
73 QGCPalette { id: qgcPal }
74
75 RowLayout {
76 id: mainLayout
77 y: 2
78 height: parent.height - 4
79 spacing: ScreenTools.defaultFontPixelWidth
80
81 QGCDelayButton {
82 text: control.title
83 enabled: true
84
85 onActivated: {
86 control.visible = false
87 var sliderOutputValue = 0
88 if (guidedValueSlider.visible) {
89 sliderOutputValue = guidedValueSlider.getOutputValue()
90 guidedValueSlider.visible = false
91 }
92 hideTrigger = false
93 guidedController.executeAction(control.action, control.actionData, sliderOutputValue, control.optionChecked)
94 if (mapIndicator) {
95 mapIndicator.actionConfirmed()
96 mapIndicator = undefined
97 }
98 }
99 }
100
101 QGCCheckBox {
102 id: optionCheckBox
103 visible: text !== ""
104 }
105
106 QGCColoredImage {
107 id: closeButton
108 Layout.alignment: Qt.AlignTop
109 width: height
110 height: ScreenTools.defaultFontPixelHeight * 0.5
111 source: "/res/XDelete.svg"
112 fillMode: Image.PreserveAspectFit
113 color: qgcPal.text
114
115 QGCMouseArea {
116 fillItem: parent
117 onClicked: confirmCancelled()
118 }
119 }
120 }
121}