PX4SimpleFlightModes.qml 9.17 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29


import QtQuick                  2.5
import QtQuick.Controls         1.2

import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.ScreenTools   1.0

Item {
    id: root

    // The following properties must be pushed in from the Loader
    //property var qgcView      - QGCView control
    //property var qgcViewPanel - QGCViewPanel control

    property real _margins: ScreenTools.defaultFontPixelHeight / 2

Don Gagne's avatar
Don Gagne committed
30 31
    readonly property real _flightModeComboWidth:   ScreenTools.defaultFontPixelWidth * 13
    readonly property real _channelComboWidth:      ScreenTools.defaultFontPixelWidth * 13
32

Don Gagne's avatar
Don Gagne committed
33 34 35 36 37 38 39 40 41 42
    QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }

    PX4SimpleFlightModesController {
        id:         controller
        factPanel:  qgcViewPanel
    }

    QGCFlickable {
        anchors.fill:   parent
        clip:           true
Don Gagne's avatar
Don Gagne committed
43 44
        contentWidth:   column2.x + column2.width
        contentHeight:  Math.max(column1.height, column2.height)
Don Gagne's avatar
Don Gagne committed
45 46

        Column {
Don Gagne's avatar
Don Gagne committed
47
            id:         column1
Don Gagne's avatar
Don Gagne committed
48 49
            spacing:    _margins

Don Gagne's avatar
Don Gagne committed
50 51 52
            Row {
                id:         settingsRow
                spacing:    _margins
Don Gagne's avatar
Don Gagne committed
53 54

                Column {
Don Gagne's avatar
Don Gagne committed
55 56 57 58 59
                    id:     flightModeSettingsColumn
                    spacing: _margins

                    QGCLabel {
                        id:             flightModeLabel
60
                        text:           qsTr("Flight Mode Settings")
61
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                    }

                    Rectangle {
                        id:                 flightModeSettings
                        width:              flightModeColumn.width + (_margins * 2)
                        height:             flightModeColumn.height + ScreenTools.defaultFontPixelHeight
                        color:              qgcPal.windowShade

                        Column {
                            id:                 flightModeColumn
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.top:        parent.top
                            spacing:            ScreenTools.defaultFontPixelHeight

                            Row {
                                spacing: _margins

                                QGCLabel {
                                    id:                 modeChannelLabel
                                    anchors.baseline:   modeChannelCombo.baseline
Don Gagne's avatar
Don Gagne committed
83
                                    text:               qsTr("Mode channel:")
Don Gagne's avatar
Don Gagne committed
84 85 86 87
                                }

                                FactComboBox {
                                    id:         modeChannelCombo
88
                                    width:      _channelComboWidth
Don Gagne's avatar
Don Gagne committed
89 90 91 92
                                    fact:       controller.getParameterFact(-1, "RC_MAP_FLTMODE")
                                    indexModel: false
                                }
                            }
Don Gagne's avatar
Don Gagne committed
93

Don Gagne's avatar
Don Gagne committed
94 95
                            Repeater {
                                model:  6
Don Gagne's avatar
Don Gagne committed
96

Don Gagne's avatar
Don Gagne committed
97 98
                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
Don Gagne's avatar
Don Gagne committed
99

Don Gagne's avatar
Don Gagne committed
100
                                    property int index:         modelData + 1
Don Gagne's avatar
Don Gagne committed
101

Don Gagne's avatar
Don Gagne committed
102 103
                                    QGCLabel {
                                        anchors.baseline:   modeCombo.baseline
104
                                        text:               qsTr("Flight Mode %1").arg(index)
Don Gagne's avatar
Don Gagne committed
105 106
                                        color:              controller.activeFlightMode == index ? "yellow" : qgcPal.text
                                    }
Don Gagne's avatar
Don Gagne committed
107

Don Gagne's avatar
Don Gagne committed
108 109
                                    FactComboBox {
                                        id:         modeCombo
110
                                        width:      _flightModeComboWidth
Don Gagne's avatar
Don Gagne committed
111 112 113 114 115 116 117 118 119 120
                                        fact:       controller.getParameterFact(-1, "COM_FLTMODE" + index)
                                        indexModel: false
                                    }
                                }
                            } // Repeater - Flight Modes
                        } // Column - Flight Modes
                    } // Rectangle - Flight Modes
                } // Column - Flight mode settings

                Column {
Don Gagne's avatar
Don Gagne committed
121 122
                    id:         column2
                    spacing:    _margins
Don Gagne's avatar
Don Gagne committed
123 124

                    QGCLabel {
125
                        text:           qsTr("Switch Settings")
126
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
127 128 129
                    }

                    Rectangle {
Don Gagne's avatar
Don Gagne committed
130
                        id:     switchSettingsRect
Don Gagne's avatar
Don Gagne committed
131 132 133 134 135 136 137 138 139 140 141
                        width:  switchSettingsColumn.width + (_margins * 2)
                        height: switchSettingsColumn.height + ScreenTools.defaultFontPixelHeight
                        color:  qgcPal.windowShade

                        Column {
                            id:                 switchSettingsColumn
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.top:        parent.top
                            spacing:            ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
142 143
                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth
Don Gagne's avatar
Don Gagne committed
144

Don Gagne's avatar
Don Gagne committed
145
                                property Fact fact: controller.getParameterFact(-1, "RC_MAP_RETURN_SW")
Don Gagne's avatar
Don Gagne committed
146

Don Gagne's avatar
Don Gagne committed
147 148 149
                                QGCLabel {
                                    anchors.baseline:   returnCombo.baseline
                                    text:               "Return switch:"
Don Gagne's avatar
Don Gagne committed
150
                                    color:              parent.fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[parent.fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
Don Gagne's avatar
Don Gagne committed
151
                                }
Don Gagne's avatar
Don Gagne committed
152

Don Gagne's avatar
Don Gagne committed
153 154 155 156 157 158 159
                                FactComboBox {
                                    id:         returnCombo
                                    width:      _channelComboWidth
                                    fact:       parent.fact
                                    indexModel: false
                                }
                            }
Don Gagne's avatar
Don Gagne committed
160

Don Gagne's avatar
Don Gagne committed
161 162 163 164 165 166 167 168
                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth

                                property Fact fact: controller.getParameterFact(-1, "RC_MAP_KILL_SW")

                                QGCLabel {
                                    anchors.baseline:   killCombo.baseline
                                    text:               "Kill switch:"
Don Gagne's avatar
Don Gagne committed
169
                                    color:              parent.fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[parent.fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
Don Gagne's avatar
Don Gagne committed
170 171 172 173 174 175 176
                                }

                                FactComboBox {
                                    id:         killCombo
                                    width:      _channelComboWidth
                                    fact:       parent.fact
                                    indexModel: false
Don Gagne's avatar
Don Gagne committed
177
                                }
Don Gagne's avatar
Don Gagne committed
178 179 180 181 182 183 184 185 186 187
                            }

                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth

                                property Fact fact: controller.getParameterFact(-1, "RC_MAP_OFFB_SW")

                                QGCLabel {
                                    anchors.baseline:   offboardCombo.baseline
                                    text:               "Offboard switch:"
Don Gagne's avatar
Don Gagne committed
188
                                    color:              parent.fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[parent.fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
Don Gagne's avatar
Don Gagne committed
189 190 191 192 193 194 195 196 197
                                }

                                FactComboBox {
                                    id:         offboardCombo
                                    width:      _channelComboWidth
                                    fact:       parent.fact
                                    indexModel: false
                                }
                            }
Don Gagne's avatar
Don Gagne committed
198 199
                        } // Column
                    } // Rectangle
Don Gagne's avatar
Don Gagne committed
200 201 202 203

                    RCChannelMonitor {
                        width: switchSettingsRect.width
                    }
Don Gagne's avatar
Don Gagne committed
204 205
                } // Column - Switch settings
            } // Row - Settings
Don Gagne's avatar
Don Gagne committed
206 207

            QGCButton {
Don Gagne's avatar
Don Gagne committed
208
                text: "Use Multi Channel Mode Selection"
Don Gagne's avatar
Don Gagne committed
209 210 211 212 213 214 215 216
                onClicked: {
                    controller.getParameterFact(-1, "RC_MAP_MODE_SW").value = 5
                    controller.getParameterFact(-1, "RC_MAP_FLTMODE").value = 0
                }
            }
        } // Column
    } // QGCFlickable
} // QGCView