| 1 |
import QtQuick 2.4 |
| 2 |
import QtQuick.Controls 2.2 |
| 3 |
import FlightGear.Launcher 1.0 |
| 4 |
import FlightGear 1.0 |
| 5 |
|
| 6 |
Rectangle { |
| 7 |
id: root |
| 8 |
color: "white" |
| 9 |
property int mdx: 0 |
| 10 |
signal goBack() |
| 11 |
|
| 12 |
MouseArea { |
| 13 |
// consume all mouse-clicks on the detail view |
| 14 |
anchors.fill: parent |
| 15 |
} |
| 16 |
|
| 17 |
Flickable |
| 18 |
{ |
| 19 |
id: flickable |
| 20 |
|
| 21 |
anchors.fill: parent |
| 22 |
contentWidth: parent.width |
| 23 |
contentHeight: content.childrenRect.height |
| 24 |
boundsBehavior: Flickable.StopAtBounds |
| 25 |
ScrollBar.vertical: ScrollBar {} |
| 26 |
|
| 27 |
function labelText(lbl, idx, key) { |
| 28 |
var value = _addOns.modules.get(idx, key); |
| 29 |
if (typeof value === 'object') { |
| 30 |
value = Object.keys(value).map(function(key) { return value[key]; }).join(', '); |
| 31 |
} |
| 32 |
return qsTr("%1: %2").arg(lbl).arg(value); |
| 33 |
} |
| 34 |
function getMeta(idx, key) { |
| 35 |
return _addOns.modules.get(idx, key); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
Item { |
| 40 |
id: content |
| 41 |
width: root.width |
| 42 |
height: childrenRect.height |
| 43 |
y: Style.margin |
| 44 |
|
| 45 |
Column { |
| 46 |
id: columnTop |
| 47 |
width: content.width - (Style.margin * 2) |
| 48 |
spacing: Style.margin |
| 49 |
anchors.horizontalCenter: parent.horizontalCenter |
| 50 |
|
| 51 |
AddOnsHeader { |
| 52 |
id: catalogHeader |
| 53 |
title: flickable.labelText(qsTr("Module"), mdx, "name"); |
| 54 |
width: parent.width |
| 55 |
} |
| 56 |
|
| 57 |
// description + authors container |
| 58 |
Item { |
| 59 |
width: parent.width |
| 60 |
height: childrenRect.height |
| 61 |
|
| 62 |
Column { |
| 63 |
id: column |
| 64 |
anchors.left: parent.left |
| 65 |
anchors.leftMargin: Style.margin |
| 66 |
anchors.right: parent.right |
| 67 |
spacing: Style.margin |
| 68 |
|
| 69 |
|
| 70 |
StyledText { |
| 71 |
id: addonDescription |
| 72 |
text: flickable.labelText(qsTr("Description"), mdx, "long_description"); |
| 73 |
width: parent.width |
| 74 |
wrapMode: Text.WordWrap |
| 75 |
visible: flickable.getMeta(mdx, "long_description") != "" |
| 76 |
} |
| 77 |
|
| 78 |
StyledText { |
| 79 |
id: addonId |
| 80 |
text: flickable.labelText(qsTr("Id"), mdx, "id"); |
| 81 |
width: parent.width |
| 82 |
wrapMode: Text.WordWrap |
| 83 |
visible: flickable.getMeta(mdx, "id") != "" |
| 84 |
} |
| 85 |
|
| 86 |
StyledText { |
| 87 |
id: addonVersion |
| 88 |
text: flickable.labelText(qsTr("Version"), mdx, "version"); |
| 89 |
width: parent.width |
| 90 |
wrapMode: Text.WordWrap |
| 91 |
visible: flickable.getMeta(mdx, "version") != "" |
| 92 |
} |
| 93 |
|
| 94 |
StyledText { |
| 95 |
id: minFgVersion |
| 96 |
text: flickable.labelText(qsTr("Minimum FlightGear version"), mdx, "minversion_fg"); |
| 97 |
width: parent.width |
| 98 |
wrapMode: Text.WordWrap |
| 99 |
visible: flickable.getMeta(mdx, "minversion_fg") != "" |
| 100 |
} |
| 101 |
|
| 102 |
StyledText { |
| 103 |
id: maxFgVersion |
| 104 |
text: flickable.labelText(qsTr("Maximum FlightGear version"), mdx, "maxversion_fg"); |
| 105 |
width: parent.width |
| 106 |
wrapMode: Text.WordWrap |
| 107 |
visible: flickable.getMeta(mdx, "maxversion_fg") != "" |
| 108 |
} |
| 109 |
|
| 110 |
StyledText { |
| 111 |
id: addonAuthors |
| 112 |
text: flickable.labelText(qsTr("Authors"), mdx, "authors"); |
| 113 |
width: parent.width |
| 114 |
anchors.horizontalCenter: parent.horizontalCenter |
| 115 |
wrapMode: Text.WordWrap |
| 116 |
visible: (flickable.getMeta(mdx, "authors") != undefined) |
| 117 |
} |
| 118 |
|
| 119 |
StyledText { |
| 120 |
id: addonMaintainers |
| 121 |
text: flickable.labelText(qsTr("Maintainers"), mdx, "maintainers"); |
| 122 |
width: parent.width |
| 123 |
anchors.horizontalCenter: parent.horizontalCenter |
| 124 |
wrapMode: Text.WordWrap |
| 125 |
visible: (flickable.getMeta(mdx, "maintainers") != undefined) |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
} // end of Item |
| 130 |
|
| 131 |
// web-links row |
| 132 |
Row { |
| 133 |
id: weblinks |
| 134 |
width: parent.width |
| 135 |
height: childrenRect.height |
| 136 |
spacing: Style.margin |
| 137 |
|
| 138 |
Weblink { |
| 139 |
visible: flickable.getMeta(mdx, "homepage") != "" |
| 140 |
label: qsTr("Website") |
| 141 |
link: flickable.getMeta(mdx, "homepage") || "" |
| 142 |
} |
| 143 |
|
| 144 |
Weblink { |
| 145 |
visible: flickable.getMeta(mdx, "support_url") != "" |
| 146 |
label: qsTr("Support and issue reporting") |
| 147 |
link: flickable.getMeta(mdx, "support_url") || "" |
| 148 |
} |
| 149 |
|
| 150 |
Weblink { |
| 151 |
visible: flickable.getMeta(mdx, "download_url") != "" |
| 152 |
label: qsTr("Download") |
| 153 |
link: flickable.getMeta(mdx, "download_url") || "" |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
ClickableText { |
| 158 |
id: pathLabel |
| 159 |
text: flickable.labelText(qsTr("Local file location"), mdx, "path"); |
| 160 |
onClicked: { |
| 161 |
// open the location |
| 162 |
_addOns.openDirectory(flickable.getMeta(mdx, "path")) |
| 163 |
} |
| 164 |
// anchors.top: weblinks.bottom |
| 165 |
anchors.left: parent.left |
| 166 |
width: parent.width |
| 167 |
wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
| 168 |
visible: flickable.getMeta(mdx, "path") != undefined |
| 169 |
} |
| 170 |
|
| 171 |
Text { |
| 172 |
height: 50 |
| 173 |
text: " " |
| 174 |
} |
| 175 |
|
| 176 |
BackButton |
| 177 |
{ |
| 178 |
id: backButton |
| 179 |
onClicked: root.goBack(); |
| 180 |
} |
| 181 |
|
| 182 |
} // main layout column |
| 183 |
} // of main item |
| 184 |
|
| 185 |
} // of Flickable |
| 186 |
|
| 187 |
} // of Rect |