FlightDisplayViewVideo.qml 4.88 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
            anchors.centerIn:   parent
        }
42 43 44 45 46 47
        MouseArea {
            anchors.fill: parent
            onDoubleClicked: {
                QGroundControl.videoManager.fullScreen = !QGroundControl.videoManager.fullScreen
            }
        }
dogmaphobic's avatar
dogmaphobic committed
48
    }
49
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
50
        anchors.fill:   parent
51
        color:          "black"
52
        visible:        QGroundControl.videoManager.videoReceiver.videoRunning
53
        QGCVideoBackground {
54
            id:             videoContent
55 56 57 58
            height:         parent.height
            width:          _ar != 0.0 ? height * _ar : parent.width
            anchors.centerIn: parent
            receiver:       QGroundControl.videoManager.videoReceiver
59 60
            display:        QGroundControl.videoManager.videoReceiver.videoSurface
            visible:        QGroundControl.videoManager.videoReceiver.videoRunning
61
            Connections {
62
                target:         QGroundControl.videoManager.videoReceiver
63 64
                onImageFileChanged: {
                    videoContent.grabToImage(function(result) {
65
                        if (!result.saveToFile(QGroundControl.videoManager.videoReceiver.imageFile)) {
66 67 68 69 70
                            console.error('Error capturing video frame');
                        }
                    });
                }
            }
71 72 73 74 75
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.33
76
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
77 78 79 80 81 82
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                height: parent.height
                width:  1
                x:      parent.width * 0.66
83
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
84 85 86 87 88 89
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.33
90
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
91 92 93 94 95 96
            }
            Rectangle {
                color:  Qt.rgba(1,1,1,0.5)
                width:  parent.width
                height: 1
                y:      parent.height * 0.66
97 98 99 100 101 102 103
                visible: _showGrid && !QGroundControl.videoManager.fullScreen
            }
        }
        MouseArea {
            anchors.fill: parent
            onDoubleClicked: {
                QGroundControl.videoManager.fullScreen = !QGroundControl.videoManager.fullScreen
104
            }
dogmaphobic's avatar
dogmaphobic committed
105
        }
106
    }
107 108
    //-- Camera Controller
    Loader {
109 110
        source:                 QGroundControl.videoManager.fullScreen ? "" : (_dynamicCameras ? _dynamicCameras.controllerSource : "")
        visible:                !_mainIsMap && _dynamicCameras && _dynamicCameras.cameras.count && _connected && !QGroundControl.videoManager.fullScreen
111 112 113 114 115
        anchors.right:          parent.right
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.bottom:         parent.bottom
        anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 2
    }
116
}