5import QGroundControl.FlyView
6import QGroundControl.FlightMap
7import QGroundControl.Controls
13 property bool useSmallFont: true
15 property double _ar: QGroundControl.videoManager.gstreamerEnabled
16 ? QGroundControl.videoManager.videoSize.width / QGroundControl.videoManager.videoSize.height
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
27 property bool _isMode_FIT_WIDTH: _fitMode === 0
28 property bool _isMode_FIT_HEIGHT: _fitMode === 1
29 property bool _isMode_FILL: _fitMode === 2
30 property bool _isMode_NO_CROP: _fitMode === 3
33 return videoBackground.getWidth()
35 function getHeight() {
36 return videoBackground.getHeight()
39 property double _thermalHeightFactor: 0.85 //-- TODO
44 source: "/res/NoVideoBackground.jpg"
45 fillMode: Image.PreserveAspectCrop
46 visible: !(QGroundControl.videoManager.decoding)
49 anchors.centerIn: parent
50 width: noVideoLabel.contentWidth + ScreenTools.defaultFontPixelHeight
51 height: noVideoLabel.contentHeight + ScreenTools.defaultFontPixelHeight
52 radius: ScreenTools.defaultFontPixelWidth / 2
59 text: QGroundControl.settingsManager.videoSettings.streamEnabled.rawValue ? qsTr("WAITING FOR VIDEO") : qsTr("VIDEO DISABLED")
62 font.pointSize: useSmallFont ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
63 anchors.centerIn: parent
71 visible: QGroundControl.videoManager.decoding
75 || (_isMode_FILL && (root.width/root.height < _ar))
76 || (_isMode_NO_CROP && (root.width/root.height > _ar))){
77 // This return value has different implications depending on the mode
78 // For FIT_HEIGHT and FILL
79 // makes so the video width will be larger than (or equal to) the screen width
81 // makes so the video width will be smaller than (or equal to) the screen width
82 return root.height * _ar
87 function getHeight() {
90 || (_isMode_FILL && (root.width/root.height > _ar))
91 || (_isMode_NO_CROP && (root.width/root.height < _ar))){
92 // This return value has different implications depending on the mode
93 // For FIT_WIDTH and FILL
94 // makes so the video height will be larger than (or equal to) the screen height
96 // makes so the video height will be smaller than (or equal to) the screen height
97 return root.width * (1 / _ar)
103 id: videoBackgroundComponent
106 objectName: "videoContent"
109 target: QGroundControl.videoManager
110 function onImageFileChanged(filename) {
111 videoContent.grabToImage(function(result) {
112 if (!result.saveToFile(filename)) {
113 console.error('Error capturing video frame');
120 color: Qt.rgba(1,1,1,0.5)
121 height: parent.height
123 x: parent.width * 0.33
124 visible: _showGrid && !QGroundControl.videoManager.fullScreen
127 color: Qt.rgba(1,1,1,0.5)
128 height: parent.height
130 x: parent.width * 0.66
131 visible: _showGrid && !QGroundControl.videoManager.fullScreen
134 color: Qt.rgba(1,1,1,0.5)
137 y: parent.height * 0.33
138 visible: _showGrid && !QGroundControl.videoManager.fullScreen
141 color: Qt.rgba(1,1,1,0.5)
144 y: parent.height * 0.66
145 visible: _showGrid && !QGroundControl.videoManager.fullScreen
150 // GStreamer is causing crashes on Lenovo laptop OpenGL Intel drivers. In order to workaround this
151 // we don't load a QGCVideoBackground object when video is disabled. This prevents any video rendering
152 // code from running. Hence the Loader to completely remove it.
153 height: parent.getHeight()
154 width: parent.getWidth()
155 anchors.centerIn: parent
156 visible: QGroundControl.videoManager.decoding
157 sourceComponent: videoBackgroundComponent
159 property bool videoDisabled: QGroundControl.settingsManager.videoSettings.videoSource.rawValue === QGroundControl.settingsManager.videoSettings.disabledVideoSource
165 width: height * QGroundControl.videoManager.thermalAspectRatio
166 height: _camera ? (_camera.thermalMode === MavlinkCameraControl.THERMAL_FULL ? parent.height : (_camera.thermalMode === MavlinkCameraControl.THERMAL_PIP ? ScreenTools.defaultFontPixelHeight * 12 : parent.height * _thermalHeightFactor)) : 0
167 anchors.centerIn: parent
168 visible: QGroundControl.videoManager.hasThermal && _camera.thermalMode !== MavlinkCameraControl.THERMAL_OFF
169 function pipOrNot() {
171 if(_camera.thermalMode === MavlinkCameraControl.THERMAL_PIP) {
172 anchors.centerIn = undefined
173 anchors.top = parent.top
174 anchors.topMargin = mainWindow.header.height + (ScreenTools.defaultFontPixelHeight * 0.5)
175 anchors.left = parent.left
176 anchors.leftMargin = ScreenTools.defaultFontPixelWidth * 12
178 anchors.top = undefined
179 anchors.topMargin = undefined
180 anchors.left = undefined
181 anchors.leftMargin = undefined
182 anchors.centerIn = parent
188 function onThermalModeChanged() { thermalItem.pipOrNot() }
191 thermalItem.pipOrNot()
195 objectName: "thermalVideo"
197 opacity: _camera ? (_camera.thermalMode === MavlinkCameraControl.THERMAL_BLEND ? _camera.thermalOpacity / 100 : 1.0) : 0
205 onPinchStarted: pinchZoom.zoom = 0
209 if(pinch.scale < 1) {
210 z = Math.round(pinch.scale * -10)
212 z = Math.round(pinch.scale)
214 if(pinchZoom.zoom != z) {