Skip to content
Snippets Groups Projects
AirspaceControl.qml 50.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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
    import QtQml                    2.2
    
    import QtGraphicalEffects       1.0
    
    Gus Grubba's avatar
    Gus Grubba committed
    
    import QGroundControl               1.0
    
    import QGroundControl.Airmap        1.0
    import QGroundControl.Airspace      1.0
    
    Gus Grubba's avatar
    Gus Grubba committed
    import QGroundControl.Controls      1.0
    import QGroundControl.FactControls  1.0
    import QGroundControl.Palette       1.0
    
    import QGroundControl.ScreenTools   1.0
    import QGroundControl.Vehicle       1.0
    
    Gus Grubba's avatar
    Gus Grubba committed
    
    Item {
        id:     _root
        width:  parent.width
    
    Gus Grubba's avatar
    Gus Grubba committed
        height: _colapsed ? colapsedRect.height : expandedRect.height
    
    Gus Grubba's avatar
    Gus Grubba committed
    
    
    Gus Grubba's avatar
    Gus Grubba committed
        property bool   showColapse:        true
    
    
        property color  _airspaceColor:     _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
        property bool   _validRules:        QGroundControl.airspaceManager.ruleSets.valid
        property bool   _validAdvisories:   QGroundControl.airspaceManager.advisories.valid
    
        property color  _textColor:         qgcPal.text
    
        property bool   _colapsed:          !QGroundControl.airspaceManager.airspaceVisible
    
        property var    _flightPermit:      QGroundControl.airspaceManager.flightPlan.flightPermitStatus
    
        property bool   _dirty:             false
    
    Gus Grubba's avatar
    Gus Grubba committed
    
        readonly property real      _radius:            ScreenTools.defaultFontPixelWidth * 0.5
        readonly property color     _colorOrange:       "#d75e0d"
        readonly property color     _colorBrown:        "#3c2b24"
        readonly property color     _colorLightBrown:   "#5a4e49"
        readonly property color     _colorGray:         "#615c61"
    
        readonly property color     _colorLightGray:    "#a0a0a0"
    
    Gus Grubba's avatar
    Gus Grubba committed
        readonly property color     _colorMidBrown:     "#3a322f"
        readonly property color     _colorYellow:       "#d7c61d"
        readonly property color     _colorWhite:        "#ffffff"
    
    Gus Grubba's avatar
    Gus Grubba committed
        readonly property color     _colorRed:          "#aa1200"
        readonly property color     _colorGreen:        "#125f00"
    
    Gus Grubba's avatar
    Gus Grubba committed
    
        QGCPalette {
            id: qgcPal
            colorGroupEnabled: enabled
        }
    
    
    Gus Grubba's avatar
    Gus Grubba committed
        function getAispaceColor(color) {
            if(color === AirspaceAdvisoryProvider.Green)  return _colorGreen;
            if(color === AirspaceAdvisoryProvider.Yellow) return _colorYellow;
            if(color === AirspaceAdvisoryProvider.Orange) return _colorOrange;
            if(color === AirspaceAdvisoryProvider.Red)    return _colorRed;
            return _colorGray;
        }
    
    
        function hasBriefRules() {
            if(QGroundControl.airspaceManager.flightPlan.rulesViolation.count > 0)
                return true;
            if(QGroundControl.airspaceManager.flightPlan.rulesInfo.count > 0)
                return true;
            if(QGroundControl.airspaceManager.flightPlan.rulesReview.count > 0)
                return true;
            if(QGroundControl.airspaceManager.flightPlan.rulesFollowing.count > 0)
                return true;
            return false;
        }
    
    
        on_AirspaceColorChanged: {
           if(_validAdvisories) {
    
               if(QGroundControl.airspaceManager.advisories.airspaceColor === AirspaceAdvisoryProvider.Yellow) {
    
                   _textColor = "#000000"
                   return
               }
           }
           _textColor = _colorWhite
        }
    
    
    Gus Grubba's avatar
    Gus Grubba committed
        //---------------------------------------------------------------
        //-- Colapsed State
        Rectangle {
            id:         colapsedRect
            width:      parent.width
    
    Gus Grubba's avatar
    Gus Grubba committed
            height:     _colapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
    
            color:      _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
    
    Gus Grubba's avatar
    Gus Grubba committed
            radius:     _radius
    
    Gus Grubba's avatar
    Gus Grubba committed
            visible:    _colapsed
    
    Gus Grubba's avatar
    Gus Grubba committed
            Row {
                id:                     colapsedRow
                spacing:                ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                anchors.verticalCenter: parent.verticalCenter
                QGCColoredImage {
                    width:                  height
                    height:                 ScreenTools.defaultFontPixelWidth * 2.5
                    sourceSize.height:      height
    
                    source:                 "qrc:/airmap/advisory-icon.svg"
                    color:                  _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                    anchors.verticalCenter: parent.verticalCenter
                }
    
    Gus Grubba's avatar
    Gus Grubba committed
                    anchors.verticalCenter: parent.verticalCenter
    
                    QGCLabel {
                        text:               qsTr("Airspace")
                        color:              _textColor
                    }
                    QGCLabel {
                        text:               _validAdvisories ? QGroundControl.airspaceManager.advisories.advisories.count + qsTr(" Advisories") : ""
                        color:              _textColor
                        visible:            _validAdvisories
                        font.pointSize:     ScreenTools.smallFontPointSize
                    }
    
    Gus Grubba's avatar
    Gus Grubba committed
                }
    
    Gus Grubba's avatar
    Gus Grubba committed
                Item {
                    width:  ScreenTools.defaultFontPixelWidth
                    height: 1
                }
                AirspaceWeather {
    
                    iconHeight:             ScreenTools.defaultFontPixelHeight * 2
                    visible:                QGroundControl.airspaceManager.weatherInfo.valid
                    contentColor:           _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                    anchors.verticalCenter: parent.verticalCenter
                }
    
    Gus Grubba's avatar
    Gus Grubba committed
            }
    
    Gus Grubba's avatar
    Gus Grubba committed
            QGCColoredImage {
                width:                  height
                height:                 ScreenTools.defaultFontPixelWidth * 2.5
                sourceSize.height:      height
                source:                 "qrc:/airmap/expand.svg"
    
                color:                  _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                anchors.right:          parent.right
                anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                anchors.verticalCenter: parent.verticalCenter
            }
    
    Gus Grubba's avatar
    Gus Grubba committed
            MouseArea {
                anchors.fill:   parent
    
    Gus Grubba's avatar
    Gus Grubba committed
                onClicked:  {
    
                    QGroundControl.airspaceManager.airspaceVisible = true
    
    Gus Grubba's avatar
    Gus Grubba committed
            }
        }
        //---------------------------------------------------------------
        //-- Expanded State
        Rectangle {
            id:         expandedRect
            width:      parent.width
    
    Gus Grubba's avatar
    Gus Grubba committed
            height:     !_colapsed ? expandedCol.height + ScreenTools.defaultFontPixelHeight : 0
    
            color:      _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
    
    Gus Grubba's avatar
    Gus Grubba committed
            radius:     _radius
    
    Gus Grubba's avatar
    Gus Grubba committed
            visible:    !_colapsed
    
    Gus Grubba's avatar
    Gus Grubba committed
            MouseArea {
                anchors.fill:   parent
                onWheel:        { wheel.accepted = true; }
                onPressed:      { mouse.accepted = true; }
                onReleased:     { mouse.accepted = true; }
            }
    
    Gus Grubba's avatar
    Gus Grubba committed
            Column {
                id:                     expandedCol
                spacing:                ScreenTools.defaultFontPixelHeight * 0.5
                anchors.left:           parent.left
                anchors.right:          parent.right
                anchors.verticalCenter: parent.verticalCenter
                //-- Header
                Item {
                    height:             expandedRow.height
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    Row {
                        id:                         expandedRow
                        spacing:                    ScreenTools.defaultFontPixelWidth
                        anchors.left:               parent.left
                        anchors.leftMargin:         ScreenTools.defaultFontPixelWidth
                        QGCColoredImage {
                            width:                  height
                            height:                 ScreenTools.defaultFontPixelWidth * 2.5
                            sourceSize.height:      height
                            source:                 "qrc:/airmap/advisory-icon.svg"
    
                            color:                  _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        Column {
                            spacing:                0
                            anchors.verticalCenter: parent.verticalCenter
                            QGCLabel {
                                text:               qsTr("Airspace")
    
                                color:              _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                            }
                            QGCLabel {
    
                                text:               _validAdvisories ? QGroundControl.airspaceManager.advisories.advisories.count + qsTr(" Advisories") : ""
    
                                color:              _textColor
                                visible:            _validAdvisories
    
    Gus Grubba's avatar
    Gus Grubba committed
                                font.pointSize:     ScreenTools.smallFontPointSize
                            }
                        }
    
    Gus Grubba's avatar
    Gus Grubba committed
                        Item {
                            width:  ScreenTools.defaultFontPixelWidth
                            height: 1
                        }
                        AirspaceWeather {
    
                            visible:                QGroundControl.airspaceManager.weatherInfo.valid && showColapse
    
                            contentColor:           _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                            anchors.verticalCenter: parent.verticalCenter
                        }
    
    Gus Grubba's avatar
    Gus Grubba committed
                    }
    
    Gus Grubba's avatar
    Gus Grubba committed
                    QGCColoredImage {
                        width:                  height
                        height:                 ScreenTools.defaultFontPixelWidth * 2.5
                        sourceSize.height:      height
                        source:                 "qrc:/airmap/colapse.svg"
    
                        color:                  _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                        visible:                showColapse
    
    Gus Grubba's avatar
    Gus Grubba committed
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                        MouseArea {
                            anchors.fill:   parent
    
                            enabled:        showColapse
                            onClicked:      QGroundControl.airspaceManager.airspaceVisible = false
    
    Gus Grubba's avatar
    Gus Grubba committed
                        }
                    }
    
    Gus Grubba's avatar
    Gus Grubba committed
                    AirspaceWeather {
    
                        visible:                QGroundControl.airspaceManager.weatherInfo.valid && !showColapse
    
                        contentColor:           _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                    }
    
    Gus Grubba's avatar
    Gus Grubba committed
                }
                //-- Contents (Brown Box)
                Rectangle {
                    color:                      _colorBrown
                    height:                     airspaceCol.height + ScreenTools.defaultFontPixelHeight
                    radius:                     _radius
                    anchors.left:               parent.left
                    anchors.leftMargin:         ScreenTools.defaultFontPixelWidth * 0.5
                    anchors.right:              parent.right
                    anchors.rightMargin:        ScreenTools.defaultFontPixelWidth * 0.5
                    Column {
                        id:                     airspaceCol
                        spacing:                ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.left:           parent.left
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth  * 0.5
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth  * 0.5
                        anchors.verticalCenter: parent.verticalCenter
                        //-- Regulations
                        Rectangle {
                            color:                          _colorLightBrown
                            height:                         regCol.height + ScreenTools.defaultFontPixelHeight
                            radius:                         _radius
                            anchors.left:                   parent.left
                            anchors.leftMargin:             ScreenTools.defaultFontPixelWidth * 0.5
                            anchors.right:                  parent.right
                            anchors.rightMargin:            ScreenTools.defaultFontPixelWidth * 0.5
                            Column {
                                id:                         regCol
    
                                spacing:                    ScreenTools.defaultFontPixelHeight * 0.25
    
    Gus Grubba's avatar
    Gus Grubba committed
                                anchors.left:               parent.left
                                anchors.leftMargin:         ScreenTools.defaultFontPixelWidth  * 0.5
                                anchors.right:              parent.right
                                anchors.rightMargin:        ScreenTools.defaultFontPixelWidth  * 0.5
                                anchors.verticalCenter:     parent.verticalCenter
                                QGCLabel {
                                    text:                   qsTr("Airspace Regulations")
                                    color:                  _colorWhite
                                    anchors.horizontalCenter: parent.horizontalCenter
                                }
                                QGCLabel {
    
                                    text:                       qsTr("Advisories based on the selected rules.")
                                    color:                      _colorWhite
                                    anchors.horizontalCenter:   parent.horizontalCenter
                                    font.pointSize:             ScreenTools.smallFontPointSize
    
    Gus Grubba's avatar
    Gus Grubba committed
                                }
    
                                Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.125; }
    
    Gus Grubba's avatar
    Gus Grubba committed
                                GridLayout {
                                    columns:                2
                                    anchors.left:           parent.left
                                    anchors.right:          parent.right
                                    Rectangle {
                                        width:                  regButton.height
                                        height:                 width
                                        radius:                 2
                                        color:                  _colorGray
                                        anchors.verticalCenter: parent.verticalCenter
                                        QGCColoredImage {
    
    Gus Grubba's avatar
    Gus Grubba committed
                                            id:                 pencilIcon
    
    Gus Grubba's avatar
    Gus Grubba committed
                                            width:              height
                                            height:             parent.height * 0.5
                                            sourceSize.height:  height
                                            source:             "qrc:/airmap/pencil.svg"
                                            color:              _colorWhite
    
    Gus Grubba's avatar
    Gus Grubba committed
                                            anchors.centerIn:   parent
    
                                            MouseArea {
                                                anchors.fill:   parent
                                                onClicked: {
                                                    rootLoader.sourceComponent = ruleSelector
                                                    mainWindow.disableToolbar()
                                                }
                                            }
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        }
                                    }
                                    Rectangle {
                                        id:                     regButton
    
                                        height:                 ScreenTools.defaultFontPixelHeight * 1.5
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        radius:                 2
                                        color:                  _colorMidBrown
                                        Layout.fillWidth:       true
                                        QGCLabel {
    
                                            text:                   _validRules ? QGroundControl.airspaceManager.ruleSets.selectedRuleSets : qsTr("None")
    
                                            elide:                  Text.ElideRight
                                            horizontalAlignment:    Text.AlignHCenter
                                            color:                  _colorWhite
                                            anchors.left:           parent.left
                                            anchors.leftMargin:     ScreenTools.defaultFontPixelWidth  * 0.5
                                            anchors.right:          parent.right
                                            anchors.rightMargin:    ScreenTools.defaultFontPixelWidth  * 0.5
                                            anchors.verticalCenter: parent.verticalCenter
    
    Gus Grubba's avatar
    Gus Grubba committed
                        Flickable {
                            clip:               true
    
                            height:             ScreenTools.defaultFontPixelHeight * 6
    
    Gus Grubba's avatar
    Gus Grubba committed
                            contentHeight:      advisoryCol.height
                            flickableDirection: Flickable.VerticalFlick
                            anchors.left:       parent.left
                            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 0.5
                            anchors.right:      parent.right
                            anchors.rightMargin:ScreenTools.defaultFontPixelWidth * 0.5
                            Column {
                                id:             advisoryCol
                                spacing:        ScreenTools.defaultFontPixelHeight * 0.5
                                anchors.right:  parent.right
                                anchors.left:   parent.left
                                Repeater {
    
                                    model:      _validAdvisories ? QGroundControl.airspaceManager.advisories.advisories : []
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    delegate: AirspaceRegulation {
                                        regTitle:            object.typeStr
                                        regText:             object.name
                                        regColor:            getAispaceColor(object.color)
                                        anchors.right:       parent.right
                                        anchors.rightMargin: ScreenTools.defaultFontPixelWidth
                                        anchors.left:        parent.left
                                        anchors.leftMargin:  ScreenTools.defaultFontPixelWidth
                                    }
                                }
                            }
    
    Gus Grubba's avatar
    Gus Grubba committed
                        }
                    }
                }
                //-- Footer
    
                QGCButton {
                    text:           qsTr("File Flight Plan")
                    backRadius:     4
                    heightFactor:   0.3333
                    showBorder:     true
                    width:          ScreenTools.defaultFontPixelWidth * 16
    
                    anchors.horizontalCenter: parent.horizontalCenter
    
                    onClicked: {
                        rootLoader.sourceComponent = flightDetails
                        mainWindow.disableToolbar()
    
    Gus Grubba's avatar
    Gus Grubba committed
                QGCLabel {
                    text:           qsTr("Powered by <b>AIRMAP</b>")
    
                    color:          _textColor
    
    Gus Grubba's avatar
    Gus Grubba committed
                    font.pointSize: ScreenTools.smallFontPointSize
                    anchors.horizontalCenter: parent.horizontalCenter
                }
            }
        }
    
        //---------------------------------------------------------------
        //-- Rule Selector
        Component {
            id:             ruleSelector
            Rectangle {
                width:      mainWindow.width
                height:     mainWindow.height
                color:      Qt.rgba(0,0,0,0.1)
                MouseArea {
                    anchors.fill:   parent
    
    Gus Grubba's avatar
    Gus Grubba committed
                    onWheel:   { wheel.accepted = true; }
    
                    onClicked: {
                        mainWindow.enableToolbar()
                        rootLoader.sourceComponent = null
                    }
                }
                Rectangle {
                    id:             ruleSelectorShadow
                    anchors.fill:   ruleSelectorRect
                    radius:         ruleSelectorRect.radius
                    color:          qgcPal.window
                    visible:        false
                }
                DropShadow {
                    anchors.fill:       ruleSelectorShadow
                    visible:            ruleSelectorRect.visible
                    horizontalOffset:   4
                    verticalOffset:     4
                    radius:             32.0
                    samples:            65
                    color:              Qt.rgba(0,0,0,0.75)
                    source:             ruleSelectorShadow
                }
                Rectangle {
                    id:                 ruleSelectorRect
    
    Gus Grubba's avatar
    Gus Grubba committed
                    x:                  0
                    y:                  0
    
                    color:              qgcPal.window
                    width:              rulesCol.width  + ScreenTools.defaultFontPixelWidth
                    height:             rulesCol.height + ScreenTools.defaultFontPixelHeight
                    radius:             ScreenTools.defaultFontPixelWidth
                    Column {
                        id:             rulesCol
                        spacing:        ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.centerIn: parent
                        //-- Regulations
                        Rectangle {
                            color:      qgcPal.windowShade
                            height:     rulesTitle.height + ScreenTools.defaultFontPixelHeight
                            width:      parent.width * 0.95
                            radius:     _radius
                            anchors.horizontalCenter: parent.horizontalCenter
                            QGCLabel {
                                id:         rulesTitle
                                text:       qsTr("Airspace Regulation Options")
                                anchors.centerIn: parent
                            }
                        }
                        Flickable {
                            clip:           true
                            width:          ScreenTools.defaultFontPixelWidth  * 30
                            height:         ScreenTools.defaultFontPixelHeight * 14
                            contentHeight:  rulesetCol.height
                            flickableDirection: Flickable.VerticalFlick
                            Column {
                                id:         rulesetCol
    
    Gus Grubba's avatar
    Gus Grubba committed
                                spacing:    ScreenTools.defaultFontPixelHeight * 0.25
    
                                anchors.right: parent.right
                                anchors.left:  parent.left
    
    Gus Grubba's avatar
    Gus Grubba committed
                                anchors.rightMargin:    ScreenTools.defaultFontPixelWidth * 2
                                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth * 2
                                Item {
                                    width:  1
                                    height: 1
                                }
    
                                QGCLabel {
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    text:           qsTr("PICK ONE REGULATION")
    
                                    font.pointSize: ScreenTools.smallFontPointSize
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
    
                                    model:    _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : []
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    delegate: RuleSelector {
    
                                        visible:             object.selectionType === AirspaceRuleSet.Pickone
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        rule:                object
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        anchors.right:       parent.right
    
                                        anchors.rightMargin: ScreenTools.defaultFontPixelWidth
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        anchors.left:        parent.left
                                        anchors.leftMargin:  ScreenTools.defaultFontPixelWidth
                                    }
                                }
                                Item {
                                    width:  1
                                    height: 1
                                }
                                QGCLabel {
                                    text:           qsTr("OPTIONAL")
                                    font.pointSize: ScreenTools.smallFontPointSize
                                    anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
                                }
                                Repeater {
    
                                    model:    _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : []
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    delegate: RuleSelector {
    
                                        visible:             object.selectionType === AirspaceRuleSet.Optional
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        rule:                object
                                        anchors.right:       parent.right
                                        anchors.rightMargin: ScreenTools.defaultFontPixelWidth
                                        anchors.left:        parent.left
                                        anchors.leftMargin:  ScreenTools.defaultFontPixelWidth
                                    }
                                }
                                Item {
                                    width:  1
                                    height: 1
                                }
                                QGCLabel {
                                    text:           qsTr("REQUIRED")
                                    font.pointSize: ScreenTools.smallFontPointSize
                                    anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
                                }
                                Repeater {
    
                                    model:    _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : []
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    delegate: RuleSelector {
    
                                        visible:             object.selectionType === AirspaceRuleSet.Required
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        rule:                object
    
    Gus Grubba's avatar
    Gus Grubba committed
                                        anchors.right:       parent.right
                                        anchors.rightMargin: ScreenTools.defaultFontPixelWidth
                                        anchors.left:        parent.left
    
                                        anchors.leftMargin:  ScreenTools.defaultFontPixelWidth
                                    }
                                }
                            }
                        }
                    }
                }
    
    Gus Grubba's avatar
    Gus Grubba committed
                //-- Arrow
                QGCColoredImage {
                    id:                 arrowIconShadow
                    anchors.fill:       arrowIcon
                    sourceSize.height:  height
                    source:             "qrc:/airmap/right-arrow.svg"
                    color:              qgcPal.window
                    visible:            false
                }
                DropShadow {
                    anchors.fill:       arrowIconShadow
    
                    visible:            ruleSelectorRect.visible && qgcPal.globalTheme === QGCPalette.Dark
    
    Gus Grubba's avatar
    Gus Grubba committed
                    horizontalOffset:   4
                    verticalOffset:     4
                    radius:             32.0
                    samples:            65
                    color:              Qt.rgba(0,0,0,0.75)
                    source:             arrowIconShadow
                }
                QGCColoredImage {
                    id:                 arrowIcon
                    width:              height
                    height:             ScreenTools.defaultFontPixelHeight * 2
                    sourceSize.height:  height
                    source:             "qrc:/airmap/right-arrow.svg"
                    color:              ruleSelectorRect.color
                    anchors.left:       ruleSelectorRect.right
                    anchors.top:        ruleSelectorRect.top
                    anchors.topMargin:  (ScreenTools.defaultFontPixelHeight * 4) - (height * 0.5) + (pencilIcon.height * 0.5)
                }
    
                Component.onCompleted: {
                    mainWindow.disableToolbar()
    
    Gus Grubba's avatar
    Gus Grubba committed
                    var target = mainWindow.mapFromItem(pencilIcon, 0, 0)
                    ruleSelectorRect.x = target.x - ruleSelectorRect.width - (ScreenTools.defaultFontPixelWidth * 7)
                    ruleSelectorRect.y = target.y - (ScreenTools.defaultFontPixelHeight * 4)
    
        //---------------------------------------------------------------
        //-- Flight Details
        Component {
            id:             flightDetails
            Rectangle {
                id:         flightDetailsRoot
                width:      mainWindow.width
                height:     mainWindow.height
                color:      Qt.rgba(0,0,0,0.1)
    
                property real flickHeight:  ScreenTools.defaultFontPixelHeight * 22
                property real flickWidth:   ScreenTools.defaultFontPixelWidth  * 40
                Component.onCompleted: {
                    _dirty = false
                    mainWindow.disableToolbar()
                }
    
    Gus Grubba's avatar
    Gus Grubba committed
                    hoverEnabled:   true
    
                    onWheel:        { wheel.accepted = true; }
                    onPressed:      { mouse.accepted = true; }
                    onReleased:     { mouse.accepted = true; }
                }
                Rectangle {
                    id:             flightDetailsShadow
                    anchors.fill:   flightDetailsRect
                    radius:         flightDetailsRect.radius
                    color:          qgcPal.window
                    visible:        false
                }
                DropShadow {
                    anchors.fill:       flightDetailsShadow
                    visible:            flightDetailsRect.visible
                    horizontalOffset:   4
                    verticalOffset:     4
                    radius:             32.0
                    samples:            65
                    color:              Qt.rgba(0,0,0,0.75)
                    source:             flightDetailsShadow
                }
                Rectangle {
                    id:                 flightDetailsRect
                    color:              qgcPal.window
                    width:              flDetailsRow.width  + (ScreenTools.defaultFontPixelWidth  * 4)
                    height:             flDetailsRow.height + (ScreenTools.defaultFontPixelHeight * 2)
                    radius:             ScreenTools.defaultFontPixelWidth
                    anchors.centerIn:   parent
                    Row {
                        id:             flDetailsRow
                        spacing:        ScreenTools.defaultFontPixelWidth
                        anchors.centerIn: parent
                        //---------------------------------------------------------
                        //-- Flight Details
                        Column {
                            spacing:        ScreenTools.defaultFontPixelHeight * 0.25
                            Rectangle {
                                color:          qgcPal.windowShade
                                anchors.right:  parent.right
                                anchors.left:   parent.left
                                height:         detailsLabel.height + ScreenTools.defaultFontPixelHeight
                                QGCLabel {
                                    id:             detailsLabel
                                    text:           qsTr("Flight Details")
                                    font.pointSize: ScreenTools.mediumFontPointSize
                                    font.family:    ScreenTools.demiboldFontFamily
                                    anchors.centerIn: parent
                                }
                            }
                            Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.5; }
                            Flickable {
                                clip:           true
                                width:          flightDetailsRoot.flickWidth
                                height:         flightDetailsRoot.flickHeight
                                contentHeight:  flContextCol.height
                                flickableDirection: Flickable.VerticalFlick
                                Column {
                                    id:                 flContextCol
                                    spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                                    anchors.right:      parent.right
                                    anchors.left:       parent.left
                                    QGCLabel {
                                        text:           qsTr("Flight Date & Time")
                                    }
                                    Rectangle {
                                        id:             dateRect
                                        color:          qgcPal.windowShade
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
                                        height:         datePickerCol.height + (ScreenTools.defaultFontPixelHeight * 2)
                                        Column {
                                            id:                 datePickerCol
                                            spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                                            anchors.right:      parent.right
                                            anchors.left:       parent.left
                                            anchors.verticalCenter: parent.verticalCenter
                                            QGCButton {
                                                text: {
                                                    var today = new Date();
                                                    if(datePicker.selectedDate.setHours(0,0,0,0) === today.setHours(0,0,0,0)) {
                                                        return qsTr("Today")
                                                    } else {
                                                        return datePicker.selectedDate.toLocaleDateString(Qt.locale())
                                                    }
                                                }
                                                iconSource:     "qrc:/airmap/expand.svg"
                                                anchors.right:  parent.right
                                                anchors.left:   parent.left
    
                                                onClicked: {
                                                    _dirty = true
                                                    datePicker.visible = true
                                                }
    
                                            }
                                            Item {
                                                anchors.right:  parent.right
                                                anchors.left:   parent.left
                                                height:         timeSlider.height
                                                QGCLabel {
                                                    id:         timeLabel
                                                    text:       ('00' + hour).slice(-2) + ":" + ('00' + minute).slice(-2)
                                                    width:      ScreenTools.defaultFontPixelWidth * 5
                                                    anchors.left:  parent.left
                                                    anchors.verticalCenter: parent.verticalCenter
    
    Gus Grubba's avatar
    Gus Grubba committed
                                                    property int hour:   Math.floor(timeSlider.value * 0.25)
    
                                                    property int minute: (timeSlider.value * 15) % 60
                                                }
                                                QGCSlider {
                                                    id:             timeSlider
                                                    width:          parent.width - timeLabel.width - ScreenTools.defaultFontPixelWidth
                                                    stepSize:       1
                                                    minimumValue:   0
                                                    maximumValue:   95 // 96 blocks of 15 minutes in 24 hours
                                                    anchors.right:  parent.right
                                                    anchors.verticalCenter: parent.verticalCenter
    
                                                    onValueChanged: {
                                                        _dirty = true
                                                    }
    
                                                    Component.onCompleted: {
                                                        var today = new Date()
                                                        var val = (((today.getHours() * 60) + today.getMinutes()) * (96/1440)) + 1
                                                        if(val > 95) val = 95
                                                        value = Math.ceil(val)
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
                                    QGCLabel {
                                        text:           qsTr("Flight Context")
    
                                        visible:        QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
    
                                        model:          QGroundControl.airspaceManager.flightPlan.briefFeatures
                                        visible:        QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
                                        delegate:       FlightFeature {
                                            feature:    object
                                            visible:     object && object.type !== AirspaceRuleFeature.Unknown && object.description !== "" && object.name !== ""
    
                                            anchors.right:  parent.right
                                            anchors.left:   parent.left
                                        }
                                    }
                                }
                            }
                        }
                        //---------------------------------------------------------
                        //-- Divider
                        Rectangle {
                            color:      qgcPal.text
                            width:      1
                            height:     parent.height
                            opacity:    0.25
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        //---------------------------------------------------------
                        //-- Flight Brief
                        Column {
                            spacing:        ScreenTools.defaultFontPixelHeight * 0.25
                            Rectangle {
                                color:          qgcPal.windowShade
                                anchors.right:  parent.right
                                anchors.left:   parent.left
                                height:         briefLabel.height + ScreenTools.defaultFontPixelHeight
                                QGCLabel {
                                    id:             briefLabel
                                    text:           qsTr("Flight Brief")
                                    font.pointSize: ScreenTools.mediumFontPointSize
                                    font.family:    ScreenTools.demiboldFontFamily
                                    anchors.centerIn: parent
                                }
                            }
                            Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.5; }
                            Flickable {
                                clip:           true
                                width:          flightDetailsRoot.flickWidth
                                height:         flightDetailsRoot.flickHeight - buttonRow.height - ScreenTools.defaultFontPixelHeight
                                contentHeight:  briefCol.height
                                flickableDirection: Flickable.VerticalFlick
                                Column {
                                    id:                 briefCol
                                    spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                                    anchors.right:      parent.right
                                    anchors.left:       parent.left
                                    QGCLabel {
                                        text:           qsTr("Authorizations")
                                    }
                                    Rectangle {
                                        color:          qgcPal.windowShade
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
    
                                        height:         authCol.height + ScreenTools.defaultFontPixelHeight
    
                                            spacing:            ScreenTools.defaultFontPixelHeight * 0.5
    
                                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                                            anchors.right:      parent.right
                                            anchors.left:       parent.left
                                            anchors.verticalCenter: parent.verticalCenter
                                            QGCLabel {
                                                text:           qsTr("Federal Aviation Administration")
    
                                                visible:        _flightPermit !== AirspaceFlightPlanProvider.PermitNone
    
                                            }
                                            QGCLabel {
                                                text:           qsTr("Automatic authorization to fly in controlled airspace")
    
                                                visible:        _flightPermit !== AirspaceFlightPlanProvider.PermitNone
    
                                                font.pointSize: ScreenTools.smallFontPointSize
                                            }
    
                                            Rectangle {
                                                anchors.right:      parent.right
                                                anchors.left:       parent.left
                                                height:             label.height + (ScreenTools.defaultFontPixelHeight * 0.5)
                                                color: {
                                                    if(_flightPermit == AirspaceFlightPlanProvider.PermitPending)
                                                        return _colorOrange
                                                    if(_flightPermit == AirspaceFlightPlanProvider.PermitAccepted)
                                                        return _colorGreen
                                                    if(_flightPermit == AirspaceFlightPlanProvider.PermitRejected)
                                                        return _colorRed
                                                    return _colorGray
                                                }
                                                QGCLabel {
                                                    id:     label
                                                    color:  _colorWhite
                                                    text: {
                                                        if(_flightPermit === AirspaceFlightPlanProvider.PermitPending)
                                                            return qsTr("Authorization Pending")
                                                        if(_flightPermit === AirspaceFlightPlanProvider.PermitAccepted)
                                                            return qsTr("Authorization Accepted")
                                                        if(_flightPermit === AirspaceFlightPlanProvider.PermitRejected)
                                                            return qsTr("Authorization Rejected")
                                                        return qsTr("Authorization Unknown")
                                                    }
                                                    anchors.centerIn: parent
                                                }
                                            }
    
                                        }
                                    }
                                    Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
                                    QGCLabel {
                                        text:           qsTr("Rules & Compliance")
    
                                        visible:        hasBriefRules()
    
                                    ExclusiveGroup { id: ruleGroup }
    
                                    ComplianceRules {
                                        text:           qsTr("Rules you may be violating")
    
                                        rules:          violationRules
                                        visible:        violationRules && violationRules.count
                                        color:          _colorRed
                                        exclusiveGroup: ruleGroup
    
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
    
                                        property var violationRules: QGroundControl.airspaceManager.flightPlan.rulesViolation
    
                                    }
                                    ComplianceRules {
                                        text:           qsTr("Rules needing more information")
    
                                        rules:          infoRules
                                        color:          _colorOrange
                                        visible:        infoRules && infoRules.count
                                        exclusiveGroup: ruleGroup
    
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
    
                                        property var infoRules: QGroundControl.airspaceManager.flightPlan.rulesInfo
    
                                    }
                                    ComplianceRules {
                                        text:           qsTr("Rules you should review")
    
                                        rules:          reviewRules
                                        color:          _colorYellow
                                        visible:        reviewRules && reviewRules.count
                                        exclusiveGroup: ruleGroup
    
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
    
                                        property var reviewRules: QGroundControl.airspaceManager.flightPlan.rulesReview
    
                                    }
                                    ComplianceRules {
                                        text:           qsTr("Rules you are following")
    
                                        rules:          followRules
                                        color:          _colorGreen
                                        visible:        followRules && followRules.count
                                        exclusiveGroup: ruleGroup
    
                                        anchors.right:  parent.right
                                        anchors.left:   parent.left
    
                                        property var followRules: QGroundControl.airspaceManager.flightPlan.rulesFollowing
    
                                    }
                                }
                            }
                            //-------------------------------------------------------------
                            //-- File Flight Plan or Close
                            Item { width: 1; height: ScreenTools.defaultFontPixelHeight; }
                            Row {
                                id:         buttonRow
    
    Gus Grubba's avatar
    Gus Grubba committed
                                spacing: ScreenTools.defaultFontPixelWidth
    
                                anchors.horizontalCenter: parent.horizontalCenter
    
    Gus Grubba's avatar
    Gus Grubba committed
                                QGCButton {
                                    text:           qsTr("Update Plan")
                                    backRadius:     4
                                    heightFactor:   0.3333
                                    showBorder:     true
    
                                    enabled:        _flightPermit !== AirspaceFlightPlanProvider.PermitNone && _dirty
    
    Gus Grubba's avatar
    Gus Grubba committed
                                    width:          ScreenTools.defaultFontPixelWidth * 12
                                    onClicked: {
                                        //-- TODO: Update Plan
                                        mainWindow.enableToolbar()
                                        rootLoader.sourceComponent = null
                                    }
                                }
    
                                QGCButton {
                                    text:           qsTr("Submit Plan")
                                    backRadius:     4
                                    heightFactor:   0.3333
                                    showBorder:     true
                                    enabled:        _flightPermit !== AirspaceFlightPlanProvider.PermitNone
                                    width:          ScreenTools.defaultFontPixelWidth * 12
                                    onClicked: {
                                        //-- TODO: File Plan
                                        mainWindow.enableToolbar()
                                        rootLoader.sourceComponent = null
                                    }
                                }
                                QGCButton {
                                    text:           qsTr("Close")
                                    backRadius:     4
                                    heightFactor:   0.3333
                                    showBorder:     true
                                    width:          ScreenTools.defaultFontPixelWidth * 12
                                    onClicked: {
                                        mainWindow.enableToolbar()
                                        rootLoader.sourceComponent = null
                                    }
                                }
                            }
                        }
                    }
                }
                Calendar {
                    id: datePicker
                    anchors.centerIn: parent
                    visible: false;
                    minimumDate: {
                        return new Date()
                    }
                    onClicked: {
                        visible = false;
                    }
                }
            }
        }
    
    Gus Grubba's avatar
    Gus Grubba committed
    }