Newer
Older
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 QGroundControl.Airmap 1.0
import QGroundControl.Airspace 1.0
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
height: _colapsed ? colapsedRect.height : expandedRect.height
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
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"
readonly property color _colorMidBrown: "#3a322f"
readonly property color _colorYellow: "#d7c61d"
readonly property color _colorWhite: "#ffffff"
readonly property color _colorRed: "#aa1200"
readonly property color _colorGreen: "#125f00"
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
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;
}
on_AirspaceColorChanged: {
if(_validAdvisories) {
if(QGroundControl.airspaceManager.advisories.airspaceColor === AirspaceAdvisoryProvider.Yellow) {
_textColor = "#000000"
return
}
}
_textColor = _colorWhite
}
//---------------------------------------------------------------
//-- Colapsed State
Rectangle {
id: colapsedRect
width: parent.width
height: _colapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
color: _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
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
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
text: qsTr("Airspace")
color: _textColor
Item {
width: ScreenTools.defaultFontPixelWidth
height: 1
}
AirspaceWeather {
iconHeight: ScreenTools.defaultFontPixelHeight * 2
visible: QGroundControl.airspaceManager.weatherInfo.valid
contentColor: _textColor
QGCColoredImage {
width: height
height: ScreenTools.defaultFontPixelWidth * 2.5
sourceSize.height: height
source: "qrc:/airmap/expand.svg"
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
}
QGroundControl.airspaceManager.airspaceVisible = true
}
}
//---------------------------------------------------------------
//-- Expanded State
Rectangle {
id: expandedRect
width: parent.width
height: !_colapsed ? expandedCol.height + ScreenTools.defaultFontPixelHeight : 0
color: _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
MouseArea {
anchors.fill: parent
onWheel: { wheel.accepted = true; }
onPressed: { mouse.accepted = true; }
onReleased: { mouse.accepted = true; }
}
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"
anchors.verticalCenter: parent.verticalCenter
}
Column {
spacing: 0
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: qsTr("Airspace")
text: _validAdvisories ? QGroundControl.airspaceManager.advisories.airspaces.count + qsTr(" Advisories") : ""
color: _textColor
visible: _validAdvisories
Item {
width: ScreenTools.defaultFontPixelWidth
height: 1
}
AirspaceWeather {
visible: QGroundControl.airspaceManager.weatherInfo.valid && showColapse
QGCColoredImage {
width: height
height: ScreenTools.defaultFontPixelWidth * 2.5
sourceSize.height: height
source: "qrc:/airmap/colapse.svg"
visible: showColapse
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
enabled: showColapse
onClicked: QGroundControl.airspaceManager.airspaceVisible = false
visible: QGroundControl.airspaceManager.weatherInfo.valid && !showColapse
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
}
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
}
//-- 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.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
QGCLabel {
text: qsTr("Airspace Regulations")
color: _colorWhite
anchors.horizontalCenter: parent.horizontalCenter
}
QGCLabel {
text: qsTr("Airspace advisories based on the selected rules.")
color: _colorWhite
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
font.pointSize: ScreenTools.smallFontPointSize
}
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 {
width: height
height: parent.height * 0.5
sourceSize.height: height
source: "qrc:/airmap/pencil.svg"
color: _colorWhite
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: {
rootLoader.sourceComponent = ruleSelector
mainWindow.disableToolbar()
}
}
Gus Grubba
committed
height: ScreenTools.defaultFontPixelHeight * 1.5
radius: 2
color: _colorMidBrown
Layout.fillWidth: true
QGCLabel {
Gus Grubba
committed
id: regLabel
text: _validRules ? QGroundControl.airspaceManager.ruleSets.selectedRuleSets : qsTr("None")
Gus Grubba
committed
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
Flickable {
clip: true
height: ScreenTools.defaultFontPixelHeight * 8
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.airspaces : []
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
}
}
}
}
}
}
//-- Footer
QGCLabel {
text: qsTr("Powered by <b>AIRMAP</b>")
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
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
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
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
Item {
width: 1
height: 1
}
Gus Grubba
committed
ExclusiveGroup { id: rulesGroup }
font.pointSize: ScreenTools.smallFontPointSize
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : []
visible: object.selectionType === AirspaceRuleSet.Pickone
Gus Grubba
committed
exclusiveGroup: rulesGroup
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
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 : []
visible: object.selectionType === AirspaceRuleSet.Optional
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 : []
visible: object.selectionType === AirspaceRuleSet.Required
required: true
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
}
}
}
}
}
}
//-- 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
Gus Grubba
committed
visible: ruleSelectorRect.visible && qgcPal.globalTheme === QGCPalette.Dark
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()
var target = mainWindow.mapFromItem(pencilIcon, 0, 0)
ruleSelectorRect.x = target.x - ruleSelectorRect.width - (ScreenTools.defaultFontPixelWidth * 7)
ruleSelectorRect.y = target.y - (ScreenTools.defaultFontPixelHeight * 4)