FlightDisplayViewVideo.qml 4.39 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10


11 12
import QtQuick                          2.3
import QtQuick.Controls                 1.2
13

14 15 16 17 18 19 20 21
import QGroundControl                   1.0
import QGroundControl.FlightDisplay     1.0
import QGroundControl.FlightMap         1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.Palette           1.0
import QGroundControl.Vehicle           1.0
import QGroundControl.Controllers       1.0
22

dogmaphobic's avatar
dogmaphobic committed
23 24
Item {
    id: root
25 26
    property double _ar:                QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue
    property bool   _showGrid:          QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0
27 28
    property var    _videoReceiver:     QGroundControl.videoManager.videoReceiver
    property var    _activeVehicle:     QGroundControl.multiVehicleManager.activeVehicle
29 30
    property var    _dynamicCameras:    _activeVehicle ? _activeVehicle.dynamicCameras : null
    property bool   _connected:         _activeVehicle ? !_activeVehicle.connectionLost : false
dogmaphobic's avatar
dogmaphobic committed
31 32 33
    Rectangle {
        id:             noVideo
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
34
        color:          Qt.rgba(0,0,0,0.75)
35
        visible:        !(_videoReceiver && _videoReceiver.videoRunning)
dogmaphobic's avatar
dogmaphobic committed
36
        QGCLabel {
37
            text:               QGroundControl.settingsManager.videoSettings.streamEnabled.rawValue ? qsTr("WAITING FOR VIDEO") : qsTr("VIDEO DISABLED")
38
            font.family:        ScreenTools.demiboldFontFamily
dogmaphobic's avatar
dogmaphobic committed
39
            color:              "white"
dogmaphobic's avatar
dogmaphobic committed
40
            font.pointSize:     _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
dogmaphobic's avatar
dogmaphobic committed
41 42
            anchors.centerIn:   parent
        }
43 44 45 46 47 48
        MouseArea {
            anchors.fill: parent
            onDoubleClicked: {
                QGroundControl.videoManager.fullScreen = !QGroundControl.videoManager.fullScreen
            }
        }
dogmaphobic's avatar
dogmaphobic committed
49
    }
50
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
51
        anchors.fill:   parent
52
        color:          "black"
53
        visible:        _videoReceiver && _videoReceiver.videoRunning
54
        QGCVideoBackground {
55
            id:             videoContent
56 57 58
            height:         parent.height
            width:          _ar != 0.0 ? height * _ar : parent.width
            anchors.centerIn: parent
59 60 61
            receiver:       _videoReceiver
            display:        _videoReceiver && _videoReceiver.videoSurface
            visible:        _videoReceiver && _videoReceiver.videoRunning
62
            Connections {
63
                target:         _videoReceiver
64 65
                onImageFileChanged: {
                    videoContent.grabToImage(function(result) {
66
                        if (!result.saveToFile(_videoReceiver.imageFile)) {
67 68 69 70 71
                            console.error('Error capturing video frame');
                        }
                    });
                }
            }
72 73 74 75 76
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.33
77
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
78 79 80 81 82 83
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.66
84
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
85 86 87 88 89 90
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.33
91
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
92 93 94 95 96 97
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.66
98
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
99
            }
dogmaphobic's avatar
dogmaphobic committed
100
        }
101 102 103 104
        MouseArea {
            anchors.fill: parent
            onDoubleClicked: {
                QGroundControl.videoManager.fullScreen = !QGroundControl.videoManager.fullScreen
105
            }
dogmaphobic's avatar
dogmaphobic committed
106
        }
107 108
    }
}