ViewWidget.qml 1.93 KB
Newer Older
1
import QtQuick 2.5
2 3 4 5 6 7 8
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

import QGroundControl.Palette 1.0
import QGroundControl.Controllers 1.0

Rectangle {
9 10
    property Component connectedComponent: __componentConnected
    property Component disconnectedComponent: __componentDisconnected
11

12 13
    QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
    ViewWidgetController { id: __controller }
14

15
    color: __qgcPal.window
16

17
    Component.onCompleted: __controller.checkForVehicle()
18

19 20
    Connections {
        target: __controller
21

22 23 24 25
        onPluginConnected: {
            pageLoader.autopilot = autopilot
            pageLoader.sourceComponent = connectedComponent
        }
26

27
        onPluginDisconnected: {
Don Gagne's avatar
Don Gagne committed
28
            pageLoader.sourceComponent = null
29 30 31 32
            pageLoader.sourceComponent = disconnectedComponent
            pageLoader.autopilot = null
        }
    }
33

34 35
    Loader {
        id: pageLoader
36

37
        anchors.fill: parent
38

39
        property var autopilot
40

41 42
        sourceComponent: __componentDisconnected
    }
43

44 45
    Component {
        id: __componentConnected
46

47 48
        Rectangle {
            QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
49

50 51
            anchors.fill:	parent
            color:			__qgcPal.window
52

53 54
            QGCLabel {
                anchors.fill:	parent
55

56 57
                horizontalAlignment:	Text.AlignHCenter
                verticalAlignment:		Text.AlignVCenter
58

59 60 61 62
                text: "missing connected implementation"
            }
        }
    }
63

64 65
    Component {
        id: __componentDisconnected
66

67 68
        Rectangle {
            QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
69

70 71
            anchors.fill:	parent
            color:			__qgcPal.window
72

73 74
            QGCLabel {
                anchors.fill:	parent
75

76 77
                horizontalAlignment:	Text.AlignHCenter
                verticalAlignment:		Text.AlignVCenter
78

79 80 81 82
                text: "no vehicle connected"
            }
        }
    }
83
}