5import QGroundControl.FlyView
6import QGroundControl.FlightMap
7import QGroundControl.Controls
13 property bool useSmallFont: true
15 property double _ar: (cameraLoader.visible && cameraLoader.status === Loader.Ready)
16 ? cameraLoader.item.implicitWidth / cameraLoader.item.implicitHeight
17 : QGroundControl.videoManager.aspectRatio
18 property bool _showGrid: QGroundControl.settingsManager.videoSettings.gridLines.rawValue
19 property var _dynamicCameras: globals.activeVehicle ? globals.activeVehicle.cameraManager : null
20 property bool _connected: globals.activeVehicle ? !globals.activeVehicle.communicationLost : false
21 property int _curCameraIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0
22 property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
23 property var _camera: _isCamera ? _dynamicCameras.cameras.get(_curCameraIndex) : null
24 property bool _hasZoom: _camera && _camera.hasZoom
25 property int _fitMode: QGroundControl.settingsManager.videoSettings.videoFit.rawValue
26 property bool _showStreamLoader: QGroundControl.videoManager.decoding
27 property bool _showUvcLoader: QGroundControl.videoManager.isUvc
29 property bool _isMode_FIT_WIDTH: _fitMode === 0
30 property bool _isMode_FIT_HEIGHT: _fitMode === 1
31 property bool _isMode_FILL: _fitMode === 2
32 property bool _isMode_NO_CROP: _fitMode === 3
35 return videoBackground.getWidth()
37 function getHeight() {
38 return videoBackground.getHeight()
41 property double _thermalHeightFactor: 0.85 //-- TODO
46 source: "/res/NoVideoBackground.jpg"
47 fillMode: Image.PreserveAspectCrop
48 visible: !_showStreamLoader && !_showUvcLoader
51 anchors.centerIn: parent
52 width: noVideoLabel.contentWidth + ScreenTools.defaultFontPixelHeight
53 height: noVideoLabel.contentHeight + ScreenTools.defaultFontPixelHeight
54 radius: ScreenTools.defaultFontPixelWidth / 2
61 text: QGroundControl.settingsManager.videoSettings.streamEnabled.rawValue ? qsTr("WAITING FOR VIDEO") : qsTr("VIDEO DISABLED")
64 font.pointSize: useSmallFont ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
65 anchors.centerIn: parent
73 visible: _showStreamLoader || _showUvcLoader
77 || (_isMode_FILL && (root.width/root.height < _ar))
78 || (_isMode_NO_CROP && (root.width/root.height > _ar))){
79 // This return value has different implications depending on the mode
80 // For FIT_HEIGHT and FILL
81 // makes so the video width will be larger than (or equal to) the screen width
83 // makes so the video width will be smaller than (or equal to) the screen width
84 return root.height * _ar
89 function getHeight() {
92 || (_isMode_FILL && (root.width/root.height > _ar))
93 || (_isMode_NO_CROP && (root.width/root.height < _ar))){
94 // This return value has different implications depending on the mode
95 // For FIT_WIDTH and FILL
96 // makes so the video height will be larger than (or equal to) the screen height
98 // makes so the video height will be smaller than (or equal to) the screen height
99 return root.width * (1 / _ar)
105 id: videoStreamLoader
106 anchors.fill: videoContentArea
107 visible: _showStreamLoader
108 sourceComponent: videoOutputComponent
110 property bool videoDisabled: QGroundControl.settingsManager.videoSettings.videoSource.rawValue === QGroundControl.settingsManager.videoSettings.disabledVideoSource
113 id: videoOutputComponent
114 FlightDisplayViewVideoOutput {
117 //-- UVC Video (USB Camera or Video Device)
120 anchors.fill: videoContentArea
121 visible: _showUvcLoader
122 source: _showUvcLoader ? "qrc:/qml/QGroundControl/FlyView/FlightDisplayViewUVC.qml" : "qrc:/qml/QGroundControl/FlyView/FlightDisplayViewDummy.qml"
127 height: parent.getHeight()
128 width: parent.getWidth()
129 anchors.centerIn: parent
130 visible: _showStreamLoader || _showUvcLoader
135 visible: _showGrid && !QGroundControl.videoManager.fullScreen
138 color: Qt.rgba(1,1,1,0.5)
139 height: parent.height
141 x: parent.width * 0.33
144 color: Qt.rgba(1,1,1,0.5)
145 height: parent.height
147 x: parent.width * 0.66
150 color: Qt.rgba(1,1,1,0.5)
153 y: parent.height * 0.33
156 color: Qt.rgba(1,1,1,0.5)
159 y: parent.height * 0.66
167 width: height * QGroundControl.videoManager.thermalAspectRatio
168 height: _camera ? (_camera.thermalMode === MavlinkCameraControlInterface.THERMAL_FULL ? parent.height : (_camera.thermalMode === MavlinkCameraControlInterface.THERMAL_PIP ? ScreenTools.defaultFontPixelHeight * 12 : parent.height * _thermalHeightFactor)) : 0
169 anchors.centerIn: parent
170 visible: QGroundControl.videoManager.hasThermal && _camera && _camera.thermalMode !== MavlinkCameraControlInterface.THERMAL_OFF
171 function pipOrNot() {
173 if(_camera.thermalMode === MavlinkCameraControlInterface.THERMAL_PIP) {
174 anchors.centerIn = undefined
175 anchors.top = parent.top
176 anchors.topMargin = mainWindow.header.height + (ScreenTools.defaultFontPixelHeight * 0.5)
177 anchors.left = parent.left
178 anchors.leftMargin = ScreenTools.defaultFontPixelWidth * 12
180 anchors.top = undefined
181 anchors.topMargin = undefined
182 anchors.left = undefined
183 anchors.leftMargin = undefined
184 anchors.centerIn = parent
190 function onThermalModeChanged() { thermalItem.pipOrNot() }
193 thermalItem.pipOrNot()
198 opacity: _camera ? (_camera.thermalMode === MavlinkCameraControlInterface.THERMAL_BLEND ? _camera.thermalOpacity / 100 : 1.0) : 0
199 sourceComponent: thermalOutputComponent
200 onLoaded: { if (item) item.objectName = "thermalVideo" }
203 id: thermalOutputComponent
204 FlightDisplayViewVideoOutput {}
213 onPinchStarted: pinchZoom.zoom = 0
217 if(pinch.scale < 1) {
218 z = Math.round(pinch.scale * -10)
220 z = Math.round(pinch.scale)
222 if(pinchZoom.zoom != z) {