Commit 438f76f2 authored by Don Gagne's avatar Don Gagne

Auto-Dismiss guided confirm dialog it state changes

parent d2ef6d01
...@@ -510,6 +510,7 @@ QGCView { ...@@ -510,6 +510,7 @@ QGCView {
GuidedActionsController { GuidedActionsController {
id: guidedActionsController id: guidedActionsController
missionController: flyMissionController missionController: flyMissionController
confirmDialog: guidedActionConfirm
z: _flightVideoPipControl.z + 1 z: _flightVideoPipControl.z + 1
onShowStartMissionChanged: { onShowStartMissionChanged: {
...@@ -523,14 +524,6 @@ QGCView { ...@@ -523,14 +524,6 @@ QGCView {
confirmAction(actionResumeMission) confirmAction(actionResumeMission)
} }
} }
onShowConfirmAction: {
guidedActionConfirm.title = title
guidedActionConfirm.message = message
guidedActionConfirm.action = action
guidedActionConfirm.actionData = actionData
guidedActionConfirm.visible = true
}
} }
GuidedActionConfirm { GuidedActionConfirm {
......
...@@ -34,9 +34,18 @@ Rectangle { ...@@ -34,9 +34,18 @@ Rectangle {
property alias message: messageText.text property alias message: messageText.text
property int action property int action
property var actionData property var actionData
property bool hideTrigger: false
property real _margins: ScreenTools.defaultFontPixelWidth property real _margins: ScreenTools.defaultFontPixelWidth
onHideTriggerChanged: {
if (hideTrigger) {
hideTrigger = false
altitudeSlider.visible = false
visible = false
}
}
QGCPalette { id: qgcPal } QGCPalette { id: qgcPal }
Column { Column {
...@@ -74,12 +83,14 @@ Rectangle { ...@@ -74,12 +83,14 @@ Rectangle {
_root.actionData = altitudeSlider.getValue() _root.actionData = altitudeSlider.getValue()
altitudeSlider.visible = false altitudeSlider.visible = false
} }
hideTrigger = false
guidedController.executeAction(_root.action, _root.actionData) guidedController.executeAction(_root.action, _root.actionData)
} }
onReject: { onReject: {
altitudeSlider.visible = false altitudeSlider.visible = false
_root.visible = false _root.visible = false
hideTrigger = false
} }
} }
} }
......
...@@ -28,8 +28,7 @@ Item { ...@@ -28,8 +28,7 @@ Item {
id: _root id: _root
property var missionController property var missionController
property var confirmDialog
signal showConfirmAction(string title, string message, int action, var actionData)
readonly property string emergencyStopTitle: qsTr("Emergency Stop") readonly property string emergencyStopTitle: qsTr("Emergency Stop")
readonly property string armTitle: qsTr("Arm") readonly property string armTitle: qsTr("Arm")
...@@ -79,6 +78,7 @@ Item { ...@@ -79,6 +78,7 @@ Item {
readonly property int actionPause: 15 readonly property int actionPause: 15
property bool showEmergenyStop: !_hideEmergenyStop && _activeVehicle && _vehicleArmed && _activeVehicle.flying property bool showEmergenyStop: !_hideEmergenyStop && _activeVehicle && _vehicleArmed && _activeVehicle.flying
property bool showArm: _activeVehicle && !_vehicleArmed
property bool showDisarm: _activeVehicle && _vehicleArmed && !_activeVehicle.flying property bool showDisarm: _activeVehicle && _vehicleArmed && !_activeVehicle.flying
property bool showRTL: _activeVehicle && _vehicleArmed && _activeVehicle.guidedModeSupported && _activeVehicle.flying && !_vehicleInRTLMode property bool showRTL: _activeVehicle && _vehicleArmed && _activeVehicle.guidedModeSupported && _activeVehicle.flying && !_vehicleInRTLMode
property bool showTakeoff: _activeVehicle && _activeVehicle.guidedModeSupported && !_activeVehicle.flying && !_activeVehicle.fixedWing property bool showTakeoff: _activeVehicle && _activeVehicle.guidedModeSupported && !_activeVehicle.flying && !_activeVehicle.fixedWing
...@@ -91,8 +91,6 @@ Item { ...@@ -91,8 +91,6 @@ Item {
property bool showLandAbort: _activeVehicle && _activeVehicle.flying && _activeVehicle.fixedWing property bool showLandAbort: _activeVehicle && _activeVehicle.flying && _activeVehicle.fixedWing
property bool showGotoLocation: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying property bool showGotoLocation: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
onShowStartMissionChanged: console.log(showStartMission, _activeVehicle, _missionAvailable, _missionActive, _vehicleArmed, _vehicleInLandMode, _vehicleInRTLMode)
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property string _flightMode: _activeVehicle ? _activeVehicle.flightMode : "" property string _flightMode: _activeVehicle ? _activeVehicle.flightMode : ""
property bool _missionAvailable: missionController.containsItems property bool _missionAvailable: missionController.containsItems
...@@ -116,81 +114,95 @@ Item { ...@@ -116,81 +114,95 @@ Item {
// Called when an action is about to be executed in order to confirm // Called when an action is about to be executed in order to confirm
function confirmAction(actionCode, actionData) { function confirmAction(actionCode, actionData) {
var title confirmDialog.action = actionCode
var message confirmDialog.actionData = actionData
_actionData = actionData _actionData = actionData
switch (actionCode) { switch (actionCode) {
case actionArm: case actionArm:
if (_activeVehicle.flying) { if (_activeVehicle.flying) {
return return
} }
title = armTitle confirmDialog.title = armTitle
message = armMessage confirmDialog.message = armMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showArm })
break; break;
case actionDisarm: case actionDisarm:
if (_activeVehicle.flying) { if (_activeVehicle.flying) {
return return
} }
title = disarmTitle confirmDialog.title = disarmTitle
message = disarmMessage confirmDialog.message = disarmMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showDisarm })
break; break;
case actionEmergencyStop: case actionEmergencyStop:
title = emergencyStopTitle confirmDialog.title = emergencyStopTitle
message = emergencyStopMessage confirmDialog.message = emergencyStopMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showEmergenyStop })
break; break;
case actionTakeoff: case actionTakeoff:
title = takeoffTitle confirmDialog.title = takeoffTitle
message = takeoffMessage confirmDialog.message = takeoffMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showTakeoff })
break; break;
case actionStartMission: case actionStartMission:
title = startMissionTitle confirmDialog.title = startMissionTitle
message = startMissionMessage confirmDialog.message = startMissionMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showStartMission })
break; break;
case actionResumeMission: case actionResumeMission:
title = resumeMissionTitle confirmDialog.title = resumeMissionTitle
message = resumeMissionMessage confirmDialog.message = resumeMissionMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showResumeMission })
break; break;
case actionResumeMissionReady: case actionResumeMissionReady:
title = resumeMissionTitle confirmDialog.title = resumeMissionTitle
message = resumeMissionReadyMessage confirmDialog.message = resumeMissionReadyMessage
confirmDialog.hideTrigger = false
break; break;
case actionLand: case actionLand:
title = landTitle confirmDialog.title = landTitle
message = landMessage confirmDialog.message = landMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showLand })
break; break;
case actionRTL: case actionRTL:
title = rtlTitle confirmDialog.title = rtlTitle
message = rtlMessage confirmDialog.message = rtlMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showRTL })
break; break;
case actionChangeAlt: case actionChangeAlt:
title = changeAltTitle confirmDialog.title = changeAltTitle
message = changeAltMessage confirmDialog.message = changeAltMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showChangeAlt })
break; break;
case actionGoto: case actionGoto:
title = gotoTitle confirmDialog.title = gotoTitle
message = gotoMessage confirmDialog.message = gotoMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showGotoLocation })
break; break;
case actionSetWaypoint: case actionSetWaypoint:
title = setWaypointTitle confirmDialog.title = setWaypointTitle
message = setWaypointMessage confirmDialog.message = setWaypointMessage
break; break;
case actionOrbit: case actionOrbit:
title = orbitTitle confirmDialog.title = orbitTitle
message = orbitMessage confirmDialog.message = orbitMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showOrbit })
break; break;
case actionLandAbort: case actionLandAbort:
title = landAbortTitle confirmDialog.title = landAbortTitle
message = landAbortMessage confirmDialog.message = landAbortMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showLandAbort })
break; break;
case actionPause: case actionPause:
title = pauseTitle confirmDialog.title = pauseTitle
message = pauseMessage confirmDialog.message = pauseMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showPause })
break; break;
default: default:
console.warn("Unknown actionCode", actionCode) console.warn("Unknown actionCode", actionCode)
return return
} }
showConfirmAction(title, message, actionCode, actionData) confirmDialog.visible = true
} }
// Executes the specified action // Executes the specified action
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment