Skip to content

Commit

Permalink
Merge branch 'master' into Fix-custom-paramters-view
Browse files Browse the repository at this point in the history
  • Loading branch information
vryabokon1705 authored Dec 20, 2024
2 parents 4f6068c + 0bb79fd commit 8857cb1
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 9 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
}
]
}
1 change: 1 addition & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<file alias="QGroundControl/FactControls/LabelledFactTextField.qml">src/FactSystem/FactControls/LabelledFactTextField.qml</file>
<file alias="QGroundControl/FactControls/LabelledFactSlider.qml">src/FactSystem/FactControls/LabelledFactSlider.qml</file>
<file alias="QGroundControl/FactControls/qmldir">src/QmlControls/QGroundControl/FactControls/qmldir</file>
<file alias="QGroundControl/FlightDisplay/CustomGuidedActionsController.qml">src/FlightDisplay/CustomGuidedActionsController.qml</file>
<file alias="QGroundControl/FlightDisplay/FlightDisplayViewVideo.qml">src/FlightDisplay/FlightDisplayViewVideo.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyView.qml">src/FlightDisplay/FlyView.qml</file>
<file alias="QGroundControl/FlightDisplay/FlyViewBottomRightRowLayout.qml">src/FlightDisplay/FlyViewBottomRightRowLayout.qml</file>
Expand Down
22 changes: 22 additions & 0 deletions src/FlightDisplay/CustomGuidedActionsController.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/****************************************************************************
*
* (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 {
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
}
}
19 changes: 16 additions & 3 deletions src/FlightDisplay/GuidedActionsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
}
Expand Down
1 change: 1 addition & 0 deletions src/QmlControls/QGroundControl/FlightDisplay/qmldir
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8857cb1

Please sign in to comment.