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 readonly property real _dragThreshold: 10
94
95 onDoubleClicked: QGroundControl.videoManager.fullScreen = !QGroundControl.videoManager.fullScreen
96
97 onPressed: (mouse) => {
98 _pressX = mouse.x
99 _pressY = mouse.y
100 _dragging = false
101 }
102
103 onPositionChanged: (mouse) => {
104 if (!_dragging && (Math.abs(mouse.x - _pressX) >= _dragThreshold || Math.abs(mouse.y - _pressY) >= _dragThreshold)) {
105 _dragging = true
106 onScreenGimbalController.mouseDragStart(_pressX, _pressY)
107 cameraTrackingController.mouseDragStart(_pressX, _pressY)
108 }
109 if (_dragging) {
110 onScreenGimbalController.mouseDragPositionChanged(mouse.x, mouse.y)
111 cameraTrackingController.mouseDragPositionChanged(mouse.x, mouse.y)
112 }
113 }
114
115 onReleased: (mouse) => {
116 if (_dragging) {
117 onScreenGimbalController.mouseDragEnd()
118 cameraTrackingController.mouseDragEnd(mouse.x, mouse.y)
119 } else {
120 onScreenGimbalController.mouseClicked(mouse.x, mouse.y)
121 cameraTrackingController.mouseClicked(mouse.x, mouse.y)
122 }
123 _dragging = false
124 }
125 }
126
127 ProximityRadarVideoView{
128 anchors.fill: parent
129 vehicle: QGroundControl.multiVehicleManager.activeVehicle
130 }
131
132 ObstacleDistanceOverlayVideo {
133 id: obstacleDistance
134 showText: pipState.state === pipState.fullState
135 }
136}