Skip to content

Commit

Permalink
Rework the guided "Action" button
Browse files Browse the repository at this point in the history
* "Actions" button now show a drop panel of additional action buttons
* Custom build can add additional actions by overriding FlyViewAdditionalCustomActionsList.qml
* Actions drop panel has three sections: Guided Actions, Custom Build Actions, Mavlink Actions
* Fixes a number of problems with Mavlink Actions
  • Loading branch information
DonLakeFlyer committed Jan 20, 2025
1 parent 218d377 commit 89a3291
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 261 deletions.
4 changes: 2 additions & 2 deletions custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@
<file alias="QGroundControl/FlightDisplay/FlyViewVideo.qml">../src/FlightDisplay/FlyViewVideo.qml</file>
<file alias="QGroundControl/FlightDisplay/OnScreenGimbalController.qml">../src/FlightDisplay/OnScreenGimbalController.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewWidgetLayer.qml">../src/FlightDisplay/FlyViewWidgetLayer.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionActionList.qml">../src/FlightDisplay/GuidedActionActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalActionsButton.qml">../src/FlightDisplay/FlyViewAdditionalActionsButton.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionConfirm.qml">../src/FlightDisplay/GuidedActionConfirm.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionsController.qml">../src/FlightDisplay/GuidedActionsController.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionLand.qml">../src/FlightDisplay/GuidedActionLand.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionList.qml">../src/FlightDisplay/GuidedActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalActionsList.qml">../src/FlightDisplay/FlyViewAdditionalActionsList.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionTakeoff.qml">../src/FlightDisplay/GuidedActionTakeoff.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionGripper.qml">../src/FlightDisplay/GuidedActionGripper.qml</file>
<file alias="QGroundControl/FlightDisplay/GripperMenu.qml">../src/FlightDisplay/GripperMenu.qml</file>
Expand Down
2 changes: 1 addition & 1 deletion custom-example/src/FlyViewToolStripActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ToolStripActionList {
GuidedActionLand { },
GuidedActionRTL { },
GuidedActionPause { },
GuidedActionActionList { },
FlyViewAdditionalActionsButton { },
GuidedToolStripAction {
text: _guidedController._customController.customButtonTitle
iconSource: "/res/gear-white.svg"
Expand Down
36 changes: 18 additions & 18 deletions docs/en/qgc-user-guide/custom_actions/custom_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ The actions available are defined in a JSON file. The format of that file is as
{
"version": 1,
"fileType": "MavlinkActions",
"actions":
[
{
"label": "First Command",
"description": "This is the first command",
"mavCmd": 10,
"compId": 100,
"param1": 1,
"param2": 2,
...
},
{
"label": "Second Command",
"description": "This is the second command",
"mavCmd": 20,
...
}
]
"actions": [
{
"label": "First Mavlink Command",
"description": "This is the first command",
"mavCmd": 10,
"compId": 100,
"param1": 1,
"param2": 2,
...
},
{
"label": "Second Mavlink Command",
"description": "This is the second command",
"mavCmd": 20,
...
}
]
}
```

Fields:

* actions (required) - An array of json objects, one for each command
* label (required) - The user visible short description for the command. This is used as the button text for the Fly View - Actions command list. For Joysticks, this is the command you select from the dropdown. For Joysticks, make sure your name doesn't conflict with the built in names.
* description (required) - This is a longer description of the command used in the Fly View - Action list. This is not used by joysticks.
Expand Down
6 changes: 4 additions & 2 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@
<file alias="QGroundControl/FlightDisplay/FlyViewVideo.qml">src/FlightDisplay/FlyViewVideo.qml</file>
<file alias="QGroundControl/FlightDisplay/OnScreenGimbalController.qml">src/FlightDisplay/OnScreenGimbalController.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewWidgetLayer.qml">src/FlightDisplay/FlyViewWidgetLayer.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionActionList.qml">src/FlightDisplay/GuidedActionActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalActionsButton.qml">src/FlightDisplay/FlyViewAdditionalActionsButton.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionConfirm.qml">src/FlightDisplay/GuidedActionConfirm.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionsController.qml">src/FlightDisplay/GuidedActionsController.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionLand.qml">src/FlightDisplay/GuidedActionLand.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionList.qml">src/FlightDisplay/GuidedActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalActionsList.qml">src/FlightDisplay/FlyViewAdditionalActionsList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalActionsPanel.qml">src/FlightDisplay/FlyViewAdditionalActionsPanel.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewAdditionalCustomActionsList.qml">src/FlightDisplay/FlyViewAdditionalCustomActionsList.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionTakeoff.qml">src/FlightDisplay/GuidedActionTakeoff.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionGripper.qml">src/FlightDisplay/GuidedActionGripper.qml</file>
<file alias="QGroundControl/FlightDisplay/GripperMenu.qml">src/FlightDisplay/GripperMenu.qml</file>
Expand Down
11 changes: 0 additions & 11 deletions src/FlightDisplay/FlyView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Item {
property var _rallyPointController: _planController.rallyPointController
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property var _guidedController: guidedActionsController
property var _guidedActionList: guidedActionList
property var _guidedValueSlider: guidedValueSlider
property var _widgetLayer: widgetLayer
property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
Expand Down Expand Up @@ -162,19 +161,9 @@ Item {
GuidedActionsController {
id: guidedActionsController
missionController: _missionController
actionList: _guidedActionList
guidedValueSlider: _guidedValueSlider
}

GuidedActionList {
id: guidedActionList
anchors.margins: _margins
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
z: QGroundControl.zOrderTopMost
guidedController: _guidedController
}

//-- Guided value slider (e.g. altitude)
GuidedValueSlider {
id: guidedValueSlider
Expand Down
49 changes: 49 additions & 0 deletions src/FlightDisplay/FlyViewAdditionalActionsButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/****************************************************************************
*
* (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 QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import QGroundControl
import QGroundControl.Controls
import QGroundControl.FlightDisplay
import QGroundControl.Controllers

ToolStripAction {
id: action
text: qsTr("Actions")
iconSource: "/res/action.svg"
visible: _additionalActions.anyActionAvailable || _mavlinkActions.anyActionAvailable || _customActions.anyActionAvailable
enabled: true

property var _guidedController: globals.guidedControllerFlyView

property var _additionalActions: FlyViewAdditionalActionsList {
guidedController: _guidedController
}

property var _mavlinkActions: MavlinkActionManager {
actionFileNameFact: QGroundControl.settingsManager.mavlinkActionsSettings.flyViewActionsFile

property bool anyActionAvailable: QGroundControl.multiVehicleManager.activeVehicle && actions.count > 0
}

property var _customActions: FlyViewAdditionalCustomActionsList {
guidedController: _guidedController
}

dropPanelComponent: Component {
FlyViewAdditionalActionsPanel {
additionalActions: _additionalActions
mavlinkActions: _mavlinkActions.actions
customActions: _customActions
}
}
}
55 changes: 55 additions & 0 deletions src/FlightDisplay/FlyViewAdditionalActionsList.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/****************************************************************************
*
* (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 QtQml

QtObject {
property var guidedController

property bool anyActionAvailable: guidedController.showStartMission || guidedController.showContinueMission || guidedController.showChangeAlt ||
guidedController.showLandAbort || guidedController.showChangeSpeed || guidedController.showGripper
property var model: [
{
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
},
{
title: guidedController.changeSpeedTitle,
text: guidedController.changeSpeedMessage,
action: guidedController.actionChangeSpeed,
visible: guidedController.showChangeSpeed
},
{
title: guidedController.gripperTitle,
text: guidedController.gripperMessage,
action: guidedController.actionGripper,
visible: guidedController.showGripper
}
]
}
70 changes: 70 additions & 0 deletions src/FlightDisplay/FlyViewAdditionalActionsPanel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/****************************************************************************
*
* (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 QtQuick
import QtQuick.Layouts

import QGroundControl
import QGroundControl.Controls

ColumnLayout {
property var additionalActions
property var mavlinkActions
property var customActions

property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _guidedController: globals.guidedControllerFlyView

// Pre-defined Additional Guided Actions
Repeater {
model: additionalActions.model

QGCButton {
Layout.fillWidth: true
text: modelData.title
visible: modelData.visible

onClicked: {
dropPanel.hide()
_guidedController.confirmAction(modelData.action)
}
}
}

// Custom Build Actions
Repeater {
model: customActions.model

QGCButton {
Layout.fillWidth: true
text: modelData.title
visible: modelData.visible

onClicked: {
dropPanel.hide()
_guidedController.confirmAction(modelData.action)
}
}
}

// User-defined Mavlink Actions
Repeater {
model: _activeVehicle ? mavlinkActions : undefined // The action list is a QmlObjectListModel

QGCButton {
Layout.fillWidth: true
text: object.label

onClicked: {
dropPanel.hide()
object.sendTo(_activeVehicle)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
*
****************************************************************************/

import QGroundControl.FlightDisplay
import QtQml

GuidedToolStripAction {
text: _guidedController.actionListTitle
iconSource: "/res/action.svg"
visible: _guidedController.showActionList
enabled: true
actionID: _guidedController.actionActionList
// Custom builds can override this resource to add additional custom actions
QtObject {
property var guidedController

property bool anyActionAvailable: false
property var model: [ ]
}
2 changes: 1 addition & 1 deletion src/FlightDisplay/FlyViewToolStripActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ToolStripActionList {
GuidedActionLand { },
GuidedActionRTL { },
GuidedActionPause { },
GuidedActionActionList { },
FlyViewAdditionalActionsButton { },
GuidedActionGripper { }
]
}
Loading

0 comments on commit 89a3291

Please sign in to comment.