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