Unverified Commit d95cb35f authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8718 from DonLakeFlyer/FlyViewEncapsulation

Fly View: Move business logic inside controls
parents 0bf152cb 4ad2c516
...@@ -194,6 +194,7 @@ ...@@ -194,6 +194,7 @@
<file alias="QGroundControl/FlightDisplay/FlightDisplayViewMap.qml">src/FlightDisplay/FlightDisplayViewMap.qml</file> <file alias="QGroundControl/FlightDisplay/FlightDisplayViewMap.qml">src/FlightDisplay/FlightDisplayViewMap.qml</file>
<file alias="QGroundControl/FlightDisplay/FlightDisplayViewVideo.qml">src/FlightDisplay/FlightDisplayViewVideo.qml</file> <file alias="QGroundControl/FlightDisplay/FlightDisplayViewVideo.qml">src/FlightDisplay/FlightDisplayViewVideo.qml</file>
<file alias="QGroundControl/FlightDisplay/FlightDisplayViewWidgets.qml">src/FlightDisplay/FlightDisplayViewWidgets.qml</file> <file alias="QGroundControl/FlightDisplay/FlightDisplayViewWidgets.qml">src/FlightDisplay/FlightDisplayViewWidgets.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolStrip.qml">src/FlightDisplay/FlyViewToolStrip.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionConfirm.qml">src/FlightDisplay/GuidedActionConfirm.qml</file> <file alias="QGroundControl/FlightDisplay/GuidedActionConfirm.qml">src/FlightDisplay/GuidedActionConfirm.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionList.qml">src/FlightDisplay/GuidedActionList.qml</file> <file alias="QGroundControl/FlightDisplay/GuidedActionList.qml">src/FlightDisplay/GuidedActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionsController.qml">src/FlightDisplay/GuidedActionsController.qml</file> <file alias="QGroundControl/FlightDisplay/GuidedActionsController.qml">src/FlightDisplay/GuidedActionsController.qml</file>
......
...@@ -39,7 +39,6 @@ Item { ...@@ -39,7 +39,6 @@ Item {
} }
} }
property alias guidedController: guidedActionsController
property bool activeVehicleJoystickEnabled: activeVehicle ? activeVehicle.joystickEnabled : false property bool activeVehicleJoystickEnabled: activeVehicle ? activeVehicle.joystickEnabled : false
property bool mainIsMap: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) : true property bool mainIsMap: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) : true
property bool isBackgroundDark: mainIsMap ? (mainWindow.flightDisplayMap ? mainWindow.flightDisplayMap.isSatelliteMap : true) : true property bool isBackgroundDark: mainIsMap ? (mainWindow.flightDisplayMap ? mainWindow.flightDisplayMap.isSatelliteMap : true) : true
...@@ -54,17 +53,12 @@ Item { ...@@ -54,17 +53,12 @@ Item {
property real _margins: ScreenTools.defaultFontPixelWidth / 2 property real _margins: ScreenTools.defaultFontPixelWidth / 2
property real _pipSize: mainWindow.width * 0.2 property real _pipSize: mainWindow.width * 0.2
property alias _guidedController: guidedActionsController property alias _guidedController: guidedActionsController
property alias _altitudeSlider: altitudeSlider property alias _guidedConfirm: guidedActionConfirm
property alias _guidedList: guidedActionList
property alias _guidedSlider: altitudeSlider
property real _guidedZOrder: _flightVideoPipControl.z + 1
property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75 property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
readonly property var _dynamicCameras: activeVehicle ? activeVehicle.dynamicCameras : null
readonly property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
readonly property real _defaultRoll: 0
readonly property real _defaultPitch: 0
readonly property real _defaultHeading: 0
readonly property real _defaultAltitudeAMSL: 0
readonly property real _defaultGroundSpeed: 0
readonly property real _defaultAirSpeed: 0
readonly property string _mapName: "FlightDisplayView" readonly property string _mapName: "FlightDisplayView"
readonly property string _showMapBackgroundKey: "/showMapBackground" readonly property string _showMapBackgroundKey: "/showMapBackground"
readonly property string _mainIsMapKey: "MainFlyWindowIsMap" readonly property string _mainIsMapKey: "MainFlyWindowIsMap"
...@@ -129,16 +123,16 @@ Item { ...@@ -129,16 +123,16 @@ Item {
Connections { Connections {
target: mainWindow target: mainWindow
onArmVehicle: guidedController.confirmAction(guidedController.actionArm) onArmVehicle: _guidedController.confirmAction(_guidedController.actionArm)
onDisarmVehicle: { onDisarmVehicle: {
if (guidedController.showEmergenyStop) { if (_guidedController.showEmergenyStop) {
guidedController.confirmAction(guidedController.actionEmergencyStop) _guidedController.confirmAction(_guidedController.actionEmergencyStop)
} else { } else {
guidedController.confirmAction(guidedController.actionDisarm) _guidedController.confirmAction(_guidedController.actionDisarm)
} }
} }
onVtolTransitionToFwdFlight: guidedController.confirmAction(guidedController.actionVtolTransitionToFwdFlight) onVtolTransitionToFwdFlight: _guidedController.confirmAction(_guidedController.actionVtolTransitionToFwdFlight)
onVtolTransitionToMRFlight: guidedController.confirmAction(guidedController.actionVtolTransitionToMRFlight) onVtolTransitionToMRFlight: _guidedController.confirmAction(_guidedController.actionVtolTransitionToMRFlight)
onFlightDisplayMapChanged: setStates() onFlightDisplayMapChanged: setStates()
} }
...@@ -241,7 +235,7 @@ Item { ...@@ -241,7 +235,7 @@ Item {
text: qsTr("Resume Mission From Waypoint %1").arg(_guidedController._resumeMissionIndex) text: qsTr("Resume Mission From Waypoint %1").arg(_guidedController._resumeMissionIndex)
onClicked: { onClicked: {
guidedController.executeAction(_guidedController.actionResumeMission, null, null) _guidedController.executeAction(_guidedController.actionResumeMission, null, null)
hideDialog() hideDialog()
} }
} }
...@@ -559,141 +553,28 @@ Item { ...@@ -559,141 +553,28 @@ Item {
property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized
} }
ToolStrip { FlyViewToolStrip {
visible: (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen id: toolStrip
id: toolStrip anchors.leftMargin: isInstrumentRight() ? _toolsMargin : undefined
anchors.left: isInstrumentRight() ? _mapAndVideo.left : undefined
anchors.leftMargin: isInstrumentRight() ? _toolsMargin : undefined anchors.rightMargin: isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
anchors.left: isInstrumentRight() ? _mapAndVideo.left : undefined anchors.right: isInstrumentRight() ? undefined : _mapAndVideo.right
anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth anchors.topMargin: _toolsMargin
anchors.right: isInstrumentRight() ? undefined : _mapAndVideo.right anchors.top: parent.top
anchors.topMargin: _toolsMargin z: _mapAndVideo.z + 4
anchors.top: parent.top maxHeight: parent.height - toolStrip.y + (_flightVideo.visible ? (_flightVideo.y - parent.height) : 0)
z: _mapAndVideo.z + 4 guidedActionsController: _guidedController
maxHeight: parent.height - toolStrip.y + (_flightVideo.visible ? (_flightVideo.y - parent.height) : 0) guidedActionList: _guidedList
title: qsTr("Fly") preFlightCheckList: checklistDropPanel
visible: (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property var _actionModel: [
{
title: _guidedController.startMissionTitle,
text: _guidedController.startMissionMessage,
action: _guidedController.actionStartMission,
visible: _guidedController.showStartMission
},
{
title: _guidedController.continueMissionTitle,
text: _guidedController.continueMissionMessage,
action: _guidedController.actionContinueMission,
visible: _guidedController.showContinueMission
},
{
title: _guidedController.changeAltTitle,
text: _guidedController.changeAltMessage,
action: _guidedController.actionChangeAlt,
visible: _guidedController.showChangeAlt
},
{
title: _guidedController.landAbortTitle,
text: _guidedController.landAbortMessage,
action: _guidedController.actionLandAbort,
visible: _guidedController.showLandAbort
}
]
model: [
{
name: "Checklist",
iconSource: "/qmlimages/check.svg",
buttonVisible: _useChecklist,
buttonEnabled: _useChecklist && activeVehicle && !activeVehicle.armed,
},
{
name: _guidedController.takeoffTitle,
iconSource: "/res/takeoff.svg",
buttonVisible: _guidedController.showTakeoff || !_guidedController.showLand,
buttonEnabled: _guidedController.showTakeoff,
action: _guidedController.actionTakeoff
},
{
name: _guidedController.landTitle,
iconSource: "/res/land.svg",
buttonVisible: _guidedController.showLand && !_guidedController.showTakeoff,
buttonEnabled: _guidedController.showLand,
action: _guidedController.actionLand
},
{
name: _guidedController.rtlTitle,
iconSource: "/res/rtl.svg",
buttonVisible: true,
buttonEnabled: _guidedController.showRTL,
action: _guidedController.actionRTL
},
{
name: _guidedController.pauseTitle,
iconSource: "/res/pause-mission.svg",
buttonVisible: _guidedController.showPause,
buttonEnabled: _guidedController.showPause,
action: _guidedController.actionPause
},
{
name: qsTr("Action"),
iconSource: "/res/action.svg",
buttonVisible: _anyActionAvailable,
buttonEnabled: true,
action: -1
}
]
onClicked: {
if(index === 0) {
checklistDropPanel.open()
} else {
guidedActionsController.closeAll()
var action = model[index].action
if (action === -1) {
guidedActionList.model = _actionModel
guidedActionList.visible = true
} else {
_guidedController.confirmAction(action)
}
}
}
} }
GuidedActionsController { GuidedActionsController {
id: guidedActionsController id: guidedActionsController
missionController: _missionController missionController: _missionController
confirmDialog: guidedActionConfirm confirmDialog: _guidedConfirm
actionList: guidedActionList actionList: _guidedList
altitudeSlider: _altitudeSlider altitudeSlider: _guidedSlider
z: _flightVideoPipControl.z + 1
onShowStartMissionChanged: {
if (showStartMission) {
confirmAction(actionStartMission)
}
}
onShowContinueMissionChanged: {
if (showContinueMission) {
confirmAction(actionContinueMission)
}
}
onShowLandAbortChanged: {
if (showLandAbort) {
confirmAction(actionLandAbort)
}
}
/// Close all dialogs
function closeAll() {
guidedActionConfirm.visible = false
guidedActionList.visible = false
altitudeSlider.visible = false
}
} }
GuidedActionConfirm { GuidedActionConfirm {
...@@ -701,8 +582,9 @@ Item { ...@@ -701,8 +582,9 @@ Item {
anchors.margins: _margins anchors.margins: _margins
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
z: _guidedZOrder
guidedController: _guidedController guidedController: _guidedController
altitudeSlider: _altitudeSlider altitudeSlider: _guidedSlider
} }
GuidedActionList { GuidedActionList {
...@@ -710,6 +592,7 @@ Item { ...@@ -710,6 +592,7 @@ Item {
anchors.margins: _margins anchors.margins: _margins
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
z: _guidedZOrder
guidedController: _guidedController guidedController: _guidedController
} }
...@@ -721,7 +604,7 @@ Item { ...@@ -721,7 +604,7 @@ Item {
anchors.topMargin: ScreenTools.toolbarHeight + _margins anchors.topMargin: ScreenTools.toolbarHeight + _margins
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
z: _guidedController.z z: _guidedZOrder
radius: ScreenTools.defaultFontPixelWidth / 2 radius: ScreenTools.defaultFontPixelWidth / 2
width: ScreenTools.defaultFontPixelWidth * 10 width: ScreenTools.defaultFontPixelWidth * 10
color: qgcPal.window color: qgcPal.window
......
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QGroundControl 1.0
import QGroundControl.Controls 1.0
ToolStrip {
title: qsTr("Fly")
property var guidedActionsController
property var guidedActionList
property var preFlightCheckList
property bool _anyActionAvailable: guidedActionsController.showStartMission || guidedActionsController.showResumeMission || guidedActionsController.showChangeAlt || guidedActionsController.showLandAbort
property var _actionModel: [
{
title: guidedActionsController.startMissionTitle,
text: guidedActionsController.startMissionMessage,
action: guidedActionsController.actionStartMission,
visible: guidedActionsController.showStartMission
},
{
title: guidedActionsController.continueMissionTitle,
text: guidedActionsController.continueMissionMessage,
action: guidedActionsController.actionContinueMission,
visible: guidedActionsController.showContinueMission
},
{
title: guidedActionsController.changeAltTitle,
text: guidedActionsController.changeAltMessage,
action: guidedActionsController.actionChangeAlt,
visible: guidedActionsController.showChangeAlt
},
{
title: guidedActionsController.landAbortTitle,
text: guidedActionsController.landAbortMessage,
action: guidedActionsController.actionLandAbort,
visible: guidedActionsController.showLandAbort
}
]
model: [
{
name: "Checklist",
iconSource: "/qmlimages/check.svg",
buttonVisible: _useChecklist,
buttonEnabled: _useChecklist && activeVehicle && !activeVehicle.armed,
},
{
name: guidedActionsController.takeoffTitle,
iconSource: "/res/takeoff.svg",
buttonVisible: guidedActionsController.showTakeoff || !guidedActionsController.showLand,
buttonEnabled: guidedActionsController.showTakeoff,
action: guidedActionsController.actionTakeoff
},
{
name: guidedActionsController.landTitle,
iconSource: "/res/land.svg",
buttonVisible: guidedActionsController.showLand && !guidedActionsController.showTakeoff,
buttonEnabled: guidedActionsController.showLand,
action: guidedActionsController.actionLand
},
{
name: guidedActionsController.rtlTitle,
iconSource: "/res/rtl.svg",
buttonVisible: true,
buttonEnabled: guidedActionsController.showRTL,
action: guidedActionsController.actionRTL
},
{
name: guidedActionsController.pauseTitle,
iconSource: "/res/pause-mission.svg",
buttonVisible: guidedActionsController.showPause,
buttonEnabled: guidedActionsController.showPause,
action: guidedActionsController.actionPause
},
{
name: qsTr("Action"),
iconSource: "/res/action.svg",
buttonVisible: _anyActionAvailable,
buttonEnabled: true,
action: -1
}
]
onClicked: {
if(index === 0) {
preFlightCheckList.open()
} else {
guidedActionsController.closeAll()
var action = model[index].action
if (action === -1) {
guidedActionList.model = _actionModel
guidedActionList.visible = true
} else {
guidedActionsController.confirmAction(action)
}
}
}
}
...@@ -24,7 +24,6 @@ Rectangle { ...@@ -24,7 +24,6 @@ Rectangle {
color: qgcPal.window color: qgcPal.window
border.color: _emergencyAction ? "red" : qgcPal.windowShade border.color: _emergencyAction ? "red" : qgcPal.windowShade
border.width: _emergencyAction ? 4 : 1 border.width: _emergencyAction ? 4 : 1
z: guidedController.z
visible: false visible: false
property var guidedController property var guidedController
......
...@@ -24,7 +24,6 @@ Rectangle { ...@@ -24,7 +24,6 @@ Rectangle {
radius: _margins / 2 radius: _margins / 2
color: qgcPal.window color: qgcPal.window
opacity: 0.9 opacity: 0.9
z: guidedController.z
visible: false visible: false
property var guidedController property var guidedController
......
...@@ -190,12 +190,18 @@ Item { ...@@ -190,12 +190,18 @@ Item {
console.log("showStartMission", showStartMission) console.log("showStartMission", showStartMission)
} }
_outputState() _outputState()
if (showStartMission) {
confirmAction(actionStartMission)
}
} }
onShowContinueMissionChanged: { onShowContinueMissionChanged: {
if (_corePlugin.guidedActionsControllerLogging()) { if (_corePlugin.guidedActionsControllerLogging()) {
console.log("showContinueMission", showContinueMission) console.log("showContinueMission", showContinueMission)
} }
_outputState() _outputState()
if (showContinueMission) {
confirmAction(actionContinueMission)
}
} }
onShowRTLChanged: { onShowRTLChanged: {
if (_corePlugin.guidedActionsControllerLogging()) { if (_corePlugin.guidedActionsControllerLogging()) {
...@@ -209,6 +215,11 @@ Item { ...@@ -209,6 +215,11 @@ Item {
} }
_outputState() _outputState()
} }
onShowLandAbortChanged: {
if (showLandAbort) {
confirmAction(actionLandAbort)
}
}
on_VehicleFlyingChanged: { on_VehicleFlyingChanged: {
_outputState() _outputState()
...@@ -228,6 +239,12 @@ Item { ...@@ -228,6 +239,12 @@ Item {
_vehicleInMissionMode = activeVehicle ? _flightMode === activeVehicle.missionFlightMode : false // Must be last to get correct signalling for showStartMission popups _vehicleInMissionMode = activeVehicle ? _flightMode === activeVehicle.missionFlightMode : false // Must be last to get correct signalling for showStartMission popups
} }
function closeAll() {
confirmDialog.visible = false
actionList.visible = false
altitudeSlider.visible = false
}
// 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, mapIndicator) { function confirmAction(actionCode, actionData, mapIndicator) {
var showImmediate = true var showImmediate = true
......
...@@ -4,6 +4,7 @@ FlightDisplayView 1.0 FlightDisplayView.qml ...@@ -4,6 +4,7 @@ FlightDisplayView 1.0 FlightDisplayView.qml
FlightDisplayViewMap 1.0 FlightDisplayViewMap.qml FlightDisplayViewMap 1.0 FlightDisplayViewMap.qml
FlightDisplayViewVideo 1.0 FlightDisplayViewVideo.qml FlightDisplayViewVideo 1.0 FlightDisplayViewVideo.qml
FlightDisplayViewWidgets 1.0 FlightDisplayViewWidgets.qml FlightDisplayViewWidgets 1.0 FlightDisplayViewWidgets.qml
FlyViewToolStrip 1.0 FlyViewToolStrip.qml
GuidedActionConfirm 1.0 GuidedActionConfirm.qml GuidedActionConfirm 1.0 GuidedActionConfirm.qml
GuidedActionList 1.0 GuidedActionList.qml GuidedActionList 1.0 GuidedActionList.qml
GuidedActionsController 1.0 GuidedActionsController.qml GuidedActionsController 1.0 GuidedActionsController.qml
......
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