FlightDisplayViewVideo.qml 3.44 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
dogmaphobic's avatar
dogmaphobic committed
28 29 30
    Rectangle {
        id:             noVideo
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
31
        color:          Qt.rgba(0,0,0,0.75)
32
        visible:        !QGroundControl.videoManager.videoReceiver.videoRunning
dogmaphobic's avatar
dogmaphobic committed
33
        QGCLabel {
34
            text:               qsTr("WAITING FOR VIDEO")
35
            font.family:        ScreenTools.demiboldFontFamily
dogmaphobic's avatar
dogmaphobic committed
36
            color:              "white"
dogmaphobic's avatar
dogmaphobic committed
37
            font.pointSize:     _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
dogmaphobic's avatar
dogmaphobic committed
38 39 40
            anchors.centerIn:   parent
        }
    }
41
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
42
        anchors.fill:   parent
43
        color:          "black"
44
        visible:        QGroundControl.videoManager.videoReceiver.videoRunning
45
        QGCVideoBackground {
46
            id:             videoContent
47 48 49 50
            height:         parent.height
            width:          _ar != 0.0 ? height * _ar : parent.width
            anchors.centerIn: parent
            receiver:       QGroundControl.videoManager.videoReceiver
51 52
            display:        QGroundControl.videoManager.videoReceiver.videoSurface
            visible:        QGroundControl.videoManager.videoReceiver.videoRunning
53
            Connections {
54
                target:         QGroundControl.videoManager.videoReceiver
55 56
                onImageFileChanged: {
                    videoContent.grabToImage(function(result) {
57
                        if (!result.saveToFile(QGroundControl.videoManager.videoReceiver.imageFile)) {
58 59 60 61 62
                            console.error('Error capturing video frame');
                        }
                    });
                }
            }
63 64 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
            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
91
        }
92 93
    }
}