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