ApmToolBar.qml 5.63 KB
Newer Older
1 2 3 4 5 6
import QtQuick 1.1
import "./components"


Rectangle {
    id: toolbar
7 8 9 10

    property alias backgroundColor : toolbar.color
    property alias linkNameLabel: linkDevice.label
    property alias baudrateLabel: baudrate.label
11
    property bool connected: false
12 13
    property bool armed: false
    property string armedstr: "Disarmed"
14

15
    width: toolbar.width
16 17 18 19
    height: 72
    color: "black"
    border.color: "black"

20 21 22 23 24 25 26 27 28 29 30
    onArmedChanged: {
        if (armed) {
            armedText.text = "Armed"
            armedText.color = "Red"
        }
        else {
            armedText.text = "Disarmed"
            armedText.color = "Green"
        }
    }

31 32 33 34
    onConnectedChanged: {
        if (connected){
            console.log("APM Tool BAR QML: connected")
            connectButton.image = "./resources/apmplanner/toolbar/disconnect.png"
35
            connectButton.label = "DISCONNECT"
36 37 38
        } else {
            console.log("APM Tool BAR QML: disconnected")
            connectButton.image = "./resources/apmplanner/toolbar/connect.png"
39
            connectButton.label = "CONNECT"
40
        }
41 42
    }

Bill Bonney's avatar
Bill Bonney committed
43
// [BB] The code below should work, not sure why. replaced with code above
44 45 46 47 48 49 50 51 52 53 54 55 56 57
//    Connections {
//            target: globalObj
//            onMAVConnected: {
//                console.log("QML Change Connection " + connected)
//                if (connected){
//                    console.log("connected")
//                    connectButton.image = "./resources/apmplanner/toolbar/disconnect.png"
//                } else {
//                    console.log("disconnected")
//                    connectButton.image = "./resources/apmplanner/toolbar/connect.png"
//                }
//            }
//    }

58 59
    Row {
        anchors.left: parent.left
60
        spacing: 10
61

Bill Bonney's avatar
Bill Bonney committed
62
        Rectangle { // Spacer
63 64 65 66 67
            width: 5
            height: parent.height
            color: "black"
        }

68 69 70 71 72
        Button {
            id: flightDataView
            label: "FLIGHT DATA"
            image: "./resources/apmplanner/toolbar/flightdata.png"
            onClicked: {
73
                globalObj.triggerFlightView()
74 75 76 77 78 79 80
            }
        }

        Button {
            id: flightPlanView
            label: "FLIGHT PLAN"
            image: "./resources/apmplanner/toolbar/flightplanner.png"
81
            onClicked: globalObj.triggerFlightPlanView()
82 83 84 85 86 87 88
        }

        Button {
            id: hardwareConfigView
            label: "HARDWARE"
            image: "./resources/apmplanner/toolbar/hardwareconfig.png"
            margins: 8
89
            onClicked: globalObj.triggerHardwareView()
90 91 92 93 94 95 96
        }

        Button {
            id: softwareConfigView
            label: "SOFTWARE"
            image: "./resources/apmplanner/toolbar/softwareconfig.png"
            margins: 8
97
            onClicked: globalObj.triggerSoftwareView()
98 99 100
        }

        Button {
101
            id: simulationView
102 103
            label: "SIMULATION"
            image: "./resources/apmplanner/toolbar/simulation.png"
104
            onClicked: globalObj.triggerSimulationView()
105 106 107 108 109 110
        }

        Button {
            id: terminalView
            label: "TERMINAL"
            image: "./resources/apmplanner/toolbar/terminal.png"
111
            onClicked: globalObj.triggerTerminalView()
112
        }
113 114 115 116 117 118 119 120 121 122 123 124 125 126
        Rectangle {
            width:150
            height: parent.height
            Text {
                id: armedText;
                anchors.fill: parent
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                font.pixelSize: 20
                color: "green"
                text: "Disarmed"
            }
            color:"black"
        }
Bill Bonney's avatar
Bill Bonney committed
127 128 129 130 131 132 133

        Rectangle { // Spacer
            width: 5
            height: parent.height
            color: "black"
        }

134 135
// [BB] Commented out ToolBar Status info work.
//      WIP: To be fixed later
Bill Bonney's avatar
Bill Bonney committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
//            DigitalDisplay { // Information Pane
//                title:"Mode"
//                textValue: "Stabilize"
//                color: "black"
//            }
//            DigitalDisplay { // Information Pane
//                title: "Speed"
//                textValue: "11.0m/s"
//                color: "black"
//            }
//            DigitalDisplay { // Information Pane
//                title: "Alt"
//                textValue: "20.0m"
//                color: "black"
//            }
//            DigitalDisplay { // Information Pane
//                title: "Volts"
//                textValue: "14.8V"
//                color: "black"
//            }
//            DigitalDisplay { // Information Pane
//                title: "Current"
//                textValue: "12.0A"
//                color: "black"
//            }
//            DigitalDisplay { // Information Pane
//                title: "Level"
//                textValue: "77%"
//                color: "black"
//            }

167 168 169
    }

    Row {
170
        anchors.right: parent.right
171 172
        spacing: 2

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
        TextButton {
            id: linkDevice
            label: "none"
            minWidth: 100

            onClicked: globalObj.showConnectionDialog()
        }

        TextButton {
            id: baudrate
            label: "none"
            minWidth: 100

            onClicked: globalObj.showConnectionDialog()
        }

        Rectangle {
            width: 5
            height: parent.height
            color: "black"
        }

195 196 197 198
        Button {
            id: connectButton
            label: "CONNECT"
            image: "./resources/apmplanner/toolbar/connect.png"
199 200 201
            onClicked: globalObj.connectMAV()
        }

Bill Bonney's avatar
Bill Bonney committed
202
        Rectangle { // Spacer
203 204 205
            width: 5
            height: parent.height
            color: "black"
206 207 208
        }
    }
}