"Fossies" - the Fresh Open Source Software Archive

Member "flightgear-2020.3.8/src/GUI/qml/LocationAirportView.qml" (24 Mar 2021, 13710 Bytes) of package /linux/privat/flightgear-2020.3.8.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) QML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "LocationAirportView.qml": 2020.3.7_vs_2020.3.8.

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