PX4SimpleFlightModes.qml 8.07 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/*=====================================================================

 QGroundControl Open Source Ground Control Station

 (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

 This file is part of the QGROUNDCONTROL project

 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

 ======================================================================*/

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

43 44 45
    readonly property real _flightModeComboWidth:   ScreenTools.defaultFontPixelWidth * 23
    readonly property real _channelComboWidth:      ScreenTools.defaultFontPixelWidth * 20

Don Gagne's avatar
Don Gagne committed
46 47 48 49 50 51 52 53 54 55
    QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }

    PX4SimpleFlightModesController {
        id:         controller
        factPanel:  qgcViewPanel
    }

    QGCFlickable {
        anchors.fill:   parent
        clip:           true
Don Gagne's avatar
Don Gagne committed
56 57
        contentWidth:   column2.x + column2.width
        contentHeight:  Math.max(column1.height, column2.height)
Don Gagne's avatar
Don Gagne committed
58 59

        Column {
Don Gagne's avatar
Don Gagne committed
60
            id:         column1
Don Gagne's avatar
Don Gagne committed
61 62
            spacing:    _margins

Don Gagne's avatar
Don Gagne committed
63 64 65
            Row {
                id:         settingsRow
                spacing:    _margins
Don Gagne's avatar
Don Gagne committed
66 67

                Column {
Don Gagne's avatar
Don Gagne committed
68 69 70 71 72
                    id:     flightModeSettingsColumn
                    spacing: _margins

                    QGCLabel {
                        id:             flightModeLabel
73
                        text:           qsTr("Flight Mode Settings")
74
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
                    }

                    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
96
                                    text:               qsTr("Flight mode channel:")
Don Gagne's avatar
Don Gagne committed
97 98 99 100
                                }

                                FactComboBox {
                                    id:         modeChannelCombo
101
                                    width:      _channelComboWidth
Don Gagne's avatar
Don Gagne committed
102 103 104 105
                                    fact:       controller.getParameterFact(-1, "RC_MAP_FLTMODE")
                                    indexModel: false
                                }
                            }
Don Gagne's avatar
Don Gagne committed
106

Don Gagne's avatar
Don Gagne committed
107 108
                            Repeater {
                                model:  6
Don Gagne's avatar
Don Gagne committed
109

Don Gagne's avatar
Don Gagne committed
110 111
                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
Don Gagne's avatar
Don Gagne committed
112

Don Gagne's avatar
Don Gagne committed
113
                                    property int index:         modelData + 1
Don Gagne's avatar
Don Gagne committed
114

Don Gagne's avatar
Don Gagne committed
115 116
                                    QGCLabel {
                                        anchors.baseline:   modeCombo.baseline
117
                                        text:               qsTr("Flight Mode %1").arg(index)
Don Gagne's avatar
Don Gagne committed
118 119
                                        color:              controller.activeFlightMode == index ? "yellow" : qgcPal.text
                                    }
Don Gagne's avatar
Don Gagne committed
120

Don Gagne's avatar
Don Gagne committed
121 122
                                    FactComboBox {
                                        id:         modeCombo
123
                                        width:      _flightModeComboWidth
Don Gagne's avatar
Don Gagne committed
124 125 126 127 128 129 130 131 132 133
                                        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
134 135
                    id:         column2
                    spacing:    _margins
Don Gagne's avatar
Don Gagne committed
136 137

                    QGCLabel {
138
                        text:           qsTr("Switch Settings")
139
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
140 141 142
                    }

                    Rectangle {
Don Gagne's avatar
Don Gagne committed
143
                        id:     switchSettingsRect
Don Gagne's avatar
Don Gagne committed
144 145 146 147 148 149 150 151 152 153 154 155
                        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

                            Repeater {
Don Gagne's avatar
Don Gagne committed
156
                                model: [ "RC_MAP_RETURN_SW", "RC_MAP_KILL_SW", "RC_MAP_OFFB_SW" ]
Don Gagne's avatar
Don Gagne committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170

                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth

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

                                    QGCLabel {
                                        anchors.baseline:   optCombo.baseline
                                        text:               fact.shortDescription + ":"
                                        color:              fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
                                    }

                                    FactComboBox {
                                        id:         optCombo
171
                                        width:      _channelComboWidth
Don Gagne's avatar
Don Gagne committed
172 173 174 175 176 177 178
                                        fact:       parent.fact
                                        indexModel: false
                                    }
                                }
                            } // Repeater
                        } // Column
                    } // Rectangle
Don Gagne's avatar
Don Gagne committed
179 180 181 182

                    RCChannelMonitor {
                        width: switchSettingsRect.width
                    }
Don Gagne's avatar
Don Gagne committed
183 184
                } // Column - Switch settings
            } // Row - Settings
Don Gagne's avatar
Don Gagne committed
185 186

            QGCButton {
Don Gagne's avatar
Don Gagne committed
187
                text: "Use Multi Channel Mode Selection"
Don Gagne's avatar
Don Gagne committed
188 189 190 191 192 193 194 195
                onClicked: {
                    controller.getParameterFact(-1, "RC_MAP_MODE_SW").value = 5
                    controller.getParameterFact(-1, "RC_MAP_FLTMODE").value = 0
                }
            }
        } // Column
    } // QGCFlickable
} // QGCView