FlightModesComponentSummary.qml 2.61 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1
import QtQuick          2.2
2
import QtQuick.Controls 1.2
3

Don Gagne's avatar
Don Gagne committed
4 5 6 7 8
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
9

10
FactPanel {
11 12 13
    id:             panel
    anchors.fill:   parent
    color:          qgcPal.windowShadeDark
14

Don Gagne's avatar
Don Gagne committed
15 16 17
    QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
    FactPanelController { id: controller; factPanel: panel }

Don Gagne's avatar
Don Gagne committed
18 19 20 21
    property Fact _nullFact
    property Fact _rcMapFltmode:    controller.parameterExists(-1, "RC_MAP_FLTMODE") ? controller.getParameterFact(-1, "RC_MAP_FLTMODE") : _nullFact
    property Fact _rcMapModeSw:     controller.getParameterFact(-1, "RC_MAP_MODE_SW")
    property bool _simpleMode:      _rcMapFltmode.value > 0 || _rcMapModeSw.value == 0
22

Don Gagne's avatar
Don Gagne committed
23 24

    Loader {
25
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
26 27
        sourceComponent:    _simpleMode ? simple : advanced
    }
28

Don Gagne's avatar
Don Gagne committed
29 30
    Component {
        id: simple
31

Don Gagne's avatar
Don Gagne committed
32 33
        Column {
            anchors.margins:    8
34

Don Gagne's avatar
Don Gagne committed
35 36 37 38 39 40 41 42 43 44 45 46 47
            VehicleSummaryRow {
                labelText: "Mode switch:"
                valueText: _rcMapFltmode.value === 0 ? "Setup required" : _rcMapFltmode.enumStringValue
            }

            Repeater {
                model: 6

                VehicleSummaryRow {
                    labelText: "Flight Mode " + (index + 1) + ":"
                    valueText: controller.getParameterFact(-1, "COM_FLTMODE" + (index + 1)).enumStringValue
                }
            }
48
        }
Don Gagne's avatar
Don Gagne committed
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
    }

    Component {
        id: advanced

        Column {
            anchors.margins:    8

            property Fact posCtlSwFact: controller.getParameterFact(-1, "RC_MAP_POSCTL_SW")
            property Fact loiterSwFact: controller.getParameterFact(-1, "RC_MAP_LOITER_SW")
            property Fact returnSwFact: controller.getParameterFact(-1, "RC_MAP_RETURN_SW")

            VehicleSummaryRow {
                labelText: "Mode switch:"
                valueText: _rcMapModeSw.value === 0 ? "Setup required" : _rcMapModeSw.valueString
            }

            VehicleSummaryRow {
                labelText: "Position Ctl switch:"
                valueText: posCtlSwFact.value === 0 ? "Disabled" : posCtlSwFact.valueString
            }

            VehicleSummaryRow {
                labelText: "Loiter switch:"
                valueText: loiterSwFact.value === 0 ? "Disabled" : loiterSwFact.valueString
            }
75

Don Gagne's avatar
Don Gagne committed
76 77 78 79
            VehicleSummaryRow {
                labelText: "Return switch:"
                valueText: returnSwFact.value === 0 ? "Disabled" : returnSwFact.valueString
            }
80
        }
81 82
    }
}