"Fossies" - the Fresh Open Source Software Archive

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

    1 import QtQuick 2.4
    2 import QtQml 2.4
    3 import FlightGear 1.0
    4 import "."
    5 
    6 Item {
    7     id: root
    8     // order of this model sets the order of buttons in the sidebar
    9     ListModel {
   10         id: startupPagesModel
   11         ListElement { title: qsTr("Summary"); pageSource: "qrc:///qml/Summary.qml"; iconPath: "qrc:///svg/toolbox-summary"; state:"loader" }
   12         ListElement { title: qsTr("Aircraft"); pageSource: "qrc:///qml/AircraftList.qml"; iconPath: "qrc:///svg/toolbox-aircraft"; state:"loader" }
   13         
   14         ListElement { 
   15             title: qsTr("Location"); pageSource: "qrc:///qml/Location.qml"; 
   16             iconPath: "qrc:///toolbox-location"; state:"loader"
   17             buttonDisabled: false
   18             disabledText: qsTr("Location page disabled due to conflicting user arguments (in Settings)");
   19         }
   20 
   21         // due to some design stupidity by James, we can't use the Loader mechanism for these pages; they need to exist
   22         // permanently so that collecting args works. So we instantiate them down below, and toggle the visiblity
   23         // of them and the loader using a state.
   24 
   25         ListElement { title: qsTr("Environment"); pageSource: ""; iconPath: "qrc:///svg/toolbox-environment"; state:"environment"  }
   26         ListElement { title: qsTr("Settings"); pageSource: ""; iconPath: "qrc:///svg/toolbox-settings"; state:"settings" }
   27 
   28         ListElement { title: qsTr("Add-ons"); pageSource: "qrc:///qml/AddOns.qml"; iconPath: "qrc:///svg/toolbox-addons"; state:"loader" }
   29         ListElement { title: qsTr("Help"); pageSource: "qrc:///qml/HelpSupport.qml"; iconPath: "qrc:///toolbox-help"; state:"loader" }
   30 
   31     }
   32 
   33     ListModel {
   34         id: inAppPagesModel
   35         ListElement { title: qsTr("Summary"); pageSource: "qrc:///qml/Summary.qml"; iconPath: "qrc:///svg/toolbox-summary"; state:"loader" }
   36         ListElement { title: qsTr("Aircraft"); pageSource: "qrc:///qml/AircraftList.qml"; iconPath: "qrc:///svg/toolbox-aircraft"; state:"loader" }
   37 
   38         ListElement {
   39             title: qsTr("Location"); pageSource: "qrc:///qml/Location.qml";
   40             iconPath: "qrc:///toolbox-location"; state:"loader"
   41         }
   42     }
   43 
   44 
   45     Component.onCompleted:
   46     {
   47        _launcher.minimumWindowSize = Qt.size(Style.strutSize * 12, sidebar.minimumHeight);
   48 
   49         if (_launcher.versionLaunchCount == 0) {
   50             popupOverlay.showOverlay(firstRun)
   51         }
   52     }
   53 
   54     Component {
   55         id: firstRun
   56         FirstRun {
   57             width: root.width
   58             height: root.height
   59         }
   60     }
   61 
   62     Connections {
   63         target: _location
   64         onSkipFromArgsChanged: startupPagesModel.setProperty(2, "buttonDisabled", _location.skipFromArgs)
   65     }
   66 
   67     Connections {
   68         target: _launcher
   69         onSkipAircraftFromArgsChanged: startupPagesModel.setProperty(1, "buttonDisabled", _launcher.skipAircraftFromArgs)
   70     }
   71 
   72     state: "loader"
   73     states: [
   74         State {
   75             name: "loader"
   76             PropertyChanges { target: pageLoader; visible: true }
   77             PropertyChanges { target: settings; visible: false }
   78             PropertyChanges { target: environment; visible: false }
   79         },
   80 
   81         State {
   82             name: "settings"
   83             PropertyChanges { target: pageLoader; visible: false }
   84             PropertyChanges { target: settings; visible: true }
   85             PropertyChanges { target: environment; visible: false }
   86         },
   87 
   88         State {
   89             name: "environment"
   90             PropertyChanges { target: pageLoader; visible: false }
   91             PropertyChanges { target: settings; visible: false }
   92             PropertyChanges { target: environment; visible: true }
   93         }
   94     ]
   95 
   96     Connections {
   97         target: _launcher
   98         onViewCommandLine: {
   99             sidebar.selectedPage = -1;
  100             pageLoader.source = "qrc:///qml/ViewCommandLine.qml"
  101             root.state = "loader";
  102         }
  103     }
  104 
  105     function enterFlightPlan()
  106     {
  107         sidebar.selectedPage = -1;
  108         pageLoader.source = "qrc:///qml/FlightPlan.qml"
  109         root.state = "loader";
  110     }
  111 
  112     Sidebar {
  113         id: sidebar
  114         height: parent.height
  115         z: 1
  116         pagesModel: _launcher.inAppMode ? inAppPagesModel : startupPagesModel
  117         selectedPage: 0 // open on the summary page
  118 
  119         onShowMenu: menu.show();
  120 
  121         onSelectPage: {
  122             pageLoader.source = pageSource
  123             root.state = pagesModel.get(selectedPage).state
  124         }
  125     }
  126 
  127     Settings {
  128         id: settings
  129 
  130         height: parent.height
  131         anchors {
  132             left: sidebar.right
  133             right: parent.right
  134         }
  135     }
  136 
  137     Environment {
  138         id: environment
  139 
  140         height: parent.height
  141         anchors {
  142             left: sidebar.right
  143             right: parent.right
  144         }
  145     }
  146 
  147     Loader {
  148         id: pageLoader
  149         height: parent.height
  150         anchors {
  151             left: sidebar.right
  152             right: parent.right
  153         }
  154 
  155         source: "qrc:///qml/Summary.qml"
  156     }
  157 
  158     NotificationArea {
  159         id: notifications
  160         // only show on the summary page
  161         visible: sidebar.selectedPage === 0
  162 
  163         anchors {
  164             right: parent.right
  165             top: parent.top
  166             bottom: parent.bottom
  167         }
  168     }
  169 
  170     function selectPage(index)
  171     {
  172         sidebar.setSelectedPage(index);
  173         var page = sidebar.pagesModel.get(index);
  174         pageLoader.source = page.pageSource
  175         root.state = page.state
  176     }
  177 
  178     Connections {
  179         target: pageLoader.item
  180         ignoreUnknownSignals: true
  181         onShowSelectedAircraft: root.selectPage(1)
  182         onShowSelectedLocation: root.selectPage(2)
  183         onShowFlightPlan: root.enterFlightPlan()
  184     }
  185 
  186     Menu {
  187         id: menu
  188         z: 100
  189 
  190         items: [
  191             MenuItem { text:qsTr("Fly!"); shortcut: "Ctrl+F";
  192                 onTriggered: _launcher.fly(); },
  193             MenuItem { text:qsTr("Open saved configuration..."); shortcut: "Ctrl+O";
  194                 onTriggered: _launcher.openConfig(); },
  195             MenuItem { text:qsTr("Save configuration as..."); shortcut: "Ctrl+S";
  196                 onTriggered: _launcher.saveConfigAs(); },
  197             MenuDivider {},
  198             MenuItem { text:qsTr("Flight-planning"); onTriggered: root.enterFlightPlan(); shortcut: "Ctrl+P"; enabled: true},
  199             MenuDivider {},
  200             MenuItem { text:qsTr("View command line"); onTriggered: _launcher.viewCommandLine(); shortcut: "Ctrl+L"},
  201             MenuItem { text:qsTr("Select data files location..."); onTriggered: _launcher.requestChangeDataPath(); },
  202             MenuItem { text:qsTr("Restore default settings..."); onTriggered: _launcher.requestRestoreDefaults(); },
  203             MenuDivider {},
  204             MenuItem { text:qsTr("Quit"); shortcut: "Ctrl+Q"; onTriggered: _launcher.quit();  } 
  205         ]
  206     }
  207 
  208     Overlay {
  209         id: popupOverlay
  210         anchors.fill: parent
  211         z: 200
  212 
  213         Component.onCompleted: {
  214             OverlayShared.globalOverlay = this
  215         }
  216     }
  217 }