Skip to content
AirmapSettings.qml 38.3 KiB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Gus Grubba's avatar
Gus Grubba committed
 *
 * 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
import QtGraphicalEffects       1.0
import QtMultimedia             5.5
Gus Grubba's avatar
Gus Grubba committed
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
import QtLocation               5.3
import QtPositioning            5.3
Gus Grubba's avatar
Gus Grubba committed

import QGroundControl                       1.0
import QGroundControl.Airspace              1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.Controllers           1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.Controls              1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.FactControls          1.0
import QGroundControl.FactSystem            1.0
import QGroundControl.FlightMap             1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.Palette               1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.ScreenTools           1.0
Gus Grubba's avatar
Gus Grubba committed
import QGroundControl.SettingsManager       1.0

Gus Grubba's avatar
Gus Grubba committed
    anchors.fill:       parent
    anchors.margins:    ScreenTools.defaultFontPixelWidth

    property real _labelWidth:                  ScreenTools.defaultFontPixelWidth * 20
Gus Grubba's avatar
Gus Grubba committed
    property real _editFieldWidth:              ScreenTools.defaultFontPixelWidth * 20
Gus Grubba's avatar
Gus Grubba committed
    property real _buttonWidth:                 ScreenTools.defaultFontPixelWidth * 18
    property real _panelWidth:                  _root.width * _internalWidthRatio
Gus Grubba's avatar
Gus Grubba committed
    property Fact _enableAirMapFact:            QGroundControl.settingsManager.airMapSettings.enableAirMap
Gus Grubba's avatar
Gus Grubba committed
    property bool _airMapEnabled:               _enableAirMapFact.rawValue
    property var  _authStatus:                  QGroundControl.airspaceManager.authStatus
Gus Grubba's avatar
Gus Grubba committed

    readonly property real _internalWidthRatio:          0.8

    QGCFlickable {
        clip:               true
        anchors.fill:       parent
        contentHeight:      settingsColumn.height
        contentWidth:       settingsColumn.width
        Column {
            id:                 settingsColumn
            width:              _root.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
                QGCLabel {
                    id:             generalLabel
                    text:           qsTr("General")
                    font.family:    ScreenTools.demiboldFontFamily
Gus Grubba's avatar
Gus Grubba committed
                }
            }
            Rectangle {
                height:                     generalRow.height + (ScreenTools.defaultFontPixelHeight * 2)
                width:                      _panelWidth
                color:                      qgcPal.windowShade
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                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
Gus Grubba's avatar
Gus Grubba committed
                        }
                        FactCheckBox {
                            text:       qsTr("Enable Telemetry")
                            fact:       _enableTelemetryFact
                            visible:    _enableTelemetryFact.visible
                            enabled:    _airMapEnabled
                            property Fact _enableTelemetryFact: QGroundControl.settingsManager.airMapSettings.enableTelemetry
                        }
                        FactCheckBox {
                            text:       qsTr("Show Airspace on Map (Experimental)")
                            fact:       _enableAirspaceFact
                            visible:    _enableAirspaceFact.visible
                            enabled:    _airMapEnabled
                            property Fact _enableAirspaceFact: QGroundControl.settingsManager.airMapSettings.enableAirspace
                        }
                    }
                    QGCButton {
                        text:           qsTr("Clear Saved Answers")
                        enabled:        _enableAirMapFact.rawValue
                        onClicked:      clearDialog.open()
                        anchors.verticalCenter: parent.verticalCenter
                        MessageDialog {
                            id:                 clearDialog
                            visible:            false
                            icon:               StandardIcon.Warning
                            standardButtons:    StandardButton.Yes | StandardButton.No
                            title:              qsTr("Clear Saved Answers")
                            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
                        }
                    }
                }
            }
            //-----------------------------------------------------------------
            //-- 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
Gus Grubba's avatar
Gus Grubba committed
                }
            }
            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
Gus Grubba's avatar
Gus Grubba committed
                    }
Gus Grubba's avatar
Gus Grubba committed
                    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
                    }
                }
            }
            //-----------------------------------------------------------------
            //-- 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
                    columns:            3
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.25
                    anchors.centerIn:   parent
                    QGCLabel        { text: qsTr("User Name:") }
                    FactTextField {
                        fact:           _usernameFact
                        width:          _editFieldWidth
                        enabled:        _airMapEnabled
                        visible:        _usernameFact.visible
                        Layout.fillWidth:    true
                        Layout.minimumWidth: _editFieldWidth
                        property Fact _usernameFact: QGroundControl.settingsManager.airMapSettings.userName
                    }
                    QGCLabel {
                        text: {
                            if(!QGroundControl.airspaceManager.connected)
                                return qsTr("Not Connected")
                            switch(_authStatus) {
                            case AirspaceManager.Unknown:
                            case AirspaceManager.Anonymous:
                                return qsTr("Anonymous")
                            case AirspaceManager.Authenticated:
                                return qsTr("Authenticated")
                            default:
                                return qsTr("Authentication Error")
Gus Grubba's avatar
Gus Grubba committed
                            }
Gus Grubba's avatar
Gus Grubba committed
                        }
                        Layout.rowSpan:     2
                        Layout.alignment:   Qt.AlignVCenter
Gus Grubba's avatar
Gus Grubba committed
                    }
                    QGCLabel { text: qsTr("Password:") }
                    FactTextField {
                        fact:           _passwordFact
                        width:          _editFieldWidth
                        enabled:        _airMapEnabled
                        visible:        _passwordFact.visible
                        echoMode:       TextInput.Password
                        Layout.fillWidth:    true
                        Layout.minimumWidth: _editFieldWidth
                        property Fact _passwordFact: QGroundControl.settingsManager.airMapSettings.password
Gus Grubba's avatar
Gus Grubba committed
                    }
                    Item {
                        width:  1
                        height: 1
                    }
                    Item {
                        width:  1
                        height: 1
                        Layout.columnSpan: 3
Gus Grubba's avatar
Gus Grubba committed
                    }
Gus Grubba's avatar
Gus Grubba committed
                    QGCLabel {
                        text:               qsTr("Forgot Your AirMap Password?")
                        Layout.alignment:   Qt.AlignHCenter
                        Layout.columnSpan:  3
Gus Grubba's avatar
Gus Grubba committed
                    }
                    Item {
                        width:  1
                        height: 1
                        Layout.columnSpan:  3
                    }
                    QGCButton {
                        text:               qsTr("Register for an AirMap Account")
                        Layout.alignment:   Qt.AlignHCenter
                        Layout.columnSpan:  3
                        enabled:            _airMapEnabled
                        onClicked: {
                            Qt.openUrlExternally("https://www.airmap.com");
Gus Grubba's avatar
Gus Grubba committed
                    }
                }
            }
            //-----------------------------------------------------------------
            //-- Pilot Profile
            Item {
                //-- Disabled for now
                width:                      _panelWidth
                height:                     profileLabel.height
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                visible:                    false // QGroundControl.settingsManager.appSettings.visible
                QGCLabel {
                    id:             profileLabel
                    text:           qsTr("Pilot Profile (WIP)")
                    font.family:    ScreenTools.demiboldFontFamily
                }
            }
            Rectangle {
                //-- Disabled for now
                height:                     profileGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
                width:                      _panelWidth
                color:                      qgcPal.windowShade
                visible:                    false // QGroundControl.settingsManager.appSettings.visible
                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") }
                }
            }
            //-----------------------------------------------------------------
            //-- License (Will this stay here?)
            Item {
                width:                      _panelWidth
                height:                     licenseLabel.height
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                visible:                    QGroundControl.settingsManager.airMapSettings.usePersonalApiKey.visible
                QGCLabel {
                    id:                     licenseLabel
                    text:                   qsTr("License")
                    font.family:            ScreenTools.demiboldFontFamily
                }
            }
            Rectangle {
                height:                     licenseGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
                width:                      _panelWidth
                color:                      qgcPal.windowShade
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                visible:                    QGroundControl.settingsManager.airMapSettings.usePersonalApiKey.visible
                GridLayout {
                    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
                        Layout.columnSpan:  2
                    }
                    Item {
                        width:      1
                        height:     1
                        visible:    hasPrivateKey.checked
                        Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
                    }
                    QGCLabel        { text: qsTr("API Key:"); visible: hasPrivateKey.checked; }
                    FactTextField   { fact: QGroundControl.settingsManager.airMapSettings.apiKey; width: _editFieldWidth * 2; visible: hasPrivateKey.checked; Layout.fillWidth: true; Layout.minimumWidth: _editFieldWidth * 2; }
                    QGCLabel        { text: qsTr("Client ID:"); visible: hasPrivateKey.checked; }
                    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
                }
            }
            //-----------------------------------------------------------------
            //-- Flight List
            Item {
                width:                      _panelWidth
                height:                     flightListLabel.height
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                visible:                    QGroundControl.settingsManager.appSettings.visible
                QGCLabel {
                    id:                     flightListLabel
                    text:                   qsTr("Flight List Management")
                    font.family:            ScreenTools.demiboldFontFamily
                }
            }
            Rectangle {
                height:                     flightListButton.height + (ScreenTools.defaultFontPixelHeight * 2)
                width:                      _panelWidth
                color:                      qgcPal.windowShade
                anchors.margins:            ScreenTools.defaultFontPixelWidth
                anchors.horizontalCenter:   parent.horizontalCenter
                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
Gus Grubba's avatar
Gus Grubba committed
    }
    //---------------------------------------------------------------
    //-- Flight List
    Component {
        id:             flightList
        Rectangle {
            id:         flightListRoot
Gus Grubba's avatar
Gus Grubba committed
            color:      qgcPal.window
Gus Grubba's avatar
Gus Grubba committed
            property var    _flightList: QGroundControl.airspaceManager.flightPlan.flightList
            property real   _mapWidth:   ScreenTools.defaultFontPixelWidth * 40
Gus Grubba's avatar
Gus Grubba committed
            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
                    selectionMode:      SelectionMode.SingleSelection
                    Layout.alignment:   Qt.AlignVCenter
Gus Grubba's avatar
Gus Grubba committed
                    Layout.fillWidth:   true
                    Layout.fillHeight:  true
                    onCurrentRowChanged: {
                        var o = _flightList.get(tableView.currentRow)
                        if(o) {
                            flightArea.path = o.boundingBox
                            map.fitViewportToMapItems()
Gus Grubba's avatar
Gus Grubba committed
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
                        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")
                        width:  ScreenTools.defaultFontPixelWidth * 18
Gus Grubba's avatar
Gus Grubba committed
                        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
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
Gus Grubba's avatar
Gus Grubba committed
                        }
                    }
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
                        title:  qsTr("Flight Start")
                        width:  ScreenTools.defaultFontPixelWidth * 18
Gus Grubba's avatar
Gus Grubba committed
                        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
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
                    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
                    TableViewColumn {
Gus Grubba's avatar
Gus Grubba committed
                        title:  qsTr("State")
                        width:  ScreenTools.defaultFontPixelWidth * 8
Gus Grubba's avatar
Gus Grubba committed
                        horizontalAlignment: Text.AlignHCenter
                        delegate : Text  {
                            horizontalAlignment: Text.AlignHCenter
                            text: {
                                var o = _flightList.get(styleData.row)
                                return o ? (o.active ? qsTr("Active") : qsTr("Completed")) : qsTr("Unknown")
Gus Grubba's avatar
Gus Grubba committed
                            color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
                            font.family: ScreenTools.fixedFontFamily
                            font.pixelSize: ScreenTools.smallFontPointSize
Gus Grubba's avatar
Gus Grubba committed
                    width:              flightListRoot._mapWidth
Gus Grubba's avatar
Gus Grubba committed
                    height:             parent.height
                    Layout.alignment:   Qt.AlignTop | Qt.AlignLeft
Gus Grubba's avatar
Gus Grubba committed
                    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
                    Column {
Gus Grubba's avatar
Gus Grubba committed
                        spacing:            ScreenTools.defaultFontPixelHeight * 0.75
                        visible:            !QGroundControl.airspaceManager.flightPlan.loadingFlightList
Gus Grubba's avatar
Gus Grubba committed
                        anchors.top:        parent.top
                        anchors.horizontalCenter: parent.horizontalCenter
                        QGCLabel {
                            text:           qsTr("Flight List")
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
Gus Grubba's avatar
Gus Grubba committed
                        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
                        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
                                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
                            }
                        }
                        QGCButton {
                            text:           qsTr("End Selected")
Gus Grubba's avatar
Gus Grubba committed
                            backRadius:     4
                            heightFactor:   0.3333
                            showBorder:     true
                            width:          _buttonWidth
                            enabled: {
                                var o = _flightList.get(tableView.currentRow)
                                return o && o.active
Gus Grubba's avatar
Gus Grubba committed
                            }
                            anchors.horizontalCenter: parent.horizontalCenter
                            onClicked: {
                                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
Gus Grubba's avatar
Gus Grubba committed
                            }
                        }
                        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
                        QGCLabel {
                            text:           _flightList.count > 0 ? _flightList.count + qsTr(" Flights Loaded") : qsTr("No Flights Loaded")
Gus Grubba's avatar
Gus Grubba committed
                            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
                    }
                    QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
                        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
                        anchors.bottom: map.top
                        anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
                        anchors.horizontalCenter: parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
                    }
                    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
                        visible:        !QGroundControl.airspaceManager.flightPlan.loadingFlightList && _flightList.count > 0 && tableView.currentRow >= 0
Gus Grubba's avatar
Gus Grubba committed
                        function updateActiveMapType() {
                            var settings =  QGroundControl.settingsManager.flightMapSettings
                            var fullMapName = settings.mapProvider.value + " " + settings.mapType.value
Gus Grubba's avatar
Gus Grubba committed
                            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
                                    return
                        MapPolygon {
                            id:             flightArea
                            color:          Qt.rgba(1,0,0,0.2)
                            border.color:   Qt.rgba(1,1,1,0.65)
Gus Grubba's avatar
Gus Grubba committed
                        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
                    }
Gus Grubba's avatar
Gus Grubba committed
                    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
                }
Gus Grubba's avatar
Gus Grubba committed
            }
        }
    }
}