From 9d31252424679d1856d51246a34368402f042550 Mon Sep 17 00:00:00 2001 From: davidsastresas Date: Thu, 28 Mar 2024 07:09:58 +0100 Subject: [PATCH] GimbalIndicator.qml: Add Acquire/release control button --- src/ui/toolbar/GimbalIndicator.qml | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/ui/toolbar/GimbalIndicator.qml b/src/ui/toolbar/GimbalIndicator.qml index 4e204c9..77d5dfa 100644 --- a/src/ui/toolbar/GimbalIndicator.qml +++ b/src/ui/toolbar/GimbalIndicator.qml @@ -65,12 +65,17 @@ Item { // These are simple buttons that can be grouped on this Repeater Repeater { + id: simpleGimbalButtonsRepeater + property var hasControl: gimbalController && gimbalController.activeGimbal && gimbalController.activeGimbal.gimbalHaveControl + property var acqControlButtonEnabled: QGroundControl.settingsManager.gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl.rawValue + model: [ - {id: "yawLock", text: activeGimbal.yawLock ? qsTr("Yaw
Follow") : qsTr("Yaw
Lock") }, - {id: "center", text: qsTr("Center") }, - {id: "tilt90", text: qsTr("Tilt 90") }, - {id: "pointHome", text: qsTr("Point
Home") }, - {id: "retract", text: qsTr("Retract") } + {id: "yawLock", text: activeGimbal.yawLock ? qsTr("Yaw
Follow") : qsTr("Yaw
Lock") , visible: true }, + {id: "center", text: qsTr("Center") , visible: true }, + {id: "tilt90", text: qsTr("Tilt 90") , visible: true }, + {id: "pointHome", text: qsTr("Point
Home") , visible: true }, + {id: "retract", text: qsTr("Retract") , visible: true }, + {id: "acqControl",text: hasControl ? qsTr("Release
Control") : qsTr("Acquire
Control"), visible: acqControlButtonEnabled } ] QGCButton { @@ -79,13 +84,18 @@ Item { {"center": function(){ gimbalController.centerGimbal() } }, {"tilt90": function(){ gimbalController.sendPitchBodyYaw(-90, 0) } }, {"pointHome": function(){ activeVehicle.guidedModeROI(activeVehicle.homePosition) } }, - {"retract": function(){ gimbalController.toggleGimbalRetracted(true) } } + {"retract": function(){ gimbalController.toggleGimbalRetracted(true) } }, + // This button changes its action depending on gimbal being under control or not + {"acqControl": function(){ simpleGimbalButtonsRepeater.hasControl ? + gimbalController.releaseGimbalControl() : + gimbalController.acquireGimbalControl() } } ] Layout.preferredWidth: Layout.preferredHeight Layout.preferredHeight: buttonHeight Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter text: modelData.text + visible: modelData.visible fontWeight: Font.Medium pointSize: ScreenTools.smallFontPointSize backRadius: panelRadius * 0.5 @@ -306,6 +316,15 @@ Item { checkedValue: 1 uncheckedValue: 0 } + + FactCheckBox { + id: showAcquireControlCheckbox + text: " " + qsTr("Show Acquire/Release control button") + fact: QGroundControl.settingsManager.gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl + Layout.columnSpan: 2 + checkedValue: 1 + uncheckedValue: 0 + } } } }