SafetyComponent.qml 12.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*=====================================================================

 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/>.

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

dogmaphobic's avatar
dogmaphobic committed
24
import QtQuick 2.5
Don Gagne's avatar
Don Gagne committed
25 26
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
dogmaphobic's avatar
dogmaphobic committed
27 28
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
29

Don Gagne's avatar
Don Gagne committed
30
import QGroundControl.FactSystem 1.0
31
import QGroundControl.FactControls 1.0
32
import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
33
import QGroundControl.Controls 1.0
34
import QGroundControl.ScreenTools 1.0
Don Gagne's avatar
Don Gagne committed
35

Don Gagne's avatar
Don Gagne committed
36

dogmaphobic's avatar
dogmaphobic committed
37 38 39 40
QGCView {
    id:                 _safetyView
    viewPanel:          panel
    anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
41

dogmaphobic's avatar
dogmaphobic committed
42
    FactPanelController { id: controller; factPanel: panel }
Don Gagne's avatar
Don Gagne committed
43

dogmaphobic's avatar
dogmaphobic committed
44
    QGCPalette { id: palette; colorGroupEnabled: enabled }
Don Gagne's avatar
Don Gagne committed
45

dogmaphobic's avatar
dogmaphobic committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    property real firstColumnWidth:     ScreenTools.defaultFontPixelWidth * 28
    property real secondColumnWidth:    ScreenTools.defaultFontPixelWidth * 25

    QGCViewPanel {
        id:             panel
        anchors.fill:   parent

        Flickable {
            clip:               true
            anchors.fill:       parent
            contentHeight:      safetyColumn.height
            contentWidth:       parent.width
            boundsBehavior:     Flickable.StopAtBounds
            flickableDirection: Flickable.VerticalFlick

            Column {
                id:     safetyColumn
                width:  _safetyView.width

                //-----------------------------------------------------------------
                //-- Return Home Triggers

dogmaphobic's avatar
dogmaphobic committed
68
                QGCLabel { text: "Triggers For Return Home"; font.weight: Font.DemiBold; }
dogmaphobic's avatar
dogmaphobic committed
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

                Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer

                Rectangle {
                    width:  parent.width
                    height: triggerColumn.height + ScreenTools.defaultFontPixelHeight
                    color:  palette.windowShade
                    Column {
                        id:                 triggerColumn
                        width:              parent.width
                        spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
                        Row {
                            spacing:                ScreenTools.defaultFontPixelWidth
                            QGCLabel {
                                text:               "RC Transmitter Signal Loss"
                                width:              firstColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            QGCLabel {
                                text:               "Return Home after"
                                width:              secondColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
Don Gagne's avatar
Don Gagne committed
95
                            FactTextField {
dogmaphobic's avatar
dogmaphobic committed
96 97 98 99
                                id:                 rcLossField
                                fact:               controller.getParameterFact(-1, "COM_RC_LOSS_T")
                                showUnits:          true
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
100
                            }
Don Gagne's avatar
Don Gagne committed
101
                        }
dogmaphobic's avatar
dogmaphobic committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
                        Row {
                            spacing:                ScreenTools.defaultFontPixelWidth
                            FactCheckBox {
                                id:                 telemetryTimeoutCheckbox
                                width:              firstColumnWidth
                                fact:               controller.getParameterFact(-1, "COM_DL_LOSS_EN")
                                checkedValue:       1
                                uncheckedValue:     0
                                text:               "Telemetry Signal Timeout"
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            QGCLabel {
                                text:               "Return Home after"
                                width:              secondColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
117
                            }
Don Gagne's avatar
Don Gagne committed
118
                            FactTextField {
dogmaphobic's avatar
dogmaphobic committed
119 120 121 122 123
                                id:                 telemetryLossField
                                fact:               controller.getParameterFact(-1, "COM_DL_LOSS_T")
                                showUnits:          true
                                enabled:            telemetryTimeoutCheckbox.checked
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
124
                            }
125
                        }
dogmaphobic's avatar
dogmaphobic committed
126
                        Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
127
                    }
dogmaphobic's avatar
dogmaphobic committed
128
                }
Don Gagne's avatar
Don Gagne committed
129

dogmaphobic's avatar
dogmaphobic committed
130
                Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } // spacer
Don Gagne's avatar
Don Gagne committed
131

dogmaphobic's avatar
dogmaphobic committed
132 133
                //-----------------------------------------------------------------
                //-- Return Home Settings
Don Gagne's avatar
Don Gagne committed
134

dogmaphobic's avatar
dogmaphobic committed
135
                QGCLabel { text: "Return Home Settings"; font.weight: Font.DemiBold; }
Don Gagne's avatar
Don Gagne committed
136

dogmaphobic's avatar
dogmaphobic committed
137
                Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
Don Gagne's avatar
Don Gagne committed
138

dogmaphobic's avatar
dogmaphobic committed
139 140 141 142
                Rectangle {
                    width:  parent.width
                    height: settingsRow.height
                    color:  palette.windowShade
Don Gagne's avatar
Don Gagne committed
143

dogmaphobic's avatar
dogmaphobic committed
144 145 146 147 148 149 150 151 152 153
                    Row {
                        id:                 settingsRow
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        spacing:            ScreenTools.defaultFontPixelWidth
                        Item {
                            width:          firstColumnWidth
                            height:         firstColumnWidth * 0.65
                            Image {
                                id:             icon
154 155
                                width:          parent.width * 0.75
                                height:         width * 0.5
dogmaphobic's avatar
dogmaphobic committed
156 157 158 159 160 161
                                mipmap:         true
                                fillMode:       Image.PreserveAspectFit
                                visible:        false
                                source:         "/qmlimages/ReturnToHomeAltitude.svg"
                                anchors.verticalCenter: parent.verticalCenter
                                anchors.horizontalCenter: parent.horizontalCenter
Don Gagne's avatar
Don Gagne committed
162
                            }
dogmaphobic's avatar
dogmaphobic committed
163 164 165 166
                            ColorOverlay {
                                id:             iconOverlay
                                anchors.fill:   icon
                                source:         icon
167
                                color:          palette.text
Don Gagne's avatar
Don Gagne committed
168
                            }
dogmaphobic's avatar
dogmaphobic committed
169
                            anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
170
                        }
Don Gagne's avatar
Don Gagne committed
171
                        Column {
dogmaphobic's avatar
dogmaphobic committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
                            width:              parent.width - firstColumnWidth
                            spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.verticalCenter: parent.verticalCenter
                            Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
                            Row {
                                spacing:        ScreenTools.defaultFontPixelWidth
                                QGCLabel {
                                    text:       "Climb to altitude of"
                                    width:      secondColumnWidth
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                                FactTextField {
                                    id:         climbField
                                    fact:       controller.getParameterFact(-1, "RTL_RETURN_ALT")
                                    showUnits:  true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                            }
                            Row {
                                spacing:        ScreenTools.defaultFontPixelWidth
                                QGCCheckBox {
                                    id:         homeLoiterCheckbox
                                    width:      secondColumnWidth
                                    checked:    fact.value > 0
                                    text:       "Loiter at Home altitude for"
                                    anchors.verticalCenter: parent.verticalCenter
                                    property Fact fact: controller.getParameterFact(-1, "RTL_LAND_DELAY")
                                    onClicked: {
                                        fact.value = checked ? 60 : -1
                                    }
                                }
                                FactTextField {
                                    id:         landDelayField
                                    fact:       controller.getParameterFact(-1, "RTL_LAND_DELAY")
                                    showUnits:  true
                                    enabled:    homeLoiterCheckbox.checked === true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
Don Gagne's avatar
Don Gagne committed
211

Don Gagne's avatar
Don Gagne committed
212
                            }
dogmaphobic's avatar
dogmaphobic committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
                            Row {
                                spacing:    ScreenTools.defaultFontPixelWidth
                                QGCLabel {
                                    text:       "Home loiter altitude";
                                    color:      palette.text;
                                    enabled:    homeLoiterCheckbox.checked === true
                                    width:      secondColumnWidth
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                                FactTextField {
                                    id:         descendField;
                                    fact:       controller.getParameterFact(-1, "RTL_DESCEND_ALT")
                                    enabled:    homeLoiterCheckbox.checked === true
                                    showUnits:  true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
Don Gagne's avatar
Don Gagne committed
229
                            }
dogmaphobic's avatar
dogmaphobic committed
230
                            Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } // spacer
Don Gagne's avatar
Don Gagne committed
231 232
                        }
                    }
Don Gagne's avatar
Don Gagne committed
233
                }
234

dogmaphobic's avatar
dogmaphobic committed
235 236 237 238 239 240
                QGCLabel {
                    width:          parent.width
                    font.pixelSize: ScreenTools.mediumFontPixelSize
                    text:           "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
                    visible:        fact.value !== 0
                    wrapMode:       Text.Wrap
Don Gagne's avatar
Don Gagne committed
241

dogmaphobic's avatar
dogmaphobic committed
242 243
                    property Fact fact: controller.getParameterFact(-1, "NAV_RCL_OBC")
                }
Don Gagne's avatar
Don Gagne committed
244

dogmaphobic's avatar
dogmaphobic committed
245 246 247 248 249 250
                QGCLabel {
                    width:          parent.width
                    font.pixelSize: ScreenTools.mediumFontPixelSize
                    text:           "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
                    visible:        fact.value !== 0
                    wrapMode:       Text.Wrap
Don Gagne's avatar
Don Gagne committed
251

dogmaphobic's avatar
dogmaphobic committed
252 253
                    property Fact fact: controller.getParameterFact(-1, "NAV_DLL_OBC")
                }
Don Gagne's avatar
Don Gagne committed
254
            }
255
        }
dogmaphobic's avatar
dogmaphobic committed
256
    }
Don Gagne's avatar
Don Gagne committed
257
}