GeneralSettings.qml 14.4 KB
Newer Older
dogmaphobic's avatar
dogmaphobic 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
/*=====================================================================

 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 QtQuick.Controls.Styles  1.2
import QtQuick.Dialogs          1.1

import QGroundControl                       1.0
import QGroundControl.FactSystem            1.0
31
import QGroundControl.FactControls          1.0
dogmaphobic's avatar
dogmaphobic committed
32 33 34 35 36 37
import QGroundControl.Controls              1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.Palette               1.0

Rectangle {
38
    id:                 _generalRoot
39
    color:              qgcPal.window
40 41
    anchors.fill:       parent
    anchors.margins:    ScreenTools.defaultFontPixelWidth
dogmaphobic's avatar
dogmaphobic committed
42

dogmaphobic's avatar
dogmaphobic committed
43 44 45
    property Fact _percentRemainingAnnounce:    QGroundControl.multiVehicleManager.disconnectedVehicle.battery.percentRemainingAnnounce
    property real _firstLabelWidth:             ScreenTools.defaultFontPixelWidth * 16
    property real _editFieldWidth:              ScreenTools.defaultFontPixelWidth * 22
46

47
    QGCPalette { id: qgcPal }
dogmaphobic's avatar
dogmaphobic committed
48

Don Gagne's avatar
Don Gagne committed
49
    QGCFlickable {
dogmaphobic's avatar
dogmaphobic committed
50 51 52
        clip:               true
        anchors.fill:       parent
        contentHeight:      settingsColumn.height
Don Gagne's avatar
Don Gagne committed
53
        contentWidth:       settingsColumn.width
dogmaphobic's avatar
dogmaphobic committed
54 55 56 57

        Column {
            id:                 settingsColumn
            anchors.margins:    ScreenTools.defaultFontPixelWidth
58
            spacing:            ScreenTools.defaultFontPixelHeight / 2
Don Gagne's avatar
Don Gagne committed
59

dogmaphobic's avatar
dogmaphobic committed
60
            QGCLabel {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
61
                text:   qsTr("General Settings")
dogmaphobic's avatar
dogmaphobic committed
62 63
                font.pixelSize: ScreenTools.mediumFontPixelSize
            }
64 65 66 67 68
            Rectangle {
                height: 1
                width:  parent.width
                color:  qgcPal.button
            }
69 70
            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
dogmaphobic's avatar
dogmaphobic committed
71 72
                width:  parent.width
            }
73

74 75 76 77 78 79 80
            //-----------------------------------------------------------------
            //-- Units

            Row {
                spacing:    ScreenTools.defaultFontPixelWidth

                QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
81
                    width:              _firstLabelWidth
82
                    anchors.baseline:   distanceUnitsCombo.baseline
Tomaz Canabrava's avatar
Tomaz Canabrava committed
83
                    text:               qsTr("Distance units:")
84 85 86
                }

                FactComboBox {
dogmaphobic's avatar
dogmaphobic committed
87 88 89 90
                    id:                 distanceUnitsCombo
                    width:              _editFieldWidth
                    fact:               QGroundControl.distanceUnits
                    indexModel:         false
91 92 93 94
                }

                QGCLabel {
                    anchors.baseline:   distanceUnitsCombo.baseline
Tomaz Canabrava's avatar
Tomaz Canabrava committed
95
                    text:               qsTr("(requires reboot to take affect)")
96 97 98 99 100
                }

            }

            Row {
dogmaphobic's avatar
dogmaphobic committed
101
                spacing:                ScreenTools.defaultFontPixelWidth
102 103 104

                QGCLabel {
                    anchors.baseline:   speedUnitsCombo.baseline
dogmaphobic's avatar
dogmaphobic committed
105
                    width:              _firstLabelWidth
Tomaz Canabrava's avatar
Tomaz Canabrava committed
106
                    text:               qsTr("Speed units:")
107 108 109
                }

                FactComboBox {
dogmaphobic's avatar
dogmaphobic committed
110 111 112 113
                    id:                 speedUnitsCombo
                    width:              _editFieldWidth
                    fact:               QGroundControl.speedUnits
                    indexModel:         false
114 115 116
                }

                QGCLabel {
117
                    anchors.baseline:   speedUnitsCombo.baseline
Tomaz Canabrava's avatar
Tomaz Canabrava committed
118
                    text:              qsTr("(requires reboot to take affect)")
119 120 121
                }
            }

dogmaphobic's avatar
dogmaphobic committed
122 123 124 125 126 127 128 129 130 131 132
            //-----------------------------------------------------------------
            //-- Scale on Flight View
            QGCCheckBox {
                text:       qsTr("Show scale on Fly View")
                onClicked: {
                    QGroundControl.flightMapSettings.showScaleOnFlyView = checked
                }
                Component.onCompleted: {
                    checked = QGroundControl.flightMapSettings.showScaleOnFlyView
                }
            }
dogmaphobic's avatar
dogmaphobic committed
133 134 135
            //-----------------------------------------------------------------
            //-- Audio preferences
            QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
136
                text:       qsTr("Mute all audio output")
dogmaphobic's avatar
dogmaphobic committed
137 138 139 140 141 142 143 144
                checked:    QGroundControl.isAudioMuted
                onClicked: {
                    QGroundControl.isAudioMuted = checked
                }
            }
            //-----------------------------------------------------------------
            //-- Prompt Save Log
            QGCCheckBox {
145
                id:         promptSaveLog
Tomaz Canabrava's avatar
Tomaz Canabrava committed
146
                text:       qsTr("Prompt to save Flight Data Log after each flight")
dogmaphobic's avatar
dogmaphobic committed
147 148 149 150 151 152 153
                checked:    QGroundControl.isSaveLogPrompt
                visible:    !ScreenTools.isMobile
                onClicked: {
                    QGroundControl.isSaveLogPrompt = checked
                }
            }
            //-----------------------------------------------------------------
154 155
            //-- Prompt Save even if not armed
            QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
156
                text:       qsTr("Prompt to save Flight Data Log even if vehicle was not armed")
157 158 159 160 161 162 163 164
                checked:    QGroundControl.isSaveLogPromptNotArmed
                visible:    !ScreenTools.isMobile
                enabled:    promptSaveLog.checked
                onClicked: {
                    QGroundControl.isSaveLogPromptNotArmed = checked
                }
            }
            //-----------------------------------------------------------------
dogmaphobic's avatar
dogmaphobic committed
165 166 167
            //-- Clear settings
            QGCCheckBox {
                id:         clearCheck
Tomaz Canabrava's avatar
Tomaz Canabrava committed
168
                text:       qsTr("Clear all settings on next start")
dogmaphobic's avatar
dogmaphobic committed
169 170 171 172 173 174 175 176 177
                checked:    false
                onClicked: {
                    checked ? clearDialog.visible = true : QGroundControl.clearDeleteAllSettingsNextBoot()
                }
                MessageDialog {
                    id:         clearDialog
                    visible:    false
                    icon:       StandardIcon.Warning
                    standardButtons: StandardButton.Yes | StandardButton.No
Tomaz Canabrava's avatar
Tomaz Canabrava committed
178 179
                    title:      qsTr("Clear Settings")
                    text:       qsTr("All saved settings will be reset the next time you start QGroundControl. Is this really what you want?")
dogmaphobic's avatar
dogmaphobic committed
180 181 182 183 184 185 186 187 188 189
                    onYes: {
                        QGroundControl.deleteAllSettingsNextBoot()
                        clearDialog.visible = false
                    }
                    onNo: {
                        clearCheck.checked  = false
                        clearDialog.visible = false
                    }
                }
            }
190 191 192 193 194 195 196 197
            //-----------------------------------------------------------------
            //-- Battery talker
            Row {
                spacing: ScreenTools.defaultFontPixelWidth

                QGCCheckBox {
                    id:                 announcePercentCheckbox
                    anchors.baseline:   announcePercent.baseline
Tomaz Canabrava's avatar
Tomaz Canabrava committed
198
                    text:               qsTr("Announce battery percent lower than:")
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
                    checked:            _percentRemainingAnnounce.value != 0

                    onClicked: {
                        if (checked) {
                            _percentRemainingAnnounce.value = _percentRemainingAnnounce.defaultValueString
                        } else {
                            _percentRemainingAnnounce.value = 0
                        }
                    }
                }

                FactTextField {
                    id:         announcePercent
                    fact:       _percentRemainingAnnounce
                    enabled:    announcePercentCheckbox.checked
                }
            }
216 217 218 219 220

            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
                width:  parent.width
            }
dogmaphobic's avatar
dogmaphobic committed
221 222 223 224 225
            //-----------------------------------------------------------------
            //-- Map Providers
            Row {
                spacing:    ScreenTools.defaultFontPixelWidth
                QGCLabel {
226
                    anchors.baseline:   mapProviders.baseline
dogmaphobic's avatar
dogmaphobic committed
227
                    width:              _firstLabelWidth
Tomaz Canabrava's avatar
Tomaz Canabrava committed
228
                    text:               qsTr("Map Providers:")
dogmaphobic's avatar
dogmaphobic committed
229 230
                }
                QGCComboBox {
dogmaphobic's avatar
dogmaphobic committed
231 232 233
                    id:                 mapProviders
                    width:              _editFieldWidth
                    model:              QGroundControl.flightMapSettings.mapProviders
dogmaphobic's avatar
dogmaphobic committed
234 235 236
                    Component.onCompleted: {
                        var index = mapProviders.find(QGroundControl.flightMapSettings.mapProvider)
                        if (index < 0) {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
237
                            console.warn(qsTr("Active map provider not in combobox"), QGroundControl.flightMapSettings.mapProvider)
dogmaphobic's avatar
dogmaphobic committed
238 239 240 241 242 243 244
                        } else {
                            mapProviders.currentIndex = index
                        }
                    }
                    onActivated: {
                        if (index != -1) {
                            currentIndex = index
Tomaz Canabrava's avatar
Tomaz Canabrava committed
245
                            console.log(qsTr("New map provider: ") + model[index])
dogmaphobic's avatar
dogmaphobic committed
246 247 248 249 250 251 252 253 254 255
                            QGroundControl.flightMapSettings.mapProvider = model[index]
                        }
                    }
                }
            }
            //-----------------------------------------------------------------
            //-- Palette Styles
            Row {
                spacing:    ScreenTools.defaultFontPixelWidth
                QGCLabel {
256
                    anchors.baseline:   paletteCombo.baseline
dogmaphobic's avatar
dogmaphobic committed
257
                    width:              _firstLabelWidth
Tomaz Canabrava's avatar
Tomaz Canabrava committed
258
                    text:               qsTr("Style:")
dogmaphobic's avatar
dogmaphobic committed
259 260
                }
                QGCComboBox {
dogmaphobic's avatar
dogmaphobic committed
261 262 263 264
                    id:                 paletteCombo
                    width:              _editFieldWidth
                    model:              [ qsTr("Indoor"), qsTr("Outdoor") ]
                    currentIndex:       QGroundControl.isDarkStyle ? 0 : 1
dogmaphobic's avatar
dogmaphobic committed
265 266 267 268 269 270 271 272
                    onActivated: {
                        if (index != -1) {
                            currentIndex = index
                            QGroundControl.isDarkStyle = index === 0 ? true : false
                        }
                    }
                }
            }
Don Gagne's avatar
Don Gagne committed
273

274 275 276 277 278
            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
                width:  parent.width
            }

Don Gagne's avatar
Don Gagne committed
279 280 281 282
            //-----------------------------------------------------------------
            //-- Autoconnect settings
            QGCLabel { text: "Autoconnect to the following devices:" }

283 284
            Row {
                spacing: ScreenTools.defaultFontPixelWidth * 2
Don Gagne's avatar
Don Gagne committed
285

286
                QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
287
                    text:       qsTr("Pixhawk")
288 289 290 291
                    visible:    !ScreenTools.isiOS
                    checked:    QGroundControl.linkManager.autoconnectPixhawk
                    onClicked:  QGroundControl.linkManager.autoconnectPixhawk = checked
                }
Don Gagne's avatar
Don Gagne committed
292

293
                QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
294
                    text:       qsTr("SiK Radio")
295 296 297 298
                    visible:    !ScreenTools.isiOS
                    checked:    QGroundControl.linkManager.autoconnect3DRRadio
                    onClicked:  QGroundControl.linkManager.autoconnect3DRRadio = checked
                }
Don Gagne's avatar
Don Gagne committed
299

300
                QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
301
                    text:       qsTr("PX4 Flow")
302 303 304 305 306 307
                    visible:    !ScreenTools.isiOS
                    checked:    QGroundControl.linkManager.autoconnectPX4Flow
                    onClicked:  QGroundControl.linkManager.autoconnectPX4Flow = checked
                }

                QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
308
                    text:       qsTr("UDP")
309 310 311
                    checked:    QGroundControl.linkManager.autoconnectUDP
                    onClicked:  QGroundControl.linkManager.autoconnectUDP = checked
                }
Don Gagne's avatar
Don Gagne committed
312
            }
313 314 315 316 317 318 319 320 321

            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
                width:  parent.width
            }

            //-----------------------------------------------------------------
            //-- Virtual joystick settings
            QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
322
                text:       qsTr("Virtual Joystick")
323 324 325
                checked:    QGroundControl.virtualTabletJoystick
                onClicked:  QGroundControl.virtualTabletJoystick = checked
            }
326 327 328 329 330 331

            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
                width:  parent.width
            }

332 333
            //-----------------------------------------------------------------
            //-- Offline mission editing settings
334 335 336 337
            Row {
                spacing: ScreenTools.defaultFontPixelWidth

                QGCLabel {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
338
                    text:               qsTr("Offline mission editing vehicle type:")
339 340 341 342 343 344 345 346 347 348
                    anchors.baseline:   offlineTypeCombo.baseline
                }

                FactComboBox {
                    id:         offlineTypeCombo
                    width:      ScreenTools.defaultFontPixelWidth * 25
                    fact:       QGroundControl.offlineEditingFirmwareType
                    indexModel: false
                }
            }
349 350 351 352 353 354 355 356 357

            Item {
                height: ScreenTools.defaultFontPixelHeight / 2
                width:  parent.width
            }

            //-----------------------------------------------------------------
            //-- Experimental Survey settings
            QGCCheckBox {
Tomaz Canabrava's avatar
Tomaz Canabrava committed
358
                text:       qsTr("Experimental Survey [WIP - no bugs reports please]")
359 360 361
                checked:    QGroundControl.experimentalSurvey
                onClicked:  QGroundControl.experimentalSurvey = checked
            }
dogmaphobic's avatar
dogmaphobic committed
362 363 364
        }
    }
}