"Fossies" - the Fresh Open Source Software Archive

Member "flightgear-2020.3.8/src/GUI/qml/Summary.qml" (24 Mar 2021, 13679 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 "Summary.qml": 2020.3.7_vs_2020.3.8.

    1 import QtQuick 2.4
    2 import QtQml 2.4
    3 import FlightGear.Launcher 1.0
    4 import FlightGear 1.0
    5 
    6 import "."
    7 
    8 Item {
    9     id: root
   10 
   11     signal showSelectedAircraft();
   12     signal showSelectedLocation();
   13     signal showFlightPlan();
   14 
   15     GettingStartedScope.controller: tips.controller
   16 
   17     Rectangle {
   18         anchors.fill: parent
   19         color: "#7f7f7f"
   20     }
   21 
   22     readonly property string __aircraftDescription: _launcher.selectedAircraftInfo.description
   23 
   24     PreviewImage {
   25         id: preview
   26         anchors.centerIn: parent
   27 
   28         // over-zoom the preview to fill the entire space available
   29         readonly property double scale: Math.max(root.width / sourceSize.width,
   30                                                          root.height / sourceSize.height)
   31 
   32         width: height * aspectRatio
   33         height: scale * sourceSize.height
   34 
   35         property var urlsList: _launcher.defaultSplashUrls()
   36         property int __currentUrl: 0
   37 
   38         Binding on urlsList {
   39             when: _launcher.selectedAircraftInfo.previews.length > 0
   40             value: _launcher.selectedAircraftInfo.previews
   41         }
   42 
   43         onUrlsListChanged: {
   44             var len = preview.urlsList.length;
   45             __currentUrl = Math.floor(Math.random() * len)
   46         }
   47 
   48         Timer {
   49             running: true
   50             interval: 8000
   51             repeat: true
   52             onTriggered: {
   53                 var len = preview.urlsList.length
   54                 preview.__currentUrl = (preview.__currentUrl + 1) % len
   55             }
   56         }
   57 
   58         function currentUrl()
   59         {
   60             if (urlsList.length <= __currentUrl) return "";
   61             return urlsList[__currentUrl];
   62         }
   63 
   64         visible: imageUrl != ""
   65         imageUrl: currentUrl()
   66     }
   67 
   68     Text {
   69         id: logoText
   70         font.pointSize: Style.strutSize * 2
   71         font.italic: true
   72         font.bold: true
   73         anchors {
   74             left: parent.left
   75             right: parent.right
   76             top: parent.top
   77             margins: Style.strutSize
   78         }
   79         fontSizeMode: Text.Fit
   80         text: "FlightGear " + _launcher.versionString
   81         color: "white"
   82         style: Text.Outline
   83         styleColor: "black"
   84     }
   85 
   86     ClickableText {
   87         anchors {
   88             left: logoText.left
   89             right: logoText.right
   90         }
   91 
   92         // anchoring to logoText bottom doesn't work as expected because of
   93         // dynamic text sizing, so bind it manually
   94         y: logoText.y + Style.margin + logoText.contentHeight
   95         wrapMode: Text.WordWrap
   96         text: qsTr("Licenced under the GNU Public License (GPL) - click for more info")
   97         baseTextColor: "white"
   98         style: Text.Outline
   99         styleColor: "black"
  100         font.bold: true
  101         font.pixelSize: Style.subHeadingFontPixelSize
  102 
  103         onClicked: {
  104             _launcher.launchUrl("http://home.flightgear.org/about/");
  105         }
  106     }
  107 
  108 
  109     Rectangle {
  110         id: summaryPanel
  111 
  112         color: "transparent"
  113         border.width: 1
  114         border.color: Style.frameColor
  115         clip: true
  116 
  117         anchors {
  118             left: parent.left
  119             right: parent.right
  120             bottom: parent.bottom
  121             margins: Style.strutSize
  122         }
  123 
  124         height: summaryGrid.height + Style.margin * 2
  125 
  126         // set opacity here only, so we don't make the whole summary pannel translucent
  127         Rectangle {
  128             id: background
  129             anchors.fill: parent
  130             z: -1
  131             opacity: Style.panelOpacity
  132             color: "white"
  133         }
  134 
  135         Grid {
  136             id: summaryGrid
  137             columns: 3
  138             columnSpacing: Style.margin
  139             rowSpacing: Style.margin
  140 
  141             readonly property int middleColumnWidth: summaryGrid.width - (locationLabel.width + Style.margin * 2 + aircraftHistoryPopup.width)
  142 
  143             anchors {
  144                 left: parent.left
  145                 right: parent.right
  146                 top: parent.top
  147                 margins: Style.margin
  148             }
  149 
  150             // aircraft name row
  151             StyledText {
  152                 text: qsTr("Aircraft:")
  153                 horizontalAlignment: Text.AlignRight
  154                 font.pixelSize: Style.headingFontPixelSize
  155             }
  156 
  157             ClickableText {
  158                 text: {
  159                     if (_launcher.skipAircraftFromArgs) return qsTr("<i>set from user arguments (in Settings)</i>");
  160                     if (_launcher.selectedAircraftInfo.name === "") return  qsTr("No aircraft selected"); 
  161                     return _launcher.selectedAircraftInfo.name;
  162                     }
  163                 enabled: _launcher.selectedAircraftInfo.name !== "" && !_launcher.skipAircraftFromArgs
  164                 font.pixelSize: Style.headingFontPixelSize
  165 
  166                 onClicked: root.showSelectedAircraft();
  167             }
  168 
  169             HistoryPopup {
  170                 id: aircraftHistoryPopup
  171                 model: _launcher.aircraftHistory
  172                 enabled: !_launcher.aircraftHistory.isEmpty && !_launcher.skipAircraftFromArgs
  173                 onSelected: {
  174                     _launcher.selectedAircraft = _launcher.aircraftHistory.uriAt(index)
  175                 }
  176 
  177                 GettingStartedTip {
  178                     tipId: "aircraftHistoryTip"
  179                     nextTip: "locationHistoryTip"
  180                     arrow: GettingStartedTip.BottomRight
  181 
  182                     anchors {
  183                         horizontalCenter: parent.horizontalCenter
  184                         bottom: parent.top
  185                     }
  186                     text: qsTr("Access recently used aircraft.")
  187                 }
  188             }
  189 
  190             // empty space in next row (thumbnail, long aircraft description)
  191             Item {
  192                 width: 1; height: 1
  193                 visible: aircraftDetailsRow.visible
  194             }
  195 
  196             Item {
  197                 id: aircraftDetailsRow
  198                 width: summaryGrid.middleColumnWidth
  199                 height: Math.max(thumbnail.height, aircraftDescriptionText.height)
  200                 visible: !_launcher.skipAircraftFromArgs
  201 
  202                 ThumbnailImage {
  203                     id: thumbnail
  204                     aircraftUri: _launcher.selectedAircraft
  205                     maximumSize.width: 172
  206                     maximumSize.height: 128
  207                 }
  208 
  209                 StyledText {
  210                     id: aircraftDescriptionText
  211                     anchors {
  212                         left: thumbnail.right
  213                         leftMargin: Style.margin
  214                         right: parent.right
  215                     }
  216 
  217                     text: root.__aircraftDescription
  218                     visible: root.__aircraftDescription != ""
  219                     wrapMode: Text.WordWrap
  220                     maximumLineCount: 5
  221                     elide: Text.ElideRight
  222                 }
  223             }
  224 
  225             Item {
  226                 width: 1; height: 1
  227                 visible: aircraftDetailsRow.visible
  228             }
  229 
  230             // aircraft state row, if enabled
  231             Item {
  232                width: 1; height: 1
  233                visible: stateSelectionGroup.visible
  234            }
  235 
  236             Column {
  237                 id: stateSelectionGroup
  238                 visible: _launcher.selectedAircraftInfo.hasStates && !_launcher.skipAircraftFromArgs
  239                 width: summaryGrid.middleColumnWidth
  240                 spacing: Style.margin
  241 
  242                 Component.onCompleted: updateComboFromController();
  243 
  244                 function updateComboFromController()
  245                 {
  246                     stateSelectionCombo.currentIndex = _launcher.selectedAircraftInfo.statesModel.indexForTag(_launcher.selectedAircraftState)
  247                 }
  248 
  249                 PopupChoice {
  250                     id: stateSelectionCombo
  251                     model: _launcher.selectedAircraftInfo.statesModel
  252                     displayRole: "name"
  253                     label: qsTr("State:")
  254                     width: parent.width   
  255                     headerText: qsTr("Default state")
  256 
  257                     function select(index)
  258                     {
  259                         if (index === -1) {
  260                             _launcher.selectedAircraftState = "";
  261                         } else {
  262                             _launcher.selectedAircraftState = model.tagForState(index);
  263                         }
  264                     }
  265 
  266                     GettingStartedTip {
  267                         id: aircraftStateTip
  268                         tipId: "aircraftStateTip"
  269                         arrow: GettingStartedTip.LeftCenter
  270                         enabled: stateSelectionGroup.visible
  271                         standalone: true
  272 
  273                         // show as a one-shot tip, first time we're enabled
  274                         onEnabledChanged: {
  275                             if (enabled) {
  276                                 tips.showOneShot(this)
  277                             }
  278                         }
  279 
  280                         x: parent.implicitWidth
  281                         anchors {
  282                             verticalCenter: parent.verticalCenter
  283                         }
  284                         text: qsTr("Choose the starting condition of the aircraft")
  285                     }
  286                 }
  287 
  288                 StyledText {
  289                     id: stateDescriptionText
  290                     wrapMode: Text.WordWrap
  291                     maximumLineCount: 5
  292                     elide: Text.ElideRight
  293                     width: parent.width
  294                     text: _launcher.selectedAircraftInfo.statesModel.descriptionForState(stateSelectionCombo.currentIndex)
  295                 }
  296 
  297                 Connections {
  298                     target: _launcher.selectedAircraftInfo
  299                     onInfoChanged: stateSelectionGroup.updateComboFromController()
  300                 }
  301 
  302                 Connections {
  303                     target: _launcher
  304                     onSelectedAircraftStateChanged: stateSelectionGroup.updateComboFromController()
  305                 } // of connections
  306             }
  307 
  308             Item {
  309                 width: 1; height: 1
  310                 visible: stateSelectionGroup.visible
  311             }
  312 
  313             // location summary row
  314             StyledText {
  315                 id: locationLabel
  316                 text: qsTr("Location:")
  317                 horizontalAlignment: Text.AlignRight
  318                 font.pixelSize: Style.headingFontPixelSize
  319             }
  320 
  321             ClickableText {
  322                 enabled: !_location.skipFromArgs
  323                 text: _location.skipFromArgs ? qsTr("<i>set from user arguments (in Settings)</i>")
  324                                              : _launcher.location.description
  325                 font.pixelSize: Style.headingFontPixelSize
  326                 width: summaryGrid.middleColumnWidth
  327                 onClicked: root.showSelectedLocation()
  328 
  329                 GettingStartedTip {
  330                     tipId: "currentLocationTextTip"
  331                     anchors {
  332                         top: parent.bottom
  333                         left: parent.left
  334                         leftMargin: Style.strutSize
  335                     }
  336                     arrow: GettingStartedTip.TopLeft
  337                     text: qsTr("Click to view and change the current location.")
  338                 }
  339             }
  340 
  341             HistoryPopup {
  342                 id: locationHistoryPopup
  343                 model: _launcher.locationHistory
  344                 enabled: !_launcher.aircraftHistory.isEmpty && !_location.skipFromArgs
  345                 onSelected: {
  346                     _launcher.restoreLocation(_launcher.locationHistory.locationAt(index))
  347                 }
  348 
  349                 GettingStartedTip {
  350                     tipId: "locationHistoryTip"
  351                     anchors {
  352                         horizontalCenter: parent.horizontalCenter
  353                         bottom: parent.top
  354                     }
  355                     arrow: GettingStartedTip.BottomRight
  356                     text: qsTr("Access recently used locations")
  357                 }
  358             }
  359 
  360             // flight plan summary row
  361             StyledText {
  362                 id: flightPlanLabel
  363                 text: qsTr("Flight Plan:")
  364                 horizontalAlignment: Text.AlignRight
  365                 font.pixelSize: Style.headingFontPixelSize
  366                 visible: _launcher.flightPlan.enabled
  367             }
  368 
  369             ClickableText {
  370                 text: _launcher.flightPlan.description
  371                 font.pixelSize: Style.headingFontPixelSize
  372                 width: summaryGrid.middleColumnWidth
  373                 onClicked: root.showFlightPlan()
  374                 visible: _launcher.flightPlan.enabled
  375             }
  376 
  377             Item { // padding item for flight plan row
  378                 width: 1; height: 1
  379                 visible: _launcher.flightPlan.enabled
  380             }
  381 
  382             // settings summary row
  383             StyledText {
  384                 text: qsTr("Settings:")
  385                 horizontalAlignment: Text.AlignRight
  386                 font.pixelSize: Style.headingFontPixelSize
  387                 visible: !_launcher.inAppMode
  388             }
  389 
  390             StyledText {
  391                 text: _launcher.combinedSummary.join(", ")
  392                 font.pixelSize: Style.headingFontPixelSize
  393                 wrapMode: Text.WordWrap
  394                 maximumLineCount: 2
  395                 elide: Text.ElideRight
  396                 width: summaryGrid.middleColumnWidth
  397                 visible: !_launcher.inAppMode
  398             }
  399 
  400             Item {
  401                 width: 1; height: 1
  402             }
  403         }
  404     } // of summary box
  405 
  406     GettingStartedTipLayer {
  407         id: tips
  408         anchors.fill: parent
  409         scopeId: "summary"
  410     }
  411 }