QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlyViewVideo.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5import QGroundControl.VideoManager
6
7Item {
8 id: root
9
10 property Item pipView
11 /// Height the Fly View toolbar covers at the top of the full-size video.
12 property real topInset: 0
13 /// Width the Fly View's widgets cover at the top right of the full-size video.
14 property real rightInset: 0
15 property Item pipState: videoPipState
16 /// The manager whose video the view shows.
17 property VideoManager videoManager: QGroundControl.videoManager
18
19 PipState {
20 id: videoPipState
21 pipView: root.pipView
22 isDark: true
23
24 onStateChanged: {
25 if (videoPipState.state !== videoPipState.fullState) {
26 root.videoManager.fullScreen = false
27 }
28 }
29 }
30
31 //-- Video Streaming
32 VideoView {
33 id: videoStreaming
34 anchors.fill: parent
35 useSmallFont: root.pipState.state !== root.pipState.fullState
36 thermalPipTopInset: root.pipState.state === root.pipState.fullState ? root.topInset : 0
37 showTiles: root.pipState.state === root.pipState.fullState
38 tilesRightInset: root.rightInset
39 videoManager: root.videoManager
40 visible: root.videoManager.isStreamSource || root.videoManager.isUvc
41 }
42
43 QGCLabel {
44 text: qsTr("Double-click to exit full screen")
45 font.pointSize: ScreenTools.largeFontPointSize
46 visible: root.videoManager.fullScreen
47 anchors.centerIn: parent
48
49 onVisibleChanged: {
50 if (visible) {
51 labelAnimation.start()
52 }
53 }
54
55 PropertyAnimation on opacity {
56 id: labelAnimation
57 duration: 10000
58 from: 1.0
59 to: 0.0
60 easing.type: Easing.InExpo
61 }
62 }
63
64 OnScreenGimbalController {
65 id: onScreenGimbalController
66 anchors.fill: parent
67 cameraTrackingEnabled: !!(videoStreaming.camera && videoStreaming.camera.trackingEnabled)
68 }
69
70 OnScreenCameraTrackingController {
71 id: cameraTrackingController
72 anchors.fill: parent
73 camera: videoStreaming.camera
74 videoWidth: videoStreaming.videoWidth
75 videoHeight: videoStreaming.videoHeight
76 }
77
78 MouseArea {
79 id: flyViewVideoMouseArea
80
81 property real _pressX: 0
82 property real _pressY: 0
83 property bool _dragging: false
84 property bool _doubleClicked: false
85 readonly property real _dragThreshold: 10
86
87 anchors.fill: parent
88 enabled: root.pipState.state === root.pipState.fullState
89
90 // Defer single-click handling so a double-click (fullscreen toggle) doesn't also
91 // fire an unintended gimbal click-to-point/tracking command on its first click.
92 Timer {
93 id: singleClickTimer
94
95 property real clickX: 0
96 property real clickY: 0
97
98 interval: Qt.styleHints.mouseDoubleClickInterval
99 repeat: false
100
101 onTriggered: {
102 onScreenGimbalController.mouseClicked(clickX, clickY)
103 cameraTrackingController.mouseClicked(clickX, clickY)
104 }
105 }
106
107 onDoubleClicked: (mouse) => {
108 if (videoStreaming.tileAt(mouse.x, mouse.y)) {
109 mouse.accepted = false
110 return
111 }
112 // Fires on the second press of a double-click. The second release still emits
113 // onReleased, so flag it to prevent re-arming the single-click timer.
114 _doubleClicked = true
115 singleClickTimer.stop()
116 root.videoManager.fullScreen = !root.videoManager.fullScreen
117 }
118
119 onPressed: (mouse) => {
120 // A press on a video tile is the tile's, which is below this area.
121 if (videoStreaming.tileAt(mouse.x, mouse.y)) {
122 mouse.accepted = false
123 return
124 }
125 _pressX = mouse.x
126 _pressY = mouse.y
127 _dragging = false
128 // Clear any stale flag (e.g. double-click followed by drag releases through the
129 // drag branch without consuming it). Safe: pressed is emitted before doubleClicked.
130 _doubleClicked = false
131 }
132
133 onPositionChanged: (mouse) => {
134 if (!_dragging && (Math.abs(mouse.x - _pressX) >= _dragThreshold || Math.abs(mouse.y - _pressY) >= _dragThreshold)) {
135 _dragging = true
136 onScreenGimbalController.mouseDragStart(_pressX, _pressY)
137 cameraTrackingController.mouseDragStart(_pressX, _pressY)
138 }
139 if (_dragging) {
140 onScreenGimbalController.mouseDragPositionChanged(mouse.x, mouse.y)
141 cameraTrackingController.mouseDragPositionChanged(mouse.x, mouse.y)
142 }
143 }
144
145 onReleased: (mouse) => {
146 if (_dragging) {
147 onScreenGimbalController.mouseDragEnd()
148 cameraTrackingController.mouseDragEnd(mouse.x, mouse.y)
149 } else if (_doubleClicked) {
150 // Second release of a double-click - fullscreen toggle already handled
151 _doubleClicked = false
152 } else {
153 singleClickTimer.clickX = mouse.x
154 singleClickTimer.clickY = mouse.y
155 singleClickTimer.restart()
156 }
157 _dragging = false
158 }
159 }
160
161 ProximityRadarVideoView{
162 anchors.fill: parent
163 vehicle: QGroundControl.multiVehicleManager.activeVehicle
164 }
165
166 ObstacleDistanceOverlayVideo {
167 id: obstacleDistance
168 showText: root.pipState.state === root.pipState.fullState
169 }
170}