1
0
Fork 0
flightgear/src/GUI/qml/Launcher.qml

171 lines
5.3 KiB
QML
Raw Normal View History

import QtQuick 2.4
2018-07-18 10:32:47 +00:00
import FlightGear 1.0
import "."
Item {
id: root
// order of this model sets the order of buttons in the sidebar
ListModel {
id: pagesModel
2018-07-02 22:10:52 +00:00
ListElement { title: qsTr("Summary"); pageSource: "qrc:///qml/Summary.qml"; iconPath: "qrc:///svg/toolbox-summary"; state:"loader" }
ListElement { title: qsTr("Aircraft"); pageSource: "qrc:///qml/AircraftList.qml"; iconPath: "qrc:///svg/toolbox-aircraft"; state:"loader" }
ListElement {
title: qsTr("Location"); pageSource: "qrc:///qml/Location.qml";
iconPath: "qrc:///toolbox-location"; state:"loader"
buttonDisabled: false
disabledText: qsTr("Location page disabled due to conflicting user arguments (in Settings)");
}
// due to some design stupidity by James, we can't use the Loader mechanism for these pages; they need to exist
// permanently so that collecting args works. So we instantiate them down below, and toggle the visiblity
// of them and the loader using a state.
2018-07-02 22:10:52 +00:00
ListElement { title: qsTr("Environment"); pageSource: ""; iconPath: "qrc:///svg/toolbox-environment"; state:"environment" }
ListElement { title: qsTr("Settings"); pageSource: ""; iconPath: "qrc:///svg/toolbox-settings"; state:"settings" }
2018-07-02 22:10:52 +00:00
ListElement { title: qsTr("Add-ons"); pageSource: "qrc:///qml/AddOns.qml"; iconPath: "qrc:///svg/toolbox-addons"; state:"loader" }
}
Component.onCompleted:
{
_launcher.minimumWindowSize = Qt.size(Style.strutSize * 12, sidebar.minimumHeight);
}
Connections {
target: _location
onSkipFromArgsChanged: pagesModel.setProperty(2, "buttonDisabled", _location.skipFromArgs)
}
states: [
State {
name: "loader"
PropertyChanges { target: pageLoader; visible: true }
PropertyChanges { target: settings; visible: false }
PropertyChanges { target: environment; visible: false }
},
State {
name: "settings"
PropertyChanges { target: pageLoader; visible: false }
PropertyChanges { target: settings; visible: true }
PropertyChanges { target: environment; visible: false }
},
State {
name: "environment"
PropertyChanges { target: pageLoader; visible: false }
PropertyChanges { target: settings; visible: false }
PropertyChanges { target: environment; visible: true }
}
]
Connections {
target: _launcher
onViewCommandLine: {
sidebar.selectedPage = -1;
pageLoader.source = "qrc:///qml/ViewCommandLine.qml"
root.state = "loader";
}
}
2018-07-05 08:02:02 +00:00
function enterFlightPlan()
{
sidebar.selectedPage = -1;
pageLoader.source = "qrc:///qml/FlightPlan.qml"
root.state = "loader";
}
Sidebar {
id: sidebar
height: parent.height
z: 1
pagesModel: pagesModel
selectedPage: 0 // open on the summary page
2018-06-26 16:13:28 +00:00
onShowMenu: menu.show();
onSelectPage: {
pageLoader.source = pageSource
root.state = pagesModel.get(selectedPage).state
}
}
Settings {
id: settings
height: parent.height
anchors {
left: sidebar.right
right: parent.right
}
}
Environment {
id: environment
height: parent.height
anchors {
left: sidebar.right
right: parent.right
}
}
Loader {
id: pageLoader
height: parent.height
anchors {
left: sidebar.right
right: parent.right
}
source: "qrc:///qml/Summary.qml"
}
function selectPage(index)
{
sidebar.setSelectedPage(index);
var page = pagesModel.get(index);
pageLoader.source = page.pageSource
root.state = page.state
}
Connections {
target: pageLoader.item
ignoreUnknownSignals: true
onShowSelectedAircraft: root.selectPage(1)
onShowSelectedLocation: root.selectPage(2)
}
2018-06-26 16:13:28 +00:00
Menu {
id: menu
z: 100
items: [
MenuItem { text:qsTr("Open saved configuration..."); shortcut: "Ctrl+O";
onTriggered: _launcher.openConfig(); },
MenuItem { text:qsTr("Save configuration as..."); shortcut: "Ctrl+S";
onTriggered: _launcher.saveConfigAs(); },
2018-06-26 16:13:28 +00:00
MenuDivider {},
MenuItem { text:qsTr("Flight-planning"); onTriggered: root.enterFlightPlan(); shortcut: "Ctrl+P"; enabled: true},
2018-07-05 08:02:02 +00:00
MenuDivider {},
MenuItem { text:qsTr("View command line"); onTriggered: _launcher.viewCommandLine(); shortcut: "Ctrl+L"},
2018-06-26 16:13:28 +00:00
MenuItem { text:qsTr("Select data files location..."); onTriggered: _launcher.requestChangeDataPath(); },
MenuItem { text:qsTr("Restore default settings..."); onTriggered: _launcher.requestRestoreDefaults(); },
MenuDivider {},
MenuItem { text:qsTr("Quit"); shortcut: "Ctrl+Q"; onTriggered: _launcher.quit(); }
]
}
2018-07-18 10:32:47 +00:00
Overlay {
id: popupOverlay
anchors.fill: parent
z: 200
Component.onCompleted: {
OverlayShared.globalOverlay = this
}
}
}