ViewWidget.qml 2.02 KB
Newer Older
1 2
import QtQuick 2.3
import QtQuick.Controls 1.2
3
import QtQuick.Controls.Styles 1.4
4

5 6 7 8
import QGroundControl               1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.Palette       1.0
9 10

Rectangle {
11 12
    property Component connectedComponent: __componentConnected
    property Component disconnectedComponent: __componentDisconnected
13

14 15
    QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
    ViewWidgetController { id: __controller }
16

17
    color: __qgcPal.window
18

19
    Component.onCompleted: __controller.checkForVehicle()
20

21 22
    Connections {
        target: __controller
23

24 25 26 27
        onPluginConnected: {
            pageLoader.autopilot = autopilot
            pageLoader.sourceComponent = connectedComponent
        }
28

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

36 37
    Loader {
        id: pageLoader
38

39
        anchors.fill: parent
40

41
        property var autopilot
42

43 44
        sourceComponent: __componentDisconnected
    }
45

46 47
    Component {
        id: __componentConnected
48

49 50
        Rectangle {
            QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
51

52 53
            anchors.fill:	parent
            color:			__qgcPal.window
54

55 56
            QGCLabel {
                anchors.fill:	parent
57

58 59
                horizontalAlignment:	Text.AlignHCenter
                verticalAlignment:		Text.AlignVCenter
60

61
                text: qsTr("missing connected implementation")
62 63 64
            }
        }
    }
65

66 67
    Component {
        id: __componentDisconnected
68

69 70
        Rectangle {
            QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
71

72 73
            anchors.fill:	parent
            color:			__qgcPal.window
74

75 76
            QGCLabel {
                anchors.fill:	parent
77

78 79
                horizontalAlignment:	Text.AlignHCenter
                verticalAlignment:		Text.AlignVCenter
80

81
                text: qsTr("no vehicle connected")
82 83 84
            }
        }
    }
85
}