diff --git a/custom-example/custom.qrc b/custom-example/custom.qrc
index 64c3fb561e5..f4eef6227de 100644
--- a/custom-example/custom.qrc
+++ b/custom-example/custom.qrc
@@ -30,7 +30,9 @@
res/Custom/Widgets/qmldir
- res/CustomFlyViewOverlay.qml
+ src/CustomGuidedActionsController.qml
+ src/FlyViewCustomLayer.qml
+ src/FlyViewToolStripActionList.qml
res/QGCLogoFull.svg
diff --git a/custom-example/qgroundcontrol.exclusion b/custom-example/qgroundcontrol.exclusion
index bdfaced0fc6..93dd17c804b 100644
--- a/custom-example/qgroundcontrol.exclusion
+++ b/custom-example/qgroundcontrol.exclusion
@@ -1,2 +1,4 @@
+ src/FlightDisplay/CustomGuidedActionsController.qml
src/FlightDisplay/FlyViewCustomLayer.qml
+ src/FlightDisplay/FlyViewToolStripActionList.qml
diff --git a/custom-example/qgroundcontrol.qrc b/custom-example/qgroundcontrol.qrc
index a087cc21165..bee99370487 100644
--- a/custom-example/qgroundcontrol.qrc
+++ b/custom-example/qgroundcontrol.qrc
@@ -232,7 +232,6 @@
../src/UI/toolbar/FlyViewToolBar.qml
../src/UI/toolbar/FlyViewToolBarIndicators.qml
../src/FlightDisplay/FlyViewToolStrip.qml
- ../src/FlightDisplay/FlyViewToolStripActionList.qml
../src/FlightDisplay/FlyViewTopRightColumnLayout.qml
../src/FlightDisplay/FlyViewVideo.qml
../src/FlightDisplay/OnScreenGimbalController.qml
diff --git a/custom-example/src/CustomGuidedActionsController.qml b/custom-example/src/CustomGuidedActionsController.qml
new file mode 100644
index 00000000000..fb5a61f8d48
--- /dev/null
+++ b/custom-example/src/CustomGuidedActionsController.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * 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
+ }
+}
\ No newline at end of file
diff --git a/custom-example/res/CustomFlyViewOverlay.qml b/custom-example/src/FlyViewCustomLayer.qml
similarity index 98%
rename from custom-example/res/CustomFlyViewOverlay.qml
rename to custom-example/src/FlyViewCustomLayer.qml
index 539efa947c0..3e04c35dad9 100644
--- a/custom-example/res/CustomFlyViewOverlay.qml
+++ b/custom-example/src/FlyViewCustomLayer.qml
@@ -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
@@ -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
diff --git a/custom-example/src/FlyViewToolStripActionList.qml b/custom-example/src/FlyViewToolStripActionList.qml
new file mode 100644
index 00000000000..e9342c96f3b
--- /dev/null
+++ b/custom-example/src/FlyViewToolStripActionList.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * 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
+}
+ ]
+}
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index a3576f6d567..0a2385c64f1 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -222,6 +222,7 @@
src/FactSystem/FactControls/LabelledFactTextField.qml
src/FactSystem/FactControls/LabelledFactSlider.qml
src/QmlControls/QGroundControl/FactControls/qmldir
+ src/FlightDisplay/CustomGuidedActionsController.qml
src/FlightDisplay/FlightDisplayViewVideo.qml
src/FlightDisplay/FlyView.qml
src/FlightDisplay/FlyViewBottomRightRowLayout.qml
diff --git a/src/FlightDisplay/CustomGuidedActionsController.qml b/src/FlightDisplay/CustomGuidedActionsController.qml
new file mode 100644
index 00000000000..8cd37bf376a
--- /dev/null
+++ b/src/FlightDisplay/CustomGuidedActionsController.qml
@@ -0,0 +1,22 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * 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 {
+ function customConfirmAction(actionCode, actionData, mapIndicator, confirmDialog) {
+ return false // false = action not handled here
+ }
+
+ function customExecuteAction(actionCode, actionData, sliderOutputValue, optionCheckedode) {
+ return false // false = action not handled here
+ }
+}
\ No newline at end of file
diff --git a/src/FlightDisplay/GuidedActionsController.qml b/src/FlightDisplay/GuidedActionsController.qml
index 245dd827ffb..881742c7378 100644
--- a/src/FlightDisplay/GuidedActionsController.qml
+++ b/src/FlightDisplay/GuidedActionsController.qml
@@ -120,6 +120,8 @@ Item {
readonly property int actionSetFlightMode: 29
readonly property int actionChangeHeading: 30
+ readonly property int customActionStart: 10000 // Custom actions ids should start here so that they don't collide with the built in actions
+
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _flyViewSettings: QGroundControl.settingsManager.flyViewSettings
property var _unitsConversion: QGroundControl.unitsConversion
@@ -194,6 +196,12 @@ Item {
property bool __orbitSupported: _activeVehicle ? !_hideOrbit && _activeVehicle.orbitModeSupported : false
property bool __flightMode: _flightMode
+ // Allow custom builds to add custom actions by overriding CustomGuidedActionsController.qml
+ CustomGuidedActionsController {
+ id: customController
+ }
+ property var _customController: customController
+
function _isGuidedActionsControllerLogEnabled() {
return QGroundControl.categoryLoggingOn("GuidedActionsControllerLog")
}
@@ -557,8 +565,10 @@ Item {
confirmDialog.message = changeHeadingMessage
break
default:
- console.warn("Unknown actionCode", actionCode)
- return
+ if (!customController.customConfirmAction(actionCode, actionData, mapIndicator, confirmDialog)) {
+ console.warn("Unknown actionCode", actionCode)
+ return
+ }
}
confirmDialog.show(showImmediate)
}
@@ -669,7 +679,10 @@ Item {
_activeVehicle.guidedModeChangeHeading(actionData)
break
default:
- console.warn(qsTr("Internal error: unknown actionCode"), actionCode)
+ if (!customController.customExecuteAction(actionCode, actionData, sliderOutputValue, optionChecked)) {
+ console.warn(qsTr("Internal error: unknown actionCode"), actionCode)
+ return
+ }
break
}
}
diff --git a/src/QmlControls/QGroundControl/FlightDisplay/qmldir b/src/QmlControls/QGroundControl/FlightDisplay/qmldir
index 4340d2b3e96..bdcf895001f 100644
--- a/src/QmlControls/QGroundControl/FlightDisplay/qmldir
+++ b/src/QmlControls/QGroundControl/FlightDisplay/qmldir
@@ -1,5 +1,6 @@
Module QGroundControl.FlightDisplay
+CustomGuidedActionsController 1.0 CustomGuidedActionsController.qml
FlyView 1.0 FlyView.qml
FlyViewBottomRightRowLayout 1.0 FlyViewBottomRightRowLayout.qml
FlyViewCustomLayer 1.0 FlyViewCustomLayer.qml