FlightDisplayViewVideo.qml 3.41 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 22 23

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


dogmaphobic's avatar
dogmaphobic committed
24 25
Item {
    id: root
26 27
    property double _ar:            QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue
    property bool   _showGrid:      QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0
28 29
    property var    _videoReceiver: QGroundControl.videoManager.videoReceiver

dogmaphobic's avatar
dogmaphobic committed
30 31 32
    Rectangle {
        id:             noVideo
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
33
        color:          Qt.rgba(0,0,0,0.75)
34
        visible:        !(_videoReceiver && _videoReceiver.videoRunning)
dogmaphobic's avatar
dogmaphobic committed
35
        QGCLabel {
36
            text:               qsTr("WAITING FOR VIDEO")
37
            font.family:        ScreenTools.demiboldFontFamily
dogmaphobic's avatar
dogmaphobic committed
38
            color:              "white"
dogmaphobic's avatar
dogmaphobic committed
39
            font.pointSize:     _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
dogmaphobic's avatar
dogmaphobic committed
40 41 42
            anchors.centerIn:   parent
        }
    }
43
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
44
        anchors.fill:   parent
45
        color:          "black"
46
        visible:        _videoReceiver && _videoReceiver.videoRunning
47
        QGCVideoBackground {
48
            id:             videoContent
49 50 51
            height:         parent.height
            width:          _ar != 0.0 ? height * _ar : parent.width
            anchors.centerIn: parent
52 53 54
            receiver:       _videoReceiver
            display:        _videoReceiver && _videoReceiver.videoSurface
            visible:        _videoReceiver && _videoReceiver.videoRunning
55
            Connections {
56
                target:         _videoReceiver
57 58
                onImageFileChanged: {
                    videoContent.grabToImage(function(result) {
59
                        if (!result.saveToFile(_videoReceiver.imageFile)) {
60 61 62 63 64
                            console.error('Error capturing video frame');
                        }
                    });
                }
            }
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.33
                visible: _showGrid
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.66
                visible: _showGrid
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.33
                visible: _showGrid
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.66
                visible: _showGrid
            }
dogmaphobic's avatar
dogmaphobic committed
93
        }
94 95
    }
}