8import QGroundControl.Controls
9import QGroundControl.FactControls
10import QGroundControl.VideoManager
14 width: mainLayout.width + (_smallMargins * 2)
15 height: mainLayout.height + (_smallMargins * 2)
16 color: Qt.rgba(qgcPal.window.r, qgcPal.window.g, qgcPal.window.b, 0.5)
18 visible: _camera.capturesVideo || _camera.capturesPhotos || _camera.hasTracking || _camera.hasVideoStream
20 property real _margins: ScreenTools.defaultFontPixelHeight / 2
21 property real _smallMargins: ScreenTools.defaultFontPixelWidth / 2
22 property var _activeVehicle: globals.activeVehicle
23 property var _cameraManager: _activeVehicle.cameraManager
24 property var _camera: _cameraManager.currentCameraInstance
25 property bool _cameraInPhotoMode: _camera.cameraMode === MavlinkCameraControlInterface.CAM_MODE_PHOTO || _camera.cameraMode === MavlinkCameraControlInterface.CAM_MODE_SURVEY
26 property bool _cameraInVideoMode: !_cameraInPhotoMode
27 property bool _videoCaptureIdle: _camera.captureVideoState === MavlinkCameraControlInterface.CaptureVideoStateIdle
28 property bool _photoCaptureIdle: _camera.capturePhotosState === MavlinkCameraControlInterface.CapturePhotosStateIdle
30 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
32 DeadMouseArea { anchors.fill: parent }
36 anchors.margins: _smallMargins
37 anchors.top: parent.top
38 anchors.left: parent.left
42 Layout.fillHeight: true
44 visible: _camera.hasZoom
47 Layout.alignment: Qt.AlignHCenter
49 font.pointSize: ScreenTools.smallFontPointSize
53 objectName: "photoVideoControl_zoomSlider"
54 Layout.alignment: Qt.AlignHCenter
55 Layout.fillHeight: true
56 orientation: Qt.Vertical
59 value: _camera.zoomLevel
61 onMoved: _camera.zoomLevel = value
70 Layout.alignment: Qt.AlignHCenter
71 text: _camera.modelName
72 visible: _cameraManager.cameras.length > 1
75 // Photo/Video Mode Selector
77 Layout.alignment: Qt.AlignHCenter
78 width: ScreenTools.defaultFontPixelWidth * 10
80 color: qgcPal.windowCard
81 border.color: qgcPal.borderSubtle
83 visible: _camera.hasModes
87 anchors.verticalCenter: parent.verticalCenter
90 color: _cameraInVideoMode ? qgcPal.window : qgcPal.windowCard
92 anchors.left: parent.left
93 border.color: qgcPal.textPrimary
94 border.width: _cameraInPhotoMode ? 0 : 1
97 height: parent.height * 0.5
99 anchors.centerIn: parent
100 source: "/qmlimages/camera_video.svg"
101 fillMode: Image.PreserveAspectFit
102 sourceSize.height: height
103 color: _cameraInVideoMode ? qgcPal.colorGreen : qgcPal.textPrimary
107 enabled: _cameraInPhotoMode ? _photoCaptureIdle : true
108 onClicked: _camera.setCameraModeVideo()
115 anchors.verticalCenter: parent.verticalCenter
117 height: parent.height
118 color: _cameraInPhotoMode ? qgcPal.window : qgcPal.windowCard
120 anchors.right: parent.right
121 border.color: qgcPal.textPrimary
122 border.width: _cameraInPhotoMode ? 1 : 0
125 height: parent.height * 0.5
127 anchors.centerIn: parent
128 source: "/qmlimages/camera_photo.svg"
129 fillMode: Image.PreserveAspectFit
130 sourceSize.height: height
131 color: _cameraInPhotoMode ? qgcPal.colorGreen : qgcPal.textPrimary
135 enabled: _cameraInVideoMode ? _videoCaptureIdle : true
136 onClicked: _camera.setCameraModePhoto()
143 Layout.alignment: Qt.AlignHCenter
144 spacing: _smallMargins
146 // Start/Stop Video button
148 id: videoCaptureButton
149 Layout.alignment: Qt.AlignHCenter
150 color: videoCaptureButtonPalette.windowCard
151 width: ScreenTools.defaultFontPixelWidth * 6
155 border.color: videoCaptureButtonPalette.textSecondary
156 visible: (_camera.hasModes && _cameraInVideoMode) || (!_camera.hasModes && _camera.capturesVideo)
157 enabled: _camera.captureVideoState !== MavlinkCameraControlInterface.CaptureVideoStateDisabled
159 QGCPalette { id: videoCaptureButtonPalette; colorGroupEnabled: videoCaptureButton.enabled }
162 anchors.centerIn: parent
163 anchors.alignWhenCentered: false // Prevents anchors.centerIn from snapping to integer coordinates, which can throw off centering.
164 color: videoCaptureButtonPalette.textSecondary
165 width: parent.width * 0.75
171 anchors.centerIn: parent
172 anchors.alignWhenCentered: false // Prevents anchors.centerIn from snapping to integer coordinates, which can throw off centering.
173 width: parent.width * (_isCapturing ? 0.5 : 0.75)
175 radius: _isCapturing ? ScreenTools.defaultFontPixelWidth * 0.5 : width * 0.5
176 color: videoCaptureButtonPalette.videoCaptureButtonColor
178 border.color: videoCaptureButtonPalette.textSecondary
180 property bool _isCapturing: _camera.captureVideoState === MavlinkCameraControlInterface.CaptureVideoStateCapturing
185 onClicked: _camera.toggleVideoRecording()
190 Layout.alignment: Qt.AlignHCenter
192 font.pointSize: ScreenTools.smallFontPointSize
193 visible: videoCaptureButton.visible && photoCaptureButton.visible
198 Layout.alignment: Qt.AlignHCenter
199 color: _videoCaptureIdle ? "transparent" : videoCaptureButtonPalette.videoCaptureButtonColor
200 Layout.preferredWidth: videoRecordTime.width + (_smallMargins * 2)
201 Layout.preferredHeight: videoRecordTime.height
202 radius: _smallMargins
203 visible: videoCaptureButton.visible
208 anchors.leftMargin: _smallMargins
209 anchors.left: parent.left
210 anchors.top: parent.top
211 text: _videoCaptureIdle ? "00:00:00" : _camera.recordTimeStr
216 Layout.alignment: Qt.AlignHCenter
219 visible: videoCaptureButton.visible && photoCaptureButton.visible
224 id: photoCaptureButton
225 objectName: "photoVideoControl_photoCaptureButton"
226 Layout.alignment: Qt.AlignHCenter
227 color: photoCaptureButtonPalette.windowCard
228 width: ScreenTools.defaultFontPixelWidth * 6
232 border.color: photoCaptureButtonPalette.textSecondary
233 visible: (_camera.hasModes && _cameraInPhotoMode) || (!_camera.hasModes && (_camera.hasVideoStream || _camera.capturesPhotos))
234 enabled: _camera.capturePhotosState !== MavlinkCameraControlInterface.CapturePhotosStateDisabled
236 QGCPalette { id: photoCaptureButtonPalette; colorGroupEnabled: photoCaptureButton.enabled }
239 anchors.centerIn: parent
240 anchors.alignWhenCentered: false // Prevents anchors.centerIn from snapping to integer coordinates, which can throw off centering.
241 color: photoCaptureButtonPalette.textSecondary
242 width: parent.width * 0.75
248 anchors.centerIn: parent
249 anchors.alignWhenCentered: false // Prevents anchors.centerIn from snapping to integer coordinates, which can throw off centering.
250 width: parent.width * (_isCapturing ? 0.5 : 0.75)
252 radius: _isCapturing ? ScreenTools.defaultFontPixelWidth * 0.5 : width * 0.5
253 color: photoCaptureButtonPalette.photoCaptureButtonColor
255 border.color: photoCaptureButtonPalette.textSecondary
257 property bool _isCapturing: _camera.capturePhotosState === MavlinkCameraControlInterface.CapturePhotosStateCapturingSinglePhoto ||
258 _camera.capturePhotosState === MavlinkCameraControlInterface.CapturePhotosStateCapturingMultiplePhotos
264 if (_camera.capturePhotosState === MavlinkCameraControlInterface.CapturePhotosStateCapturingMultiplePhotos) {
265 _camera.stopTakePhoto()
266 } else if (_camera.capturePhotosState === MavlinkCameraControlInterface.CapturePhotosStateIdle) {
274 Layout.alignment: Qt.AlignHCenter
276 font.pointSize: ScreenTools.smallFontPointSize
277 visible: videoCaptureButton.visible && photoCaptureButton.visible
282 Layout.alignment: Qt.AlignHCenter
283 color: _photoCaptureIdle ? "transparent" : photoCaptureButtonPalette.photoCaptureButtonColor
284 Layout.preferredWidth: photoCaptureCount.width + (_smallMargins * 2)
285 Layout.preferredHeight: photoCaptureCount.height
286 radius: _smallMargins
287 visible: photoCaptureButton.visible
289 // Photo capture count
291 id: photoCaptureCount
292 anchors.leftMargin: _smallMargins
293 anchors.left: parent.left
294 anchors.top: parent.top
295 text: _activeVehicle ? ('00000' + _activeVehicle.cameraTriggerPoints.count).slice(-5) : "00000"
300 //-- Status Information
302 Layout.alignment: Qt.AlignHCenter
304 visible: storageStatus.visible || batteryStatus.visible
308 Layout.alignment: Qt.AlignHCenter
309 text: qsTr("Free: ") + _camera.storageFreeStr
310 font.pointSize: ScreenTools.defaultFontPointSize
311 visible: _camera.storageStatus === MavlinkCameraControlInterface.STORAGE_READY
316 Layout.alignment: Qt.AlignHCenter
317 text: qsTr("Battery: ") + _camera.batteryRemainingStr
318 font.pointSize: ScreenTools.defaultFontPointSize
319 visible: _camera.batteryRemaining >= 0
325 Layout.alignment: Qt.AlignHCenter
327 visible: _camera.hasTracking
330 Layout.alignment: Qt.AlignHCenter
331 color: _camera.trackingEnabled ? qgcPal.colorRed : qgcPal.windowCard
332 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 6
333 Layout.preferredHeight: Layout.preferredWidth
334 border.color: qgcPal.textPrimary
338 height: parent.height * 0.5
340 anchors.centerIn: parent
341 source: "/qmlimages/TrackingIcon.svg"
342 fillMode: Image.PreserveAspectFit
343 sourceSize.height: height
344 color: qgcPal.textPrimary
349 _camera.trackingEnabled = !_camera.trackingEnabled;
350 if (!_camera.trackingEnabled) {
351 _camera.stopTracking()
359 Layout.alignment: Qt.AlignHCenter
360 text: qsTr("Camera Tracking")
361 font.pointSize: ScreenTools.smallFontPointSize
366 Layout.alignment: Qt.AlignHCenter
367 source: "/res/gear-black.svg"
369 Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
370 Layout.preferredWidth: Layout.preferredHeight
371 sourceSize.height: Layout.preferredHeight
372 color: qgcPal.textPrimary
373 fillMode: Image.PreserveAspectFit
377 onClicked: settingsDialogFactory.open()
382 QGCPopupDialogFactory {
383 id: settingsDialogFactory
385 dialogComponent: settingsDialogComponent
389 id: settingsDialogComponent
392 title: qsTr("Settings")
393 buttons: Dialog.Close
395 property bool _multipleMavlinkCameras: _cameraManager.cameras.count > 1
396 property bool _multipleMavlinkCameraStreams: _camera.streamLabels.length > 1
397 property bool _cameraStorageSupported: _camera.storageStatus !== MavlinkCameraControlInterface.STORAGE_NOT_SUPPORTED
404 flow: GridLayout.TopToBottom
405 rows: dynamicRows + _camera.activeSettings.length
407 property int dynamicRows: 8
412 visible: _multipleMavlinkCameras
413 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
417 text: qsTr("Video Stream")
418 visible: _multipleMavlinkCameraStreams
419 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
423 text: qsTr("Thermal View Mode")
424 visible: _camera.thermalStreamInstance
425 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
429 text: qsTr("Blend Opacity")
430 visible: _camera.thermalStreamInstance && _camera.thermalMode === MavlinkCameraControlInterface.THERMAL_BLEND
431 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
434 // Mavlink Camera Protocol active settings
436 model: _camera.activeSettings
439 text: _camera.getFact(modelData).shortDescription
444 text: qsTr("Photo Mode")
445 visible: _camera.capturesPhotos
446 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
450 text: qsTr("Photo Interval (seconds)")
451 visible: _camera.capturesPhotos && _camera.photoCaptureMode === MavlinkCameraControlInterface.PHOTO_CAPTURE_TIMELAPSE
452 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
456 text: qsTr("Reset Camera Defaults")
457 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
461 text: qsTr("Storage")
462 visible: _cameraStorageSupported
463 onVisibleChanged: gridLayout.dynamicRows += visible ? 1 : -1
468 Layout.fillWidth: true
470 model: _cameraManager.cameraLabels
471 currentIndex: _cameraManager.currentCamera
472 visible: _multipleMavlinkCameras
473 onActivated: (index) => { _cameraManager.currentCamera = index }
477 Layout.fillWidth: true
479 model: _camera.streamLabels
480 currentIndex: _camera.currentStream
481 visible: _multipleMavlinkCameraStreams
482 onActivated: (index) => { _camera.currentStream = index }
486 Layout.fillWidth: true
488 model: [ qsTr("Off"), qsTr("Blend"), qsTr("Full"), qsTr("Picture In Picture") ]
489 currentIndex: _camera.thermalMode
490 visible: _camera.thermalStreamInstance
491 onActivated: (index) => { _camera.thermalMode = index }
495 Layout.fillWidth: true
498 value: _camera.thermalOpacity
500 visible: _camera.thermalStreamInstance && _camera.thermalMode === MavlinkCameraControlInterface.THERMAL_BLEND
501 onValueChanged: _camera.thermalOpacity = value
504 // Mavlink Camera Protocol active settings
506 model: _camera.activeSettings
509 Layout.fillWidth: true
510 spacing: ScreenTools.defaultFontPixelWidth
512 property var _fact: _camera.getFact(modelData)
513 property bool _isBool: _fact.typeIsBool
514 property bool _isCombo: !_isBool && _fact.enumStrings.length > 0
515 property bool _isSlider: _fact && !isNaN(_fact.increment)
516 property bool _isEdit: !_isBool && !_isSlider && _fact.enumStrings.length < 1
517 property bool _isReadOnly: _fact && _fact.readOnly
520 Layout.fillWidth: true
524 visible: parent._isCombo
525 enabled: !parent._isReadOnly
528 Layout.fillWidth: true
530 visible: parent._isEdit
531 enabled: !parent._isReadOnly
534 Layout.fillWidth: true
536 from: parent._fact.min
537 stepSize: parent._fact.increment
538 visible: parent._isSlider
539 enabled: !parent._isReadOnly
541 property bool initialized: false
547 parent._fact.value = value
550 Component.onCompleted: {
551 value = parent._fact.value
556 checked: parent._fact ? parent._fact.value : false
557 visible: parent._isBool
558 enabled: !parent._isReadOnly
559 onClicked: parent._fact.value = checked ? 1 : 0
565 Layout.fillWidth: true
567 model: [ qsTr("Single"), qsTr("Time Lapse") ]
568 currentIndex: _camera.photoCaptureMode
569 visible: _camera.capturesPhotos
570 onActivated: (index) => { _camera.photoCaptureMode = index }
574 Layout.fillWidth: true
578 value: _camera.photoLapse
581 visible: _camera.capturesPhotos && _camera.photoCaptureMode === MavlinkCameraControlInterface.PHOTO_CAPTURE_TIMELAPSE
582 onValueChanged: _camera.photoLapse = value
586 Layout.fillWidth: true
588 onClicked: resetPrompt.open()
591 title: qsTr("Reset Camera to Factory Settings")
592 text: qsTr("Confirm resetting all settings?")
593 buttons: MessageDialog.Yes | MessageDialog.No
595 onButtonClicked: function (button, role) {
597 case MessageDialog.Yes:
598 _camera.resetSettings()
601 case MessageDialog.No:
610 Layout.fillWidth: true
612 visible: _cameraStorageSupported
613 onClicked: formatPrompt.open()
616 title: qsTr("Format Camera Storage")
617 text: qsTr("Confirm erasing all files?")
618 buttons: MessageDialog.Yes | MessageDialog.No
620 onButtonClicked: function (button, role) {
622 case MessageDialog.Yes:
626 case MessageDialog.No:
635 VideoDisplaySettingsGroup {
636 visible: _camera.hasVideoStream