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 /// Names a gimbal as "<manager compid>-<device id>", e.g. "154-1", so that gimbals
36 /// belonging to different managers can be told apart.
37 function gimbalName(gimbal) {
38 return gimbal ? (gimbal.managerCompid.valueString + "-" + gimbal.deviceId.valueString) : ""
41 QGCPalette { id: qgcPal }
44 id: gimbalIndicatorRow
45 anchors.top: parent.top
46 anchors.bottom: parent.bottom
47 spacing: ScreenTools.defaultFontPixelWidth / 2
50 anchors.top: parent.top
51 anchors.bottom: parent.bottom
55 id: gimbalIndicatorIcon
56 anchors.horizontalCenter: parent.horizontalCenter
58 height: multiGimbalSetup ? parent.height - gimbalIdLabel.contentHeight : parent.height
59 source: "/res/CameraGimbal.png"
60 fillMode: Image.PreserveAspectFit
61 sourceSize.height: height
68 anchors.horizontalCenter: parent.horizontalCenter
69 font.pointSize: ScreenTools.smallFontPointSize
70 text: control.gimbalName(activeGimbal)
72 visible: multiGimbalSetup
76 // Telemetry and status indicator
78 anchors.verticalCenter: parent.verticalCenter
82 columnSpacing: margins / 2
86 font.pointSize: ScreenTools.smallFontPointSize
87 text: activeGimbal && activeGimbal.retracted ?
89 (activeGimbal && activeGimbal.yawLock ? qsTr("Yaw locked") : qsTr("Yaw follow"))
92 Layout.alignment: Qt.AlignHCenter
96 font.pointSize: ScreenTools.smallFontPointSize
97 text: activeGimbal ? qsTr("P: ") + activeGimbal.absolutePitch.valueString : ""
102 font.pointSize: ScreenTools.smallFontPointSize
105 (qsTr("Az: ") + activeGimbal.absoluteYaw.valueString) :
106 (qsTr("Y: ") + activeGimbal.bodyYaw.valueString)) :
115 onClicked: mainWindow.showIndicatorDrawer(gimbalPopup, control)
123 waitForParameters: false
124 contentComponent: gimbalContentComponent
125 expandedComponent: gimbalExpandedComponent
130 id: gimbalContentComponent
133 spacing: ScreenTools.defaultFontPixelWidth / 2
135 SettingsGroupLayout {
136 heading: qsTr("Active Gimbal")
137 visible: multiGimbalSetup
140 id: gimbalSelectorCombo
141 Layout.fillWidth: true
142 visible: multiGimbalSetup
143 onCurrentIndexChanged: gimbalController.activeGimbal = gimbalController.gimbals.get(currentIndex)
145 function _updateComboModel() {
148 for (var i = 0; i < gimbals.count; i++) {
149 var gimbal = gimbals.get(i)
150 gimbalModel.push(gimbal.deviceName ?
151 qsTr("%1 (%2)").arg(gimbal.deviceName).arg(control.gimbalName(gimbal)) :
152 qsTr("Gimbal %1").arg(control.gimbalName(gimbal)))
153 if (gimbal === activeGimbal) {
157 gimbalSelectorCombo.model = gimbalModel
158 gimbalSelectorCombo.currentIndex = activeIndex
161 Component.onCompleted: _updateComboModel()
164 function onCountChanged(count) { _updateComboModel() }
168 delegate: Connections {
170 function onDeviceNameChanged() { gimbalSelectorCombo._updateComboModel() }
176 SettingsGroupLayout {
177 heading: qsTr("Commands")
181 Layout.fillWidth: true
182 text: activeGimbal.yawLock ? qsTr("Yaw Follow") : qsTr("Yaw Lock")
183 visible: activeGimbal.supportsYawLock
185 gimbalController.setGimbalYawLock(!activeGimbal.yawLock)
186 mainWindow.closeIndicatorDrawer()
191 Layout.fillWidth: true
194 gimbalController.centerGimbal()
195 mainWindow.closeIndicatorDrawer()
200 Layout.fillWidth: true
201 text: qsTr("Tilt 90")
203 gimbalController.sendPitchBodyYaw(-90, 0)
204 mainWindow.closeIndicatorDrawer()
209 Layout.fillWidth: true
210 text: qsTr("Point Home")
212 activeVehicle.guidedModeROI(activeVehicle.homePosition, 0)
213 mainWindow.closeIndicatorDrawer()
218 Layout.fillWidth: true
219 text: qsTr("Retract")
220 visible: activeGimbal.supportsRetract
222 gimbalController.setGimbalRetract(true)
223 mainWindow.closeIndicatorDrawer()
228 Layout.fillWidth: true
229 text: activeGimbal.gimbalHaveControl ? qsTr("Release Control") : qsTr("Acquire Control")
230 visible: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl.rawValue
232 activeGimbal.gimbalHaveControl ? gimbalController.releaseGimbalControl() : gimbalController.acquireGimbalControl()
233 mainWindow.closeIndicatorDrawer()
241 id: gimbalExpandedComponent
244 spacing: ScreenTools.defaultFontPixelWidth / 2
246 SettingsGroupLayout {
247 heading: qsTr("On-Screen Control")
251 id: enableOnScreenControlCheckbox
252 Layout.fillWidth: true
253 text: qsTr("Enabled")
254 fact: _gimbalControllerSettings.enableOnScreenControl
258 Layout.fillWidth: true
259 text: qsTr("Click and drag")
260 fact: _gimbalControllerSettings.clickAndDrag
261 visible: enableOnScreenControlCheckbox.checked
264 LabelledFactTextField {
265 label: qsTr("Horizontal FOV")
266 fact: _gimbalControllerSettings.cameraHFov
267 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
270 LabelledFactTextField {
271 label: qsTr("Vertical FOV")
272 fact: _gimbalControllerSettings.cameraVFov
273 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
276 LabelledFactTextField {
277 label: qsTr("Max speed")
278 fact: _gimbalControllerSettings.cameraSlideSpeed
279 visible: enableOnScreenControlCheckbox.checked && _gimbalControllerSettings.clickAndDrag.rawValue
283 SettingsGroupLayout {
284 heading: qsTr("Zoom speed")
287 LabelledFactTextField {
288 label: qsTr("Max speed (min zoom)")
289 fact: _gimbalControllerSettings.zoomMaxSpeed
292 LabelledFactTextField {
293 label: qsTr("Min speed (max zoom)")
294 fact: _gimbalControllerSettings.zoomMinSpeed
299 SettingsGroupLayout {
300 LabelledFactTextField {
301 label: qsTr("Joystick buttons speed:")
302 fact: _gimbalControllerSettings.joystickButtonsSpeed
303 enabled: joystickButtonsAvailable && _gimbalControllerSettings.userVisible
307 Layout.fillWidth: true
308 text: qsTr("Show gimbal Azimuth indicator in map")
309 fact: _gimbalControllerSettings.showAzimuthIndicatorOnMap
313 Layout.fillWidth: true
314 text: qsTr("Use Azimuth instead of local yaw on top toolbar indicator")
315 fact: _gimbalControllerSettings.toolbarIndicatorShowAzimuth
319 Layout.fillWidth: true
320 text: qsTr("Show Acquire/Release control button")
321 fact: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl
328 id: acquirePopupConnection
329 property bool isPopupOpen: false
330 target: gimbalController
331 function onShowAcquireGimbalControlPopup() {
332 if(!acquirePopupConnection.isPopupOpen){
333 acquirePopupConnection.isPopupOpen = true;
334 QGroundControl.showMessageDialog(
336 qsTr("Request Gimbal Control?"),
337 qsTr("Command not sent. Another user has control of the gimbal."),
338 Dialog.Yes | Dialog.No,
339 gimbalController.acquireGimbalControl,
340 function() { acquirePopupConnection.isPopupOpen = false }