AirmapSettings.qml 39.5 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8 9 10
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/


Gus Grubba's avatar
Gus Grubba committed
11 12
import QtGraphicalEffects       1.0
import QtMultimedia             5.5
Gus Grubba's avatar
Gus Grubba committed
13 14 15 16 17
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtQuick.Layouts          1.2
Gus Grubba's avatar
Gus Grubba committed
18 19
import QtLocation               5.3
import QtPositioning            5.3
Gus Grubba's avatar
Gus Grubba committed
20 21

import QGroundControl                       1.0
22
import QGroundControl.Airspace              1.0
Gus Grubba's avatar
Gus Grubba committed
23
import QGroundControl.Controllers           1.0
Gus Grubba's avatar
Gus Grubba committed
24
import QGroundControl.Controls              1.0
Gus Grubba's avatar
Gus Grubba committed
25 26 27
import QGroundControl.FactControls          1.0
import QGroundControl.FactSystem            1.0
import QGroundControl.FlightMap             1.0
Gus Grubba's avatar
Gus Grubba committed
28 29
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.Palette               1.0
Gus Grubba's avatar
Gus Grubba committed
30
import QGroundControl.ScreenTools           1.0
Gus Grubba's avatar
Gus Grubba committed
31 32 33 34 35 36 37 38 39 40
import QGroundControl.SettingsManager       1.0

QGCView {
    id:                 _qgcView
    viewPanel:          panel
    color:              qgcPal.window
    anchors.fill:       parent
    anchors.margins:    ScreenTools.defaultFontPixelWidth

    property real _labelWidth:                  ScreenTools.defaultFontPixelWidth * 20
Gus Grubba's avatar
Gus Grubba committed
41
    property real _editFieldWidth:              ScreenTools.defaultFontPixelWidth * 20
Gus Grubba's avatar
Gus Grubba committed
42
    property real _buttonWidth:                 ScreenTools.defaultFontPixelWidth * 18
Gus Grubba's avatar
Gus Grubba committed
43
    property real _panelWidth:                  _qgcView.width * _internalWidthRatio
Gus Grubba's avatar
Gus Grubba committed
44
    property Fact _enableAirMapFact:            QGroundControl.settingsManager.airMapSettings.enableAirMap
Gus Grubba's avatar
Gus Grubba committed
45
    property bool _airMapEnabled:               _enableAirMapFact.rawValue
46
    property var  _authStatus:                  QGroundControl.airspaceManager.authStatus
Gus Grubba's avatar
Gus Grubba committed
47 48 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 75 76 77 78 79

    readonly property real _internalWidthRatio:          0.8

    QGCPalette { id: qgcPal }

    QGCViewPanel {
        id:             panel
        anchors.fill:   parent
        QGCFlickable {
            clip:               true
            anchors.fill:       parent
            contentHeight:      settingsColumn.height
            contentWidth:       settingsColumn.width
            Column {
                id:                 settingsColumn
                width:              _qgcView.width
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                anchors.margins:    ScreenTools.defaultFontPixelWidth
                //-----------------------------------------------------------------
                //-- General
                Item {
                    width:                      _panelWidth
                    height:                     generalLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    visible:                    QGroundControl.settingsManager.unitsSettings.visible
                    QGCLabel {
                        id:             generalLabel
                        text:           qsTr("General")
                        font.family:    ScreenTools.demiboldFontFamily
                    }
                }
                Rectangle {
80
                    height:                     generalRow.height + (ScreenTools.defaultFontPixelHeight * 2)
Gus Grubba's avatar
Gus Grubba committed
81 82 83 84
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
                    Row {
                        id:                 generalRow
                        spacing:            ScreenTools.defaultFontPixelWidth * 4
                        anchors.centerIn:   parent
                        Column {
                            spacing:        ScreenTools.defaultFontPixelWidth
                            FactCheckBox {
                                text:       qsTr("Enable AirMap Services")
                                fact:       _enableAirMapFact
                                visible:    _enableAirMapFact.visible
                            }
                            FactCheckBox {
                                text:       qsTr("Enable Telemetry")
                                fact:       _enableTelemetryFact
                                visible:    _enableTelemetryFact.visible
                                enabled:    _airMapEnabled
                                property Fact _enableTelemetryFact: QGroundControl.settingsManager.airMapSettings.enableTelemetry
                            }
Gus Grubba's avatar
Gus Grubba committed
103
                        }
104
                        QGCButton {
105
                            text:           qsTr("Clear Saved Answers")
106 107 108 109 110 111 112 113
                            enabled:        _enableAirMapFact.rawValue
                            onClicked:      clearDialog.open()
                            anchors.verticalCenter: parent.verticalCenter
                            MessageDialog {
                                id:                 clearDialog
                                visible:            false
                                icon:               StandardIcon.Warning
                                standardButtons:    StandardButton.Yes | StandardButton.No
114
                                title:              qsTr("Clear Saved Answers")
115 116 117 118 119 120 121 122 123
                                text:               qsTr("All saved ruleset answers will be cleared. Is this really what you want?")
                                onYes: {
                                    QGroundControl.airspaceManager.ruleSets.clearAllFeatures()
                                    clearDialog.close()
                                }
                                onNo: {
                                    clearDialog.close()
                                }
                            }
Gus Grubba's avatar
Gus Grubba committed
124 125 126 127
                        }
                    }
                }
                //-----------------------------------------------------------------
Gus Grubba's avatar
Gus Grubba committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
                //-- Connection Status
                Item {
                    width:                      _panelWidth
                    height:                     statusLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    visible:                    QGroundControl.settingsManager.appSettings.visible && _airMapEnabled
                    QGCLabel {
                        id:                     statusLabel
                        text:                   qsTr("Connection Status")
                        font.family:            ScreenTools.demiboldFontFamily
                    }
                }
                Rectangle {
                    height:                     statusCol.height + (ScreenTools.defaultFontPixelHeight * 2)
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
                    visible:                    QGroundControl.settingsManager.appSettings.visible && _airMapEnabled
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    Column {
                        id:                     statusCol
                        spacing:                ScreenTools.defaultFontPixelHeight * 0.5
                        width:                  parent.width
                        anchors.centerIn:       parent
                        QGCLabel {
                            text:                       QGroundControl.airspaceManager.connected ? qsTr("Connected") : qsTr("Not Connected")
                            color:                      QGroundControl.airspaceManager.connected ? qgcPal.colorGreen : qgcPal.colorRed
                            anchors.horizontalCenter:   parent.horizontalCenter
                        }
                        QGCLabel {
                            text:                       QGroundControl.airspaceManager.connectStatus
                            visible:                    QGroundControl.airspaceManager.connectStatus != ""
                            wrapMode:                   Text.WordWrap
                            horizontalAlignment:        Text.AlignHCenter
                            width:                      parent.width * 0.8
                            anchors.horizontalCenter:   parent.horizontalCenter
                        }
                    }
                }
                //-----------------------------------------------------------------
Gus Grubba's avatar
Gus Grubba committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
                //-- Login / Registration
                Item {
                    width:                      _panelWidth
                    height:                     loginLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    QGCLabel {
                        id:             loginLabel
                        text:           qsTr("Login / Registration")
                        font.family:    ScreenTools.demiboldFontFamily
                    }
                }
                Rectangle {
                    height:                     loginGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    GridLayout {
                        id:                 loginGrid
189 190
                        columns:            3
                        columnSpacing:      ScreenTools.defaultFontPixelWidth
Gus Grubba's avatar
Gus Grubba committed
191 192
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.25
                        anchors.centerIn:   parent
Gus Grubba's avatar
Gus Grubba committed
193
                        QGCLabel        { text: qsTr("User Name:") }
Gus Grubba's avatar
Gus Grubba committed
194
                        FactTextField {
Gus Grubba's avatar
Gus Grubba committed
195
                            fact:           _usernameFact
Gus Grubba's avatar
Gus Grubba committed
196
                            width:          _editFieldWidth
Gus Grubba's avatar
Gus Grubba committed
197
                            enabled:        _airMapEnabled
Gus Grubba's avatar
Gus Grubba committed
198
                            visible:        _usernameFact.visible
Gus Grubba's avatar
Gus Grubba committed
199 200
                            Layout.fillWidth:    true
                            Layout.minimumWidth: _editFieldWidth
Gus Grubba's avatar
Gus Grubba committed
201
                            property Fact _usernameFact: QGroundControl.settingsManager.airMapSettings.userName
Gus Grubba's avatar
Gus Grubba committed
202
                        }
203 204 205 206 207 208 209 210 211
                        QGCLabel {
                            text: {
                                if(!QGroundControl.airspaceManager.connected)
                                    return qsTr("Not Connected")
                                switch(_authStatus) {
                                case AirspaceManager.Unknown:
                                    return qsTr("")
                                case AirspaceManager.Anonymous:
                                    return qsTr("Anonymous")
212 213
                                case AirspaceManager.Authenticated:
                                    return qsTr("Authenticated")
214
                                default:
215
                                    return qsTr("Authentication Error")
216 217 218 219 220
                                }
                            }
                            Layout.rowSpan:     2
                            Layout.alignment:   Qt.AlignVCenter
                        }
Gus Grubba's avatar
Gus Grubba committed
221
                        QGCLabel { text: qsTr("Password:") }
Gus Grubba's avatar
Gus Grubba committed
222
                        FactTextField {
Gus Grubba's avatar
Gus Grubba committed
223
                            fact:           _passwordFact
Gus Grubba's avatar
Gus Grubba committed
224
                            width:          _editFieldWidth
Gus Grubba's avatar
Gus Grubba committed
225
                            enabled:        _airMapEnabled
Gus Grubba's avatar
Gus Grubba committed
226
                            visible:        _passwordFact.visible
227
                            echoMode:       TextInput.Password
Gus Grubba's avatar
Gus Grubba committed
228 229
                            Layout.fillWidth:    true
                            Layout.minimumWidth: _editFieldWidth
Gus Grubba's avatar
Gus Grubba committed
230
                            property Fact _passwordFact: QGroundControl.settingsManager.airMapSettings.password
Gus Grubba's avatar
Gus Grubba committed
231 232 233 234
                        }
                        Item {
                            width:  1
                            height: 1
235 236 237 238 239
                        }
                        Item {
                            width:  1
                            height: 1
                            Layout.columnSpan: 3
Gus Grubba's avatar
Gus Grubba committed
240 241
                        }
                        QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
242 243
                            text:               qsTr("Forgot Your AirMap Password?")
                            Layout.alignment:   Qt.AlignHCenter
244
                            Layout.columnSpan:  3
Gus Grubba's avatar
Gus Grubba committed
245 246 247 248
                        }
                        Item {
                            width:  1
                            height: 1
249
                            Layout.columnSpan:  3
Gus Grubba's avatar
Gus Grubba committed
250 251
                        }
                        QGCButton {
Gus Grubba's avatar
Gus Grubba committed
252 253
                            text:               qsTr("Register for an AirMap Account")
                            Layout.alignment:   Qt.AlignHCenter
254
                            Layout.columnSpan:  3
Gus Grubba's avatar
Gus Grubba committed
255
                            enabled:            _airMapEnabled
Gus Grubba's avatar
Gus Grubba committed
256 257 258
                            onClicked: {
                                Qt.openUrlExternally("https://www.airmap.com");
                            }
Gus Grubba's avatar
Gus Grubba committed
259 260 261 262 263 264
                        }
                    }
                }
                //-----------------------------------------------------------------
                //-- Pilot Profile
                Item {
Gus Grubba's avatar
Gus Grubba committed
265
                    //-- Disabled for now
Gus Grubba's avatar
Gus Grubba committed
266 267 268 269
                    width:                      _panelWidth
                    height:                     profileLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
270
                    visible:                    false // QGroundControl.settingsManager.appSettings.visible
Gus Grubba's avatar
Gus Grubba committed
271 272
                    QGCLabel {
                        id:             profileLabel
Gus Grubba's avatar
Gus Grubba committed
273
                        text:           qsTr("Pilot Profile (WIP)")
Gus Grubba's avatar
Gus Grubba committed
274 275 276 277
                        font.family:    ScreenTools.demiboldFontFamily
                    }
                }
                Rectangle {
Gus Grubba's avatar
Gus Grubba committed
278
                    //-- Disabled for now
Gus Grubba's avatar
Gus Grubba committed
279 280 281
                    height:                     profileGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
Gus Grubba's avatar
Gus Grubba committed
282
                    visible:                    false // QGroundControl.settingsManager.appSettings.visible
Gus Grubba's avatar
Gus Grubba committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    GridLayout {
                        id:                 profileGrid
                        columns:            2
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 2
                        rowSpacing:         ScreenTools.defaultFontPixelWidth  * 0.25
                        anchors.centerIn:   parent
                        QGCLabel { text: qsTr("Name:") }
                        QGCLabel { text: qsTr("John Doe") }
                        QGCLabel { text: qsTr("User Name:") }
                        QGCLabel { text: qsTr("joe36") }
                        QGCLabel { text: qsTr("Email:") }
                        QGCLabel { text: qsTr("jonh@doe.com") }
                        QGCLabel { text: qsTr("Phone:") }
                        QGCLabel { text: qsTr("+1 212 555 1212") }
                    }
                }
Gus Grubba's avatar
Gus Grubba committed
301 302 303 304 305 306 307
                //-----------------------------------------------------------------
                //-- License (Will this stay here?)
                Item {
                    width:                      _panelWidth
                    height:                     licenseLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
308
                    visible:                    QGroundControl.settingsManager.airMapSettings.usePersonalApiKey.visible
Gus Grubba's avatar
Gus Grubba committed
309
                    QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
310 311 312
                        id:                     licenseLabel
                        text:                   qsTr("License")
                        font.family:            ScreenTools.demiboldFontFamily
Gus Grubba's avatar
Gus Grubba committed
313 314 315 316 317 318 319 320
                    }
                }
                Rectangle {
                    height:                     licenseGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
321
                    visible:                    QGroundControl.settingsManager.airMapSettings.usePersonalApiKey.visible
Gus Grubba's avatar
Gus Grubba committed
322
                    GridLayout {
Gus Grubba's avatar
Gus Grubba committed
323 324 325 326 327 328 329 330 331
                        id:                     licenseGrid
                        columns:                2
                        columnSpacing:          ScreenTools.defaultFontPixelHeight * 2
                        rowSpacing:             ScreenTools.defaultFontPixelWidth  * 0.25
                        anchors.centerIn:       parent
                        FactCheckBox {
                            id:                 hasPrivateKey
                            text:               qsTr("Personal API Key")
                            fact:               QGroundControl.settingsManager.airMapSettings.usePersonalApiKey
Gus Grubba's avatar
Gus Grubba committed
332 333 334 335 336 337 338 339 340
                            Layout.columnSpan:  2
                        }
                        Item {
                            width:      1
                            height:     1
                            visible:    hasPrivateKey.checked
                            Layout.columnSpan:  2
                        }
                        QGCLabel        { text: qsTr("API Key:"); visible: hasPrivateKey.checked; }
Gus Grubba's avatar
Gus Grubba committed
341
                        FactTextField   { fact: QGroundControl.settingsManager.airMapSettings.apiKey; width: _editFieldWidth * 2; visible: hasPrivateKey.checked; Layout.fillWidth: true; Layout.minimumWidth: _editFieldWidth * 2; }
Gus Grubba's avatar
Gus Grubba committed
342
                        QGCLabel        { text: qsTr("Client ID:"); visible: hasPrivateKey.checked; }
Gus Grubba's avatar
Gus Grubba committed
343
                        FactTextField   { fact: QGroundControl.settingsManager.airMapSettings.clientID; width: _editFieldWidth * 2; visible: hasPrivateKey.checked; Layout.fillWidth: true; Layout.minimumWidth: _editFieldWidth * 2;  }
Gus Grubba's avatar
Gus Grubba committed
344 345
                    }
                }
Gus Grubba's avatar
Gus Grubba committed
346 347 348 349 350 351 352 353 354
                //-----------------------------------------------------------------
                //-- Flight List
                Item {
                    width:                      _panelWidth
                    height:                     flightListLabel.height
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
                    visible:                    QGroundControl.settingsManager.appSettings.visible
                    QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
355 356 357
                        id:                     flightListLabel
                        text:                   qsTr("Flight List Management")
                        font.family:            ScreenTools.demiboldFontFamily
Gus Grubba's avatar
Gus Grubba committed
358 359 360
                    }
                }
                Rectangle {
Gus Grubba's avatar
Gus Grubba committed
361
                    height:                     flightListButton.height + (ScreenTools.defaultFontPixelHeight * 2)
Gus Grubba's avatar
Gus Grubba committed
362 363 364 365
                    width:                      _panelWidth
                    color:                      qgcPal.windowShade
                    anchors.margins:            ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter:   parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
                    QGCButton {
                        id:             flightListButton
                        text:           qsTr("Show Flight List")
                        backRadius:     4
                        heightFactor:   0.3333
                        showBorder:     true
                        width:          ScreenTools.defaultFontPixelWidth * 16
                        anchors.centerIn: parent
                        onClicked: {
                            panelLoader.sourceComponent = flightList
                        }
                    }
                }
            }
        }
        Loader {
            id: panelLoader
            anchors.centerIn: parent
        }
    }
    //---------------------------------------------------------------
    //-- Flight List
    Component {
        id:             flightList
        Rectangle {
            id:         flightListRoot
            width:      _qgcView.width
            height:     _qgcView.height
            color:      qgcPal.window
Gus Grubba's avatar
Gus Grubba committed
395 396
            property var    _flightList: QGroundControl.airspaceManager.flightPlan.flightList
            property real   _mapWidth:   ScreenTools.defaultFontPixelWidth * 40
Gus Grubba's avatar
Gus Grubba committed
397 398 399 400 401 402 403 404 405 406 407 408 409 410
            MouseArea {
                anchors.fill:   parent
                hoverEnabled:   true
                onWheel:        { wheel.accepted = true; }
                onPressed:      { mouse.accepted = true; }
                onReleased:     { mouse.accepted = true; }
            }
            //---------------------------------------------------------
            //-- Flight List
            RowLayout {
                anchors.fill: parent
                TableView {
                    id:                 tableView
                    model:              _flightList
411
                    selectionMode:      SelectionMode.SingleSelection
412
                    Layout.alignment:   Qt.AlignVCenter
Gus Grubba's avatar
Gus Grubba committed
413
                    Layout.fillWidth:   true
414
                    Layout.fillHeight:  true
415 416 417
                    onCurrentRowChanged: {
                        var o = _flightList.get(tableView.currentRow)
                        if(o) {
418 419
                            flightArea.path = o.boundingBox
                            map.fitViewportToMapItems()
420 421
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
422
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
423 424 425 426 427 428 429 430 431 432 433 434 435
                        title:  qsTr("No")
                        width:  ScreenTools.defaultFontPixelWidth * 3
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text {
                            horizontalAlignment: Text.AlignHCenter
                            text:  (styleData.row + 1)
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
                        }
                    }
                    TableViewColumn {
                        title:  qsTr("Created")
436
                        width:  ScreenTools.defaultFontPixelWidth * 18
Gus Grubba's avatar
Gus Grubba committed
437 438 439 440 441 442 443
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text {
                            horizontalAlignment: Text.AlignHCenter
                            text: {
                                var o = _flightList.get(styleData.row)
                                return o ? o.createdTime : ""
                            }
Gus Grubba's avatar
Gus Grubba committed
444 445 446
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
Gus Grubba's avatar
Gus Grubba committed
447 448 449
                        }
                    }
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
450
                        title:  qsTr("Flight Start")
451
                        width:  ScreenTools.defaultFontPixelWidth * 18
Gus Grubba's avatar
Gus Grubba committed
452 453 454 455 456 457 458
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text  {
                            horizontalAlignment: Text.AlignHCenter
                            text: {
                                var o = _flightList.get(styleData.row)
                                return o ? o.startTime : ""
                            }
Gus Grubba's avatar
Gus Grubba committed
459 460 461
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
Gus Grubba's avatar
Gus Grubba committed
462 463
                        }
                    }
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
                    TableViewColumn {
                        title:  qsTr("Flight End")
                        width:  ScreenTools.defaultFontPixelWidth * 18
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text  {
                            horizontalAlignment: Text.AlignHCenter
                            text: {
                                var o = _flightList.get(styleData.row)
                                return o ? o.endTime : ""
                            }
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
479
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
480
                        title:  qsTr("State")
481
                        width:  ScreenTools.defaultFontPixelWidth * 8
Gus Grubba's avatar
Gus Grubba committed
482 483 484 485 486
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text  {
                            horizontalAlignment: Text.AlignHCenter
                            text: {
                                var o = _flightList.get(styleData.row)
487
                                return o ? (o.active ? qsTr("Active") : qsTr("Completed")) : qsTr("Unknown")
Gus Grubba's avatar
Gus Grubba committed
488
                            }
Gus Grubba's avatar
Gus Grubba committed
489 490 491
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
Gus Grubba's avatar
Gus Grubba committed
492 493 494 495
                        }
                    }
                }
                Item {
Gus Grubba's avatar
Gus Grubba committed
496
                    width:              flightListRoot._mapWidth
Gus Grubba's avatar
Gus Grubba committed
497 498
                    height:             parent.height
                    Layout.alignment:   Qt.AlignTop | Qt.AlignLeft
Gus Grubba's avatar
Gus Grubba committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
                    QGCLabel {
                        id:             loadingLabel
                        text:           qsTr("Loading Flight List")
                        visible:        QGroundControl.airspaceManager.flightPlan.loadingFlightList
                        anchors.centerIn: parent
                    }
                    QGCColoredImage {
                        id:                 busyIndicator
                        height:             ScreenTools.defaultFontPixelHeight * 2.5
                        width:              height
                        source:             "/qmlimages/MapSync.svg"
                        sourceSize.height:  height
                        fillMode:           Image.PreserveAspectFit
                        mipmap:             true
                        smooth:             true
                        color:              qgcPal.colorGreen
                        visible:            loadingLabel.visible
                        anchors.top:        loadingLabel.bottom
                        anchors.topMargin:  ScreenTools.defaultFontPixelHeight
                        anchors.horizontalCenter: parent.horizontalCenter
                        RotationAnimation on rotation {
                            loops:          Animation.Infinite
                            from:           360
                            to:             0
                            duration:       740
                            running:        busyIndicator.visible
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
527
                    Column {
Gus Grubba's avatar
Gus Grubba committed
528 529
                        spacing:            ScreenTools.defaultFontPixelHeight * 0.75
                        visible:            !QGroundControl.airspaceManager.flightPlan.loadingFlightList
Gus Grubba's avatar
Gus Grubba committed
530 531 532 533 534 535
                        anchors.top:        parent.top
                        anchors.horizontalCenter: parent.horizontalCenter
                        QGCLabel {
                            text:           qsTr("Flight List")
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
Gus Grubba's avatar
Gus Grubba committed
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
                        Rectangle {
                            color:          qgcPal.window
                            border.color:   qgcPal.globalTheme === QGCPalette.Dark ? Qt.rgba(1,1,1,0.25) : Qt.rgba(0,0,0,0.25)
                            border.width:   1
                            radius:         4
                            width:          _mapWidth - (ScreenTools.defaultFontPixelWidth * 2)
                            height:         rangeCol.height + (ScreenTools.defaultFontPixelHeight * 2)
                            Column {
                                id:         rangeCol
                                anchors.centerIn: parent
                                spacing:    ScreenTools.defaultFontPixelHeight * 0.5
                                QGCLabel {
                                    text:   qsTr("Range")
                                    anchors.horizontalCenter: parent.horizontalCenter
                                }
                                Row {
                                    spacing:            ScreenTools.defaultFontPixelWidth * 2
                                    anchors.horizontalCenter: parent.horizontalCenter
                                    Column {
                                        spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                                        QGCButton {
                                            text:           qsTr("From")
                                            backRadius:     4
                                            heightFactor:   0.3333
                                            showBorder:     true
                                            width:          _buttonWidth * 0.5
                                            onClicked:      fromPicker.visible = true
                                            anchors.horizontalCenter: parent.horizontalCenter
                                        }
                                        QGCLabel {
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            text: fromPicker.selectedDate.toLocaleDateString(Qt.locale())
                                        }
                                    }
                                    Rectangle {
                                        width:  1
                                        height: parent.height
                                        color:  qgcPal.globalTheme === QGCPalette.Dark ? Qt.rgba(1,1,1,0.25) : Qt.rgba(0,0,0,0.25)
                                    }
                                    Column {
                                        spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                                        QGCButton {
                                            text:           qsTr("To")
                                            backRadius:     4
                                            heightFactor:   0.3333
                                            showBorder:     true
                                            width:          _buttonWidth * 0.5
                                            onClicked:      toPicker.visible = true
                                            anchors.horizontalCenter: parent.horizontalCenter
                                        }
                                        QGCLabel {
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            text: toPicker.selectedDate.toLocaleDateString(Qt.locale())
                                        }
                                    }
                                }
                            }
                        }
Gus Grubba's avatar
Gus Grubba committed
594 595 596 597 598 599 600 601 602
                        QGCButton {
                            text:           qsTr("Refresh")
                            backRadius:     4
                            heightFactor:   0.3333
                            showBorder:     true
                            width:          _buttonWidth
                            enabled:        true
                            anchors.horizontalCenter: parent.horizontalCenter
                            onClicked: {
Gus Grubba's avatar
Gus Grubba committed
603 604 605 606 607
                                var start   = fromPicker.selectedDate
                                var end     = toPicker.selectedDate
                                start.setHours(0,0,0,0)
                                end.setHours(23,59,59,0)
                                QGroundControl.airspaceManager.flightPlan.loadFlightList(start, end)
Gus Grubba's avatar
Gus Grubba committed
608 609 610
                            }
                        }
                        QGCButton {
611
                            text:           qsTr("End Selected")
Gus Grubba's avatar
Gus Grubba committed
612 613 614 615
                            backRadius:     4
                            heightFactor:   0.3333
                            showBorder:     true
                            width:          _buttonWidth
616 617 618
                            enabled: {
                                var o = _flightList.get(tableView.currentRow)
                                return o && o.active
Gus Grubba's avatar
Gus Grubba committed
619 620 621
                            }
                            anchors.horizontalCenter: parent.horizontalCenter
                            onClicked: {
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
                                endFlightDialog.visible = true
                            }
                            MessageDialog {
                                id:         endFlightDialog
                                visible:    false
                                icon:       StandardIcon.Warning
                                standardButtons: StandardButton.Yes | StandardButton.No
                                title:      qsTr("End Flight")
                                text:       qsTr("Confirm ending active flight?")
                                onYes: {
                                    var o = _flightList.get(tableView.currentRow)
                                    if(o) {
                                        QGroundControl.airspaceManager.flightPlan.endFlight(o.flightID)
                                    }
                                    endFlightDialog.visible = false
                                }
                                onNo: {
                                    endFlightDialog.visible = false
640
                                }
Gus Grubba's avatar
Gus Grubba committed
641 642 643 644 645 646 647 648 649 650 651 652 653
                            }
                        }
                        QGCButton {
                            text:           qsTr("Close")
                            backRadius:     4
                            heightFactor:   0.3333
                            showBorder:     true
                            width:          _buttonWidth
                            anchors.horizontalCenter: parent.horizontalCenter
                            onClicked: {
                                panelLoader.sourceComponent = null
                            }
                        }
Gus Grubba's avatar
Gus Grubba committed
654
                        QGCLabel {
655
                            text:           _flightList.count > 0 ? _flightList.count + qsTr(" Flights Loaded") : qsTr("No Flights Loaded")
Gus Grubba's avatar
Gus Grubba committed
656 657 658 659 660 661 662 663 664
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
                        QGCLabel {
                            text:           qsTr("A maximum of 250 flights were loaded")
                            color:          qgcPal.colorOrange
                            font.pixelSize: ScreenTools.smallFontPointSize
                            visible:        _flightList.count >= 250
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
Gus Grubba's avatar
Gus Grubba committed
665 666
                    }
                    QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
667 668
                        text:           qsTr("Flight Area ") + (tableView.currentRow + 1)
                        visible:        !QGroundControl.airspaceManager.flightPlan.loadingFlightList && _flightList.count > 0 && tableView.currentRow >= 0
Gus Grubba's avatar
Gus Grubba committed
669 670
                        anchors.bottom: map.top
                        anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
671
                        anchors.horizontalCenter: parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
672 673 674 675 676 677 678 679 680 681 682
                    }
                    Map {
                        id:             map
                        width:          ScreenTools.defaultFontPixelWidth * 40
                        height:         width * 0.6666
                        anchors.bottom: parent.bottom
                        anchors.horizontalCenter: parent.horizontalCenter
                        zoomLevel:      QGroundControl.flightMapZoom
                        center:         QGroundControl.flightMapPosition
                        gesture.acceptedGestures: MapGestureArea.PinchGesture
                        plugin:         Plugin { name: "QGroundControl" }
Gus Grubba's avatar
Gus Grubba committed
683
                        visible:        !QGroundControl.airspaceManager.flightPlan.loadingFlightList && _flightList.count > 0 && tableView.currentRow >= 0
Gus Grubba's avatar
Gus Grubba committed
684 685 686
                        function updateActiveMapType() {
                            var settings =  QGroundControl.settingsManager.flightMapSettings
                            var fullMapName = settings.mapProvider.enumStringValue + " " + settings.mapType.enumStringValue
Gus Grubba's avatar
Gus Grubba committed
687 688 689
                            for (var i = 0; i < map.supportedMapTypes.length; i++) {
                                if (fullMapName === map.supportedMapTypes[i].name) {
                                    map.activeMapType = map.supportedMapTypes[i]
Gus Grubba's avatar
Gus Grubba committed
690
                                    return
Gus Grubba's avatar
Gus Grubba committed
691 692 693
                                }
                            }
                        }
694 695 696 697
                        MapPolygon {
                            id:             flightArea
                            color:          Qt.rgba(1,0,0,0.2)
                            border.color:   Qt.rgba(1,1,1,0.65)
698
                        }
Gus Grubba's avatar
Gus Grubba committed
699 700 701 702 703 704 705 706 707 708 709 710 711
                        Component.onCompleted: {
                            updateActiveMapType()
                        }
                        Connections {
                            target:             QGroundControl.settingsManager.flightMapSettings.mapType
                            onRawValueChanged:  updateActiveMapType()
                        }

                        Connections {
                            target:             QGroundControl.settingsManager.flightMapSettings.mapProvider
                            onRawValueChanged:  updateActiveMapType()
                        }

Gus Grubba's avatar
Gus Grubba committed
712
                    }
Gus Grubba's avatar
Gus Grubba committed
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
                    Calendar {
                        id: fromPicker
                        anchors.centerIn: parent
                        visible: false;
                        onClicked: {
                            visible = false;
                        }
                    }
                    Calendar {
                        id: toPicker
                        anchors.centerIn: parent
                        visible: false;
                        minimumDate: fromPicker.selectedDate
                        onClicked: {
                            visible = false;
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
730
                }
Gus Grubba's avatar
Gus Grubba committed
731 732 733 734
            }
        }
    }
}