FlightDisplayViewVideo.qml 4.22 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 27 28 29
    property var    _activeVehicle:     QGroundControl.multiVehicleManager.activeVehicle
    property double _ar:                QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue
    property bool   _showGrid:          QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0
    property var    _dynamicCameras:    _activeVehicle ? _activeVehicle.dynamicCameras : null
    property bool   _connected:         _activeVehicle ? !_activeVehicle.connectionLost : false
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:        !QGroundControl.videoManager.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:        QGroundControl.videoManager.videoReceiver.videoRunning
47
        QGCVideoBackground {
48
            id:             videoContent
49 50 51 52
            height:         parent.height
            width:          _ar != 0.0 ? height * _ar : parent.width
            anchors.centerIn: parent
            receiver:       QGroundControl.videoManager.videoReceiver
53 54
            display:        QGroundControl.videoManager.videoReceiver.videoSurface
            visible:        QGroundControl.videoManager.videoReceiver.videoRunning
55
            Connections {
56
                target:         QGroundControl.videoManager.videoReceiver
57 58
                onImageFileChanged: {
                    videoContent.grabToImage(function(result) {
59
                        if (!result.saveToFile(QGroundControl.videoManager.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 96 97 98 99 100 101 102 103
    //-- Camera Controller
    Loader {
        source:                 _dynamicCameras ? _dynamicCameras.controllerSource : ""
        visible:                !_mainIsMap && _dynamicCameras && _dynamicCameras.cameras.count && _connected
        anchors.right:          parent.right
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.bottom:         parent.bottom
        anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 2
    }
104
}