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(qsTr("Gimbal %1").arg(control.gimbalName(gimbal)))
151 if (gimbal === activeGimbal) {
155 gimbalSelectorCombo.model = gimbalModel
156 gimbalSelectorCombo.currentIndex = activeIndex
159 Component.onCompleted: _updateComboModel()
162 function onCountChanged(count) { _updateComboModel() }
167 SettingsGroupLayout {
168 heading: qsTr("Commands")
172 Layout.fillWidth: true
173 text: activeGimbal.yawLock ? qsTr("Yaw Follow") : qsTr("Yaw Lock")
174 visible: activeGimbal.supportsYawLock
176 gimbalController.setGimbalYawLock(!activeGimbal.yawLock)
177 mainWindow.closeIndicatorDrawer()
182 Layout.fillWidth: true
185 gimbalController.centerGimbal()
186 mainWindow.closeIndicatorDrawer()
191 Layout.fillWidth: true
192 text: qsTr("Tilt 90")
194 gimbalController.sendPitchBodyYaw(-90, 0)
195 mainWindow.closeIndicatorDrawer()
200 Layout.fillWidth: true
201 text: qsTr("Point Home")
203 activeVehicle.guidedModeROI(activeVehicle.homePosition)
204 mainWindow.closeIndicatorDrawer()
209 Layout.fillWidth: true
210 text: qsTr("Retract")
211 visible: activeGimbal.supportsRetract
213 gimbalController.setGimbalRetract(true)
214 mainWindow.closeIndicatorDrawer()
219 Layout.fillWidth: true
220 text: activeGimbal.gimbalHaveControl ? qsTr("Release Control") : qsTr("Acquire Control")
221 visible: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl.rawValue
223 activeGimbal.gimbalHaveControl ? gimbalController.releaseGimbalControl() : gimbalController.acquireGimbalControl()
224 mainWindow.closeIndicatorDrawer()
232 id: gimbalExpandedComponent
235 spacing: ScreenTools.defaultFontPixelWidth / 2
237 SettingsGroupLayout {
238 heading: qsTr("On-Screen Control")
242 id: enableOnScreenControlCheckbox
243 Layout.fillWidth: true
244 text: qsTr("Enabled")
245 fact: _gimbalControllerSettings.enableOnScreenControl
249 Layout.fillWidth: true
250 text: qsTr("Click and drag")
251 fact: _gimbalControllerSettings.clickAndDrag
252 visible: enableOnScreenControlCheckbox.checked
255 LabelledFactTextField {
256 label: qsTr("Horizontal FOV")
257 fact: _gimbalControllerSettings.cameraHFov
258 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
261 LabelledFactTextField {
262 label: qsTr("Vertical FOV")
263 fact: _gimbalControllerSettings.cameraVFov
264 visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
267 LabelledFactTextField {
268 label: qsTr("Max speed")
269 fact: _gimbalControllerSettings.cameraSlideSpeed
270 visible: enableOnScreenControlCheckbox.checked && _gimbalControllerSettings.clickAndDrag.rawValue
274 SettingsGroupLayout {
275 heading: qsTr("Zoom speed")
278 LabelledFactTextField {
279 label: qsTr("Max speed (min zoom)")
280 fact: _gimbalControllerSettings.zoomMaxSpeed
283 LabelledFactTextField {
284 label: qsTr("Min speed (max zoom)")
285 fact: _gimbalControllerSettings.zoomMinSpeed
290 SettingsGroupLayout {
291 LabelledFactTextField {
292 label: qsTr("Joystick buttons speed:")
293 fact: _gimbalControllerSettings.joystickButtonsSpeed
294 enabled: joystickButtonsAvailable && _gimbalControllerSettings.userVisible
298 Layout.fillWidth: true
299 text: qsTr("Show gimbal Azimuth indicator in map")
300 fact: _gimbalControllerSettings.showAzimuthIndicatorOnMap
304 Layout.fillWidth: true
305 text: qsTr("Use Azimuth instead of local yaw on top toolbar indicator")
306 fact: _gimbalControllerSettings.toolbarIndicatorShowAzimuth
310 Layout.fillWidth: true
311 text: qsTr("Show Acquire/Release control button")
312 fact: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl
319 id: acquirePopupConnection
320 property bool isPopupOpen: false
321 target: gimbalController
322 function onShowAcquireGimbalControlPopup() {
323 if(!acquirePopupConnection.isPopupOpen){
324 acquirePopupConnection.isPopupOpen = true;
325 QGroundControl.showMessageDialog(
327 "Request Gimbal Control?",
328 "Command not sent. Another user has control of the gimbal.",
329 Dialog.Yes | Dialog.No,
330 gimbalController.acquireGimbalControl,
331 function() { acquirePopupConnection.isPopupOpen = false }