Skip to content

Commit

Permalink
Add custom guided action example
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Dec 19, 2024
1 parent cee4f7f commit 0bb79fd
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 6 deletions.
4 changes: 3 additions & 1 deletion custom-example/custom.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
<file alias="Custom/Widgets/qmldir">res/Custom/Widgets/qmldir</file>
</qresource>
<qresource prefix="/qml">
<file alias="QGroundControl/FlightDisplay/FlyViewCustomLayer.qml">res/CustomFlyViewOverlay.qml</file>
<file alias="QGroundControl/FlightDisplay/CustomGuidedActionsController.qml">src/CustomGuidedActionsController.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewCustomLayer.qml">src/FlyViewCustomLayer.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolStripActionList.qml">src/FlyViewToolStripActionList.qml</file>
</qresource>
<qresource prefix="/res">
<file alias="QGCLogoFull.svg">res/QGCLogoFull.svg</file>
Expand Down
2 changes: 2 additions & 0 deletions custom-example/qgroundcontrol.exclusion
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<file alias="QGroundControl/FlightDisplay/CustomGuidedActionsController.qml">src/FlightDisplay/CustomGuidedActionsController.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewCustomLayer.qml">src/FlightDisplay/FlyViewCustomLayer.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolStripActionList.qml">src/FlightDisplay/FlyViewToolStripActionList.qml</file>

1 change: 0 additions & 1 deletion custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
<file alias="QGroundControl/FlightDisplay/FlyViewToolBar.qml">../src/UI/toolbar/FlyViewToolBar.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolBarIndicators.qml">../src/UI/toolbar/FlyViewToolBarIndicators.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolStrip.qml">../src/FlightDisplay/FlyViewToolStrip.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewToolStripActionList.qml">../src/FlightDisplay/FlyViewToolStripActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewTopRightColumnLayout.qml">../src/FlightDisplay/FlyViewTopRightColumnLayout.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewVideo.qml">../src/FlightDisplay/FlyViewVideo.qml</file>
<file alias="QGroundControl/FlightDisplay/OnScreenGimbalController.qml">../src/FlightDisplay/OnScreenGimbalController.qml</file>
Expand Down
46 changes: 46 additions & 0 deletions custom-example/src/CustomGuidedActionsController.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/****************************************************************************
*
* (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.
*
****************************************************************************/

// Custom builds can override this file to add custom guided actions.

import QtQml

QtObject {
readonly property int actionCustomButton: _guidedController.customActionStart + 0

readonly property string customButtonTitle: qsTr("Custom")

readonly property string customButtonMessage: qsTr("Example of a custom action.")

function customConfirmAction(actionCode, actionData, mapIndicator, confirmDialog) {
switch (actionCode) {
case actionCustomButton:
confirmDialog.hideTrigger = true
confirmDialog.title = customButtonTitle
confirmDialog.message = customButtonMessage
break
default:
return false // false = action not handled here
}

return true // true = action handled here
}

function customExecuteAction(actionCode, actionData, sliderOutputValue, optionCheckedode) {
switch (actionCode) {
case actionCustomButton:
mainWindow.showMessageDialog("Custom Action", "Custom action executed.")
break
default:
return false // false = action not handled here
}

return true // true = action handled here
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ Item {
id: compassBar
height: ScreenTools.defaultFontPixelHeight * 1.5
width: ScreenTools.defaultFontPixelWidth * 50
anchors.bottom: parent.bottom
anchors.bottomMargin: _toolsMargin
color: "#DEDEDE"
radius: 2
clip: true
anchors.top: headingIndicator.bottom
anchors.topMargin: -headingIndicator.height / 2
anchors.horizontalCenter: parent.horizontalCenter
Repeater {
model: 720
Expand Down Expand Up @@ -137,8 +137,8 @@ Item {
height: ScreenTools.defaultFontPixelHeight
width: ScreenTools.defaultFontPixelWidth * 4
color: qgcPal.windowShadeDark
anchors.top: parent.top
anchors.topMargin: _toolsMargin
anchors.top: compassBar.top
anchors.topMargin: -headingIndicator.height / 2
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: _heading
Expand Down
43 changes: 43 additions & 0 deletions custom-example/src/FlyViewToolStripActionList.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/****************************************************************************
*
* (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.Models

import QGroundControl
import QGroundControl.Controls

ToolStripActionList {
id: _root

signal displayPreFlightChecklist

model: [
ToolStripAction {
text: qsTr("Plan")
iconSource: "/qmlimages/Plan.svg"
onTriggered:{
mainWindow.showPlanView()
viewer3DWindow.close()
}
},
PreFlightCheckListShowAction { onTriggered: displayPreFlightChecklist() },
GuidedActionTakeoff { },
GuidedActionLand { },
GuidedActionRTL { },
GuidedActionPause { },
GuidedActionActionList { },
GuidedToolStripAction {
text: _guidedController._customController.customButtonTitle
iconSource: "/res/gear-white.svg"
visible: true
enabled: true
actionID: _guidedController._customController.actionCustomButton
}
]
}

0 comments on commit 0bb79fd

Please sign in to comment.