SetupViewConnected.qml 4.56 KB
Newer Older
1 2 3
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
4
import QGroundControl.FactSystem 1.0
5 6

Rectangle {
7 8
    QGCPalette { id: palette; colorGroup: QGCPalette.Active }

9 10 11
    id: topLevel
    objectName: "topLevel"

12
    color: palette.window
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

    signal buttonClicked(variant component);

    Image {
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
        smooth: true
        source: autopilot.setupBackgroundImage;
    }

    Column {
        anchors.margins: 20
        anchors.fill: parent
        spacing: 5

        Rectangle { id: header; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8;
29
            Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Setup" }
30 31 32 33 34 35 36 37 38 39 40 41 42 43
        }

        Flow {
            width: parent.width;
            height: parent.height - header.height - footer.height
            spacing: 5

            Repeater {
                model: autopilot.components

                Button {
                    width: 250
                    height: 200

44
                    property var summaryQmlSource: modelData.summaryQmlSource
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 91 92 93 94 95 96 97 98 99 100 101
                    text: modelData.name
                    property bool setupComplete: modelData.setupComplete

                    style: ButtonStyle {
                        id: buttonStyle
                        background: Rectangle {
                            id: innerRect
                            readonly property real titleHeight: 30

                            border.color: "#888"
                            radius: 10

                            color: control.activeFocus ? "#47b" : "white"
                            opacity: control.hovered || control.activeFocus ? 1 : 0.8
                            Behavior on opacity {NumberAnimation{ duration: 100 }}

                            Text {
                                id: titleBar

                                width: parent.width
                                height: parent.titleHeight

                                verticalAlignment: TextEdit.AlignVCenter
                                horizontalAlignment: TextEdit.AlignHCenter

                                text: control.text
                                font.pixelSize: 12

                                Rectangle {
                                    id: setupIndicator

                                    property bool setupComplete: true
                                    readonly property real indicatorRadius: 6

                                    x: parent.width - (indicatorRadius * 2) - 5
                                    y: (parent.height - (indicatorRadius * 2)) / 2
                                    width: indicatorRadius * 2
                                    height: indicatorRadius * 2

                                    radius: indicatorRadius
                                    color: control.setupComplete ? "green" : "red"
                                }
                            }

                            Rectangle {
                                width: parent.width
                                height: parent.height - parent.titleHeight

                                y: parent.titleHeight

                                border.color: "#888"

                                gradient: Gradient {
                                    GradientStop { position: 0; color: "#ffffff" }
                                    GradientStop { position: 1; color: "#000000" }
                                }

102
                                Loader {
103
                                    anchors.fill: parent
104
                                    source: summaryQmlSource
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
                                }
                            }
                        }

                    label: Item {}
                    }

                onClicked: topLevel.buttonClicked(modelData)
                }
            }
        }

        Rectangle { id: footer; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8;

            property real spacing: (width - firmwareButton.width - parametersButton.width) / 3

            Button { id: firmwareButton; objectName: "firmwareButton";
                x: parent.spacing; anchors.verticalCenter: parent.verticalCenter;
                text: "Firmware Upgrade" }
            Button { id: parametersButton; objectName: "parametersButton"
                x: firmwareButton.width + (parent.spacing*2); anchors.verticalCenter: parent.verticalCenter;
                text: "Parameters" }
        }

    }
}