6import QGroundControl.Controls
7import QGroundControl.FactControls
11 objectName: "toolbar_gimbalIndicator"
12 anchors.top: parent.top
13 anchors.bottom: parent.bottom
14 width: gimbalIndicatorRow.width
16 property bool showIndicator: gimbalController.gimbals.count
18 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
19 property var gimbalController: activeVehicle.gimbalController
20 property var gimbals: gimbalController.gimbals
21 property var activeGimbal: gimbalController.activeGimbal
22 property var multiGimbalSetup: gimbalController.gimbals.count > 1
23 property bool joystickButtonsAvailable: activeVehicle ? joystickManager.activeJoystickEnabledForActiveVehicle : false
24 property bool showAzimuth: QGroundControl.settingsManager.gimbalControllerSettings.toolbarIndicatorShowAzimuth.rawValue
26 property var margins: ScreenTools.defaultFontPixelWidth
27 property var panelRadius: ScreenTools.defaultFontPixelWidth * 0.5
28 property var buttonHeight: height * 1.6
29 property var squareButtonPadding: ScreenTools.defaultFontPixelWidth
30 property var separatorHeight: buttonHeight * 0.9
31 property var settingsPanelVisible: false
33 property var _gimbalControllerSettings: QGroundControl.settingsManager.gimbalControllerSettings
35 QGCPalette { id: qgcPal }
38 id: gimbalIndicatorRow
39 anchors.top: parent.top
40 anchors.bottom: parent.bottom
41 spacing: ScreenTools.defaultFontPixelWidth / 2
44 anchors.top: parent.top
45 anchors.bottom: parent.bottom
49 id: gimbalIndicatorIcon
50 anchors.horizontalCenter: parent.horizontalCenter
52 height: multiGimbalSetup ? parent.height - gimbalIdLabel.contentHeight : parent.height
53 source: "/res/CameraGimbal.png"
54 fillMode: Image.PreserveAspectFit
55 sourceSize.height: height
62 anchors.horizontalCenter: parent.horizontalCenter
63 font.pointSize: ScreenTools.smallFontPointSize
64 text: activeGimbal ? activeGimbal.deviceId.rawValue : ""
66 visible: multiGimbalSetup
70 // Telemetry and status indicator
72 anchors.verticalCenter: parent.verticalCenter
76 columnSpacing: margins / 2
80 font.pointSize: ScreenTools.smallFontPointSize
81 text: activeGimbal && activeGimbal.retracted ?
83 (activeGimbal && activeGimbal.yawLock ? qsTr("Yaw locked") : qsTr("Yaw follow"))
86 Layout.alignment: Qt.AlignHCenter
90 font.pointSize: ScreenTools.smallFontPointSize
91 text: activeGimbal ? qsTr("P: ") + activeGimbal.absolutePitch.valueString : ""
96 font.pointSize: ScreenTools.smallFontPointSize
99 (qsTr("Az: ") + activeGimbal.absoluteYaw.valueString) :
100 (qsTr("Y: ") + activeGimbal.bodyYaw.valueString)) :
109 onClicked: mainWindow.showIndicatorDrawer(gimbalPopup, control)
117 waitForParameters: false
118 contentComponent: gimbalContentComponent
119 expandedComponent: gimbalExpandedComponent
124 id: gimbalContentComponent
127 spacing: ScreenTools.defaultFontPixelWidth / 2
129 SettingsGroupLayout {
130 heading: qsTr("Active Gimbal")
131 visible: multiGimbalSetup
134 id: gimbalSelectorCombo
135 Layout.fillWidth: true
136 visible: multiGimbalSetup
137 onCurrentIndexChanged: gimbalController.activeGimbal = gimbalController.gimbals.get(currentIndex)
139 function _updateComboModel() {
142 for (var i = 0; i < gimbals.count; i++) {
143 var gimbal = gimbals.get(i)
144 gimbalModel.push(qsTr("Gimbal %1").arg(gimbal.deviceId.valueString))
145 if (gimbal === activeGimbal) {
149 gimbalSelectorCombo.model = gimbalModel
150 gimbalSelectorCombo.currentIndex = activeIndex
153 Component.onCompleted: _updateComboModel()
156 function onCountChanged(count) { _updateComboModel() }
161 SettingsGroupLayout {
162 heading: qsTr("Commands")
166 Layout.fillWidth: true
167 text: activeGimbal.yawLock ? qsTr("Yaw Follow") : qsTr("Yaw Lock")
168 visible: activeGimbal.supportsYawLock
170 gimbalController.setGimbalYawLock(!activeGimbal.yawLock)
171 mainWindow.closeIndicatorDrawer()
176 Layout.fillWidth: true
179 gimbalController.centerGimbal()
180 mainWindow.closeIndicatorDrawer()
185 Layout.fillWidth: true
186 text: qsTr("Tilt 90")
188 gimbalController.sendPitchBodyYaw(-90, 0)
189 mainWindow.closeIndicatorDrawer()
194 Layout.fillWidth: true
195 text: qsTr("Point Home")
197 activeVehicle.guidedModeROI(activeVehicle.homePosition)
198 mainWindow.closeIndicatorDrawer()
203 Layout.fillWidth: true
204 text: qsTr("Retract")
205 visible: activeGimbal.supportsRetract
207 gimbalController.setGimbalRetract(true)
208 mainWindow.closeIndicatorDrawer()
213 Layout.fillWidth: true
214 text: activeGimbal.gimbalHaveControl ? qsTr("Release Control") : qsTr("Acquire Control")
215 visible: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl.rawValue
217 activeGimbal.gimbalHaveControl ? gimbalController.releaseGimbalControl() : gimbalController.acquireGimbalControl()
218 mainWindow.closeIndicatorDrawer()
226 id: gimbalExpandedComponent
229 spacing: ScreenTools.defaultFontPixelWidth / 2
231 SettingsGroupLayout {
232 heading: qsTr("On-Screen Control")
236 id: enableOnScreenControlCheckbox
237 Layout.fillWidth: true
238 text: qsTr("Enabled")
239 fact: _gimbalControllerSettings.enableOnScreenControl
243 Layout.fillWidth: true
244 text: qsTr("Click and drag")
245 fact: _gimbalControllerSettings.clickAndDrag
246 visible: enableOnScreenControlCheckbox.checked
249 LabelledFactTextField {
250 label: qsTr("Horizontal FOV")
251 fact: _gimbalControllerSettings.cameraHFov
252 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
255 LabelledFactTextField {
256 label: qsTr("Vertical FOV")
257 fact: _gimbalControllerSettings.cameraVFov
258 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
261 LabelledFactTextField {
262 label: qsTr("Max speed")
263 fact: _gimbalControllerSettings.cameraSlideSpeed
264 visible: enableOnScreenControlCheckbox.checked && _gimbalControllerSettings.clickAndDrag.rawValue
268 SettingsGroupLayout {
269 heading: qsTr("Zoom speed")
272 LabelledFactTextField {
273 label: qsTr("Max speed (min zoom)")
274 fact: _gimbalControllerSettings.zoomMaxSpeed
277 LabelledFactTextField {
278 label: qsTr("Min speed (max zoom)")
279 fact: _gimbalControllerSettings.zoomMinSpeed
284 SettingsGroupLayout {
285 LabelledFactTextField {
286 label: qsTr("Joystick buttons speed:")
287 fact: _gimbalControllerSettings.joystickButtonsSpeed
288 enabled: joystickButtonsAvailable && _gimbalControllerSettings.userVisible
292 Layout.fillWidth: true
293 text: qsTr("Show gimbal Azimuth indicator in map")
294 fact: _gimbalControllerSettings.showAzimuthIndicatorOnMap
298 Layout.fillWidth: true
299 text: qsTr("Use Azimuth instead of local yaw on top toolbar indicator")
300 fact: _gimbalControllerSettings.toolbarIndicatorShowAzimuth
304 Layout.fillWidth: true
305 text: qsTr("Show Acquire/Release control button")
306 fact: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl
313 id: acquirePopupConnection
314 property bool isPopupOpen: false
315 target: gimbalController
316 function onShowAcquireGimbalControlPopup() {
317 if(!acquirePopupConnection.isPopupOpen){
318 acquirePopupConnection.isPopupOpen = true;
319 QGroundControl.showMessageDialog(
321 "Request Gimbal Control?",
322 "Command not sent. Another user has control of the gimbal.",
323 Dialog.Yes | Dialog.No,
324 gimbalController.acquireGimbalControl,
325 function() { acquirePopupConnection.isPopupOpen = false }