6import QGroundControl.Controls
10 width: mainLayout.width
13 property var guidedController
14 property var guidedValueSlider
15 property var messageDisplay
17 property string message
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
25 property real _margins: 2
26 property bool _emergencyAction: action === guidedController.actionEmergencyStop
28 Component.onCompleted: guidedController.confirmDialog = this
30 onHideTriggerChanged: {
36 function show(immediate) {
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()
48 guidedValueSlider.visible = false
51 messageDisplay.opacity = 1.0
52 messageFadeTimer.stop()
53 messageOpacityAnimation.stop()
56 // Cancel the current pending action and notify its map indicator.
57 // Pass incomingIndicator when superseding one action with another (e.g. from confirmAction):
58 // if the old and new indicator are the same object, actionCancelled() is intentionally skipped
59 // so that a show() call made before confirmAction() is not undone (e.g. goto -> goto).
60 // Omit incomingIndicator (or pass undefined) for explicit user cancellation via the X button
61 // or auto-hide trigger, where the indicator must always be notified.
62 function confirmCancelled(incomingIndicator) {
64 if (mapIndicator && mapIndicator !== incomingIndicator) {
65 mapIndicator.actionCancelled()
67 mapIndicator = undefined
70 function _reallyShow() {
72 messageDisplay.opacity = 1.0
73 messageFadeTimer.start()
80 onTriggered: _reallyShow()
83 QGCPalette { id: qgcPal }
88 height: parent.height - 4
89 spacing: ScreenTools.defaultFontPixelWidth
96 control.visible = false
97 var sliderOutputValue = 0
98 if (guidedValueSlider.visible) {
99 sliderOutputValue = guidedValueSlider.getOutputValue()
100 guidedValueSlider.visible = false
103 let success = guidedController.executeAction(control.action, control.actionData, sliderOutputValue, control.optionChecked)
106 mapIndicator.actionConfirmed()
108 mapIndicator.actionCancelled()
110 mapIndicator = undefined
122 Layout.alignment: Qt.AlignTop
124 height: ScreenTools.defaultFontPixelHeight * 0.5
125 source: "/res/XDelete.svg"
126 fillMode: Image.PreserveAspectFit
131 onClicked: confirmCancelled()