| 1 |
// SPDX-FileCopyrightText: 2018 James Turner |
| 2 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 3 |
|
| 4 |
import QtQuick 2.4 |
| 5 |
import FlightGear 1.0 |
| 6 |
import FlightGear.Launcher 1.0 |
| 7 |
|
| 8 |
Item { |
| 9 |
id: root |
| 10 |
property alias location: airportData.guid |
| 11 |
|
| 12 |
Positioned { |
| 13 |
id: airportData |
| 14 |
onGuidChanged: _location.setBaseLocation(this) |
| 15 |
} |
| 16 |
|
| 17 |
GettingStartedScope.controller: tips.controller |
| 18 |
|
| 19 |
readonly property bool isHeliport: airportData.type === Positioned.Heliport |
| 20 |
readonly property bool haveParking: airportData.airportHasParkings |
| 21 |
|
| 22 |
AirportDiagram { |
| 23 |
id: diagram |
| 24 |
anchors.fill: parent |
| 25 |
airport: airportData.guid |
| 26 |
|
| 27 |
onClicked: function(pos) { |
| 28 |
if (pos === null) |
| 29 |
return; |
| 30 |
|
| 31 |
// only allow selection of helipads if the aircraft type in |
| 32 |
// use is a helicopter. |
| 33 |
if ((pos.type == Positioned.Helipad) && (_launcher.aircraftType != LauncherController.Helicopter)) { |
| 34 |
return; |
| 35 |
} |
| 36 |
|
| 37 |
_location.setDetailLocation(pos) |
| 38 |
diagram.selection = pos |
| 39 |
syncUIFromController(); |
| 40 |
} |
| 41 |
|
| 42 |
approachExtensionEnabled: _location.onFinal |
| 43 |
approachExtension: _location.offsetDistance |
| 44 |
|
| 45 |
GettingStartedTip { |
| 46 |
tipId: "locationDiagram" |
| 47 |
anchors.centerIn: parent |
| 48 |
arrow: GettingStartedTip.NoArrow |
| 49 |
text: qsTr("Click here to select a runway or parking position, and drag to pan. Mouse-wheel zooms in and out.") |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
// not very declarative, try to remove this over time |
| 54 |
function syncUIFromController() |
| 55 |
{ |
| 56 |
if (_location.useAvailableParking || (_location.detail.type === Positioned.Parking)) { |
| 57 |
parkingRadio.select() |
| 58 |
parkingChoice.syncCurrentIndex(); |
| 59 |
} else if (_location.detail.type === Positioned.Helipad) { |
| 60 |
helipadRadio.select(); |
| 61 |
helipadChoice.syncCurrentIndex(); |
| 62 |
} else { |
| 63 |
runwayRadio.select(); |
| 64 |
runwayChoice.syncCurrentIndex(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
RadioButtonGroup { |
| 69 |
id: radioGroup |
| 70 |
} |
| 71 |
|
| 72 |
Component.onCompleted: { |
| 73 |
syncUIFromController(); |
| 74 |
} |
| 75 |
|
| 76 |
Rectangle { |
| 77 |
id: panel |
| 78 |
|
| 79 |
color: "transparent" |
| 80 |
border.width: 1 |
| 81 |
border.color: Style.frameColor |
| 82 |
clip: true |
| 83 |
|
| 84 |
anchors { |
| 85 |
left: parent.left |
| 86 |
right: parent.right |
| 87 |
bottom: parent.bottom |
| 88 |
margins: Style.strutSize |
| 89 |
} |
| 90 |
|
| 91 |
height: selectionGrid.height + Style.margin * 2 |
| 92 |
|
| 93 |
// set opacity here only, so we don't make the whole summary panel translucent |
| 94 |
Rectangle { |
| 95 |
id: background |
| 96 |
anchors.fill: parent |
| 97 |
z: -1 |
| 98 |
opacity: Style.panelOpacity |
| 99 |
color: Style.panelBackground |
| 100 |
} |
| 101 |
|
| 102 |
Column { |
| 103 |
id: selectionGrid |
| 104 |
spacing: Style.margin |
| 105 |
width: parent.width |
| 106 |
|
| 107 |
StyledText { // heading text |
| 108 |
id: airportHeading |
| 109 |
anchors { |
| 110 |
left: parent.left |
| 111 |
right: parent.right |
| 112 |
margins: Style.margin |
| 113 |
} |
| 114 |
|
| 115 |
font.pixelSize: Style.headingFontPixelSize |
| 116 |
text: isHeliport ? qsTr("Heliport: ") + airportData.ident + " / " + airportData.name |
| 117 |
: qsTr("Airport: ") + airportData.ident + " / " + airportData.name |
| 118 |
} |
| 119 |
|
| 120 |
Row { |
| 121 |
width: parent.width |
| 122 |
spacing: Style.margin |
| 123 |
visible: !root.isHeliport |
| 124 |
|
| 125 |
RadioButton { |
| 126 |
id: runwayRadio |
| 127 |
anchors.verticalCenter: parent.verticalCenter |
| 128 |
group: radioGroup |
| 129 |
|
| 130 |
onClicked: { |
| 131 |
if (selected) runwayChoice.setLocation(); |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
StyledText { |
| 136 |
text: qsTr("Runway") |
| 137 |
anchors.verticalCenter: parent.verticalCenter |
| 138 |
} |
| 139 |
|
| 140 |
PopupChoice { |
| 141 |
id: runwayChoice |
| 142 |
model: _location.airportRunways |
| 143 |
width: parent.width * 0.5 |
| 144 |
anchors.verticalCenter: parent.verticalCenter |
| 145 |
headerText: qsTr("Active") |
| 146 |
enabled: runwayRadio.selected |
| 147 |
|
| 148 |
onCurrentIndexChanged: { |
| 149 |
setLocation(); |
| 150 |
} |
| 151 |
|
| 152 |
function setLocation() |
| 153 |
{ |
| 154 |
if (currentIndex == -1) { |
| 155 |
_location.useActiveRunway = true; |
| 156 |
diagram.selection = null; |
| 157 |
} else { |
| 158 |
var rwy = _location.airportRunways.itemAt(currentIndex); |
| 159 |
_location.setDetailLocation(rwy); |
| 160 |
diagram.selection = rwy; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
function syncCurrentIndex() |
| 165 |
{ |
| 166 |
if (_location.useActiveRunway) { |
| 167 |
currentIndex = -1; |
| 168 |
return; |
| 169 |
} |
| 170 |
|
| 171 |
currentIndex = _location.airportRunways.indexOf(_location.detail); |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
// runway offset |
| 177 |
ToggleBox { |
| 178 |
id: onFinalBox |
| 179 |
|
| 180 |
visible: !root.isHeliport |
| 181 |
anchors.left: parent.left |
| 182 |
anchors.leftMargin: Style.strutSize |
| 183 |
height: onFinalContents.height + onFinalContents.y + Style.margin |
| 184 |
anchors.right: parent.right |
| 185 |
anchors.rightMargin: Style.margin |
| 186 |
|
| 187 |
enabled: runwayRadio.selected |
| 188 |
selected: _location.onFinal |
| 189 |
|
| 190 |
label: qsTr("On final approach") |
| 191 |
|
| 192 |
onSelectedChanged: _location.onFinal = selected |
| 193 |
readonly property bool enableOnFinal: enabled && selected |
| 194 |
|
| 195 |
Column { |
| 196 |
id: onFinalContents |
| 197 |
y: parent.contentVerticalOffset |
| 198 |
spacing: Style.margin |
| 199 |
width: parent.width |
| 200 |
|
| 201 |
Row { |
| 202 |
height: offsetNmEdit.height |
| 203 |
NumericalEdit { |
| 204 |
id: offsetNmEdit |
| 205 |
quantity: _location.offsetDistance |
| 206 |
onCommit: _location.offsetDistance = newValue; |
| 207 |
label: qsTr("At") |
| 208 |
unitsMode: Units.Distance |
| 209 |
live: true |
| 210 |
anchors.verticalCenter: parent.verticalCenter |
| 211 |
enabled: onFinalBox.enableOnFinal |
| 212 |
} |
| 213 |
|
| 214 |
StyledText { |
| 215 |
text: qsTr(" from the threshold") |
| 216 |
anchors.verticalCenter: parent.verticalCenter |
| 217 |
enabled: onFinalBox.enableOnFinal |
| 218 |
} |
| 219 |
|
| 220 |
Item { |
| 221 |
height: 1; width: Style.strutSize |
| 222 |
} |
| 223 |
|
| 224 |
ToggleSwitch { |
| 225 |
id: airspeedToggle |
| 226 |
enabled: onFinalBox.enableOnFinal |
| 227 |
checked: _location.speedEnabled |
| 228 |
onCheckedChanged: _location.speedEnabled = checked; |
| 229 |
anchors.verticalCenter: parent.verticalCenter |
| 230 |
} |
| 231 |
|
| 232 |
NumericalEdit { |
| 233 |
id: airspeedSpinbox |
| 234 |
label: qsTr("Airspeed:") |
| 235 |
unitsMode: Units.SpeedWithoutMach |
| 236 |
enabled: _location.speedEnabled && onFinalBox.enableOnFinal |
| 237 |
quantity: _location.airspeed |
| 238 |
onCommit: _location.airspeed = newValue |
| 239 |
anchors.verticalCenter: parent.verticalCenter |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
LocationAltitudeRow |
| 244 |
{ |
| 245 |
enabled: onFinalBox.enableOnFinal |
| 246 |
width: parent.width |
| 247 |
} |
| 248 |
} // of column |
| 249 |
} // of runway offset group |
| 250 |
|
| 251 |
|
| 252 |
ToggleSwitch { |
| 253 |
x: Style.strutSize |
| 254 |
enabled:runwayRadio.selected |
| 255 |
visible: !root.isHeliport |
| 256 |
// enable if selected runway has ILS |
| 257 |
label: qsTr("Tune navigation radio (NAV1) to runway localizer") |
| 258 |
checked: _location.tuneNAV1 |
| 259 |
|
| 260 |
onCheckedChanged: { |
| 261 |
_location.tuneNAV1 = checked |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
// helipads row |
| 266 |
Row { |
| 267 |
width: parent.width |
| 268 |
spacing: Style.margin |
| 269 |
visible: (_launcher.aircraftType === LauncherController.Helicopter) && (! _location.airportHelipads.empty) |
| 270 |
|
| 271 |
RadioButton { |
| 272 |
id: helipadRadio |
| 273 |
anchors.verticalCenter: parent.verticalCenter |
| 274 |
group: radioGroup |
| 275 |
|
| 276 |
onClicked: { |
| 277 |
if (selected) helipadChoice.setLocation(); |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
StyledText { |
| 282 |
text: qsTr("Pad") |
| 283 |
anchors.verticalCenter: parent.verticalCenter |
| 284 |
} |
| 285 |
|
| 286 |
PopupChoice { |
| 287 |
id: helipadChoice |
| 288 |
model: _location.airportHelipads |
| 289 |
width: parent.width * 0.5 |
| 290 |
anchors.verticalCenter: parent.verticalCenter |
| 291 |
enabled: helipadRadio.selected |
| 292 |
|
| 293 |
onCurrentIndexChanged: { |
| 294 |
setLocation(); |
| 295 |
} |
| 296 |
|
| 297 |
function setLocation() |
| 298 |
{ |
| 299 |
var pad = _location.airportHelipads.itemAt(currentIndex); |
| 300 |
_location.setDetailLocation(pad); |
| 301 |
diagram.selection = pad; |
| 302 |
} |
| 303 |
|
| 304 |
function syncCurrentIndex() |
| 305 |
{ |
| 306 |
currentIndex = _location.airportHelipads.indexOf(_location.detail); |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
// parking row |
| 312 |
Row { |
| 313 |
width: parent.width |
| 314 |
spacing: Style.margin |
| 315 |
|
| 316 |
// hide if there's no parking locations defined for this airport |
| 317 |
visible: haveParking |
| 318 |
|
| 319 |
RadioButton { |
| 320 |
id: parkingRadio |
| 321 |
anchors.verticalCenter: parent.verticalCenter |
| 322 |
group: radioGroup |
| 323 |
|
| 324 |
onClicked: { |
| 325 |
if (selected) parkingChoice.setLocation(); |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
StyledText { |
| 330 |
text: qsTr("Parking") |
| 331 |
anchors.verticalCenter: parent.verticalCenter |
| 332 |
} |
| 333 |
|
| 334 |
PopupChoice { |
| 335 |
id: parkingChoice |
| 336 |
model: _location.airportParkings |
| 337 |
width: parent.width * 0.5 |
| 338 |
anchors.verticalCenter: parent.verticalCenter |
| 339 |
headerText: qsTr("Available") |
| 340 |
enabled: parkingRadio.selected |
| 341 |
|
| 342 |
onCurrentIndexChanged: { |
| 343 |
setLocation(); |
| 344 |
} |
| 345 |
|
| 346 |
function syncCurrentIndex() |
| 347 |
{ |
| 348 |
if (_location.useAvailableParking) { |
| 349 |
currentIndex = -1; |
| 350 |
return; |
| 351 |
} |
| 352 |
|
| 353 |
currentIndex = _location.airportParkings.indexOf(_location.detail); |
| 354 |
} |
| 355 |
|
| 356 |
function setLocation() |
| 357 |
{ |
| 358 |
if (currentIndex == -1) { |
| 359 |
_location.useAvailableParking = true; |
| 360 |
diagram.selection = null; |
| 361 |
} else { |
| 362 |
var park = _location.airportParkings.itemAt(currentIndex); |
| 363 |
_location.setDetailLocation(park); |
| 364 |
diagram.selection = park; |
| 365 |
} |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
} // main layout column |
| 372 |
} // main panel rectangle |
| 373 |
|
| 374 |
GettingStartedTipLayer { |
| 375 |
id: tips |
| 376 |
anchors.fill: parent |
| 377 |
scopeId: "locationAirportDetails" |
| 378 |
} |
| 379 |
} |