| 1 |
// SPDX-FileCopyrightText: 2018 James Turner |
| 2 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 3 |
|
| 4 |
import QtQuick 2.4 |
| 5 |
import FlightGear.Launcher 1.0 |
| 6 |
import FlightGear 1.0 |
| 7 |
|
| 8 |
Item { |
| 9 |
id: root |
| 10 |
|
| 11 |
signal select(var uri); |
| 12 |
signal showDetails(var uri) |
| 13 |
|
| 14 |
implicitHeight: Math.max(contentBox.childrenRect.height, thumbnailBox.height) + |
| 15 |
footer.height + Style.margin / 2 |
| 16 |
implicitWidth: ListView.view.width |
| 17 |
|
| 18 |
readonly property bool __isSelected: (_launcher.selectedAircraft === model.uri) |
| 19 |
|
| 20 |
property bool __showAlternateText: false |
| 21 |
|
| 22 |
function cycleTextDisplay() |
| 23 |
{ |
| 24 |
__showAlternateText = !__showAlternateText; |
| 25 |
} |
| 26 |
|
| 27 |
function alternateText() |
| 28 |
{ |
| 29 |
return qsTr("URI: %1\nLocal path: %2").arg(model.uri).arg(titleBox.pathOnDisk); |
| 30 |
} |
| 31 |
|
| 32 |
MouseArea { |
| 33 |
anchors.fill: parent |
| 34 |
|
| 35 |
onClicked: function(mouse) { |
| 36 |
if (mouse.modifiers & Qt.ShiftModifier ) { |
| 37 |
root.cycleTextDisplay(); |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
if (__isSelected) { |
| 42 |
root.showDetails(model.uri) |
| 43 |
} else { |
| 44 |
root.select(model.uri) |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
Item { |
| 50 |
id: thumbnailBox |
| 51 |
width: 172 |
| 52 |
height: 128 |
| 53 |
anchors.top: parent.top |
| 54 |
anchors.topMargin: Style.margin / 2 |
| 55 |
|
| 56 |
Rectangle { |
| 57 |
anchors.centerIn: parent |
| 58 |
border.width: 1 |
| 59 |
border.color: "#7f7f7f" |
| 60 |
width: thumbnail.width |
| 61 |
height: thumbnail.height |
| 62 |
|
| 63 |
ThumbnailImage { |
| 64 |
id: thumbnail |
| 65 |
aircraftUri: model.uri |
| 66 |
maximumSize.width: 172 |
| 67 |
maximumSize.height: 128 |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
Column { |
| 73 |
id: contentBox |
| 74 |
|
| 75 |
anchors { |
| 76 |
left: thumbnailBox.right |
| 77 |
right: parent.right |
| 78 |
leftMargin: Style.margin |
| 79 |
rightMargin: Style.margin |
| 80 |
topMargin: Style.margin / 2 |
| 81 |
top: parent.top |
| 82 |
} |
| 83 |
|
| 84 |
spacing: Style.margin |
| 85 |
|
| 86 |
Item { |
| 87 |
height: titleBox.height |
| 88 |
width: parent.width |
| 89 |
|
| 90 |
FavouriteToggleButton { |
| 91 |
id: favourite |
| 92 |
checked: model.favourite |
| 93 |
anchors.verticalCenter: parent.verticalCenter |
| 94 |
onToggle: { |
| 95 |
model.favourite = on; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
AircraftVariantChoice { |
| 100 |
id: titleBox |
| 101 |
|
| 102 |
anchors { |
| 103 |
left: favourite.right |
| 104 |
leftMargin: Style.margin |
| 105 |
right: parent.right |
| 106 |
} |
| 107 |
|
| 108 |
aircraft: model.uri; |
| 109 |
currentIndex: model.activeVariant |
| 110 |
onSelected: function(index) { |
| 111 |
model.activeVariant = index |
| 112 |
root.select(model.uri) |
| 113 |
} |
| 114 |
|
| 115 |
GettingStartedTip { |
| 116 |
tipId: "aircraftVariantTip" |
| 117 |
enabled: model.variantCount > 0 |
| 118 |
standalone: true |
| 119 |
|
| 120 |
Component.onCompleted: { |
| 121 |
if (enabled) { |
| 122 |
showOneShot(); |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
anchors { |
| 127 |
horizontalCenter: parent.horizontalCenter |
| 128 |
top: parent.bottom |
| 129 |
} |
| 130 |
arrow: GettingStartedTip.TopCenter |
| 131 |
text: qsTr("Click here to select different variants or models of this aircraft") |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
StyledText { |
| 139 |
id: description |
| 140 |
width: parent.width |
| 141 |
text: root.__showAlternateText ? root.alternateText() |
| 142 |
: model.description |
| 143 |
maximumLineCount: 3 |
| 144 |
wrapMode: Text.WordWrap |
| 145 |
elide: Text.ElideRight |
| 146 |
height: implicitHeight |
| 147 |
visible: (model.description !== "") || root.__showAlternateText |
| 148 |
} |
| 149 |
|
| 150 |
AircraftDownloadPanel |
| 151 |
{ |
| 152 |
id: downloadPanel |
| 153 |
visible: (model.package !== undefined) |
| 154 |
packageSize: model.packageSizeBytes |
| 155 |
installStatus: model.packageStatus |
| 156 |
downloadedBytes: model.downloadedBytes |
| 157 |
uri: model.uri |
| 158 |
width: parent.width |
| 159 |
compact: true |
| 160 |
} |
| 161 |
|
| 162 |
} // of content column |
| 163 |
|
| 164 |
Item { |
| 165 |
id: footer |
| 166 |
height: Style.margin / 2 + 1 |
| 167 |
width: parent.width |
| 168 |
anchors.bottom: parent.bottom |
| 169 |
|
| 170 |
Rectangle { |
| 171 |
color: Style.frameColor |
| 172 |
height: 1 |
| 173 |
width: parent.width - Style.strutSize |
| 174 |
anchors.bottom: parent.bottom |
| 175 |
anchors.horizontalCenter: parent.horizontalCenter |
| 176 |
} |
| 177 |
} |
| 178 |
} // of root item |