Debian Codegraph @

src/GUI/qml/AddOns.qml

raw
1 import QtQuick 2.4
2 import QtQuick.Controls 2.2
3
4 import FlightGear.Launcher 1.0
5 import FlightGear 1.0
6
7 Item {
8 id: root
9
10 function showDetails(index)
11 {
12 // set URI, start animation
13 // change state
14 detailsView.mdx = index;
15 detailsView.visible = true
16 }
17
18 Flickable {
19 id: flick
20 height: parent.height
21 width: parent.width
22 ScrollBar.vertical: ScrollBar {}
23
24 flickableDirection: Flickable.VerticalFlick
25 contentHeight: contents.childrenRect.height
26
27 Column {
28 id: contents
29 width: parent.width - (Style.margin * 2)
30 x: Style.margin
31 y: Style.margin
32 spacing: Style.margin
33
34 //////////////////////////////////////////////////////////////////
35 // catalogs //////////////////////////////////////////////////////
36
37 AddOnsHeader {
38 id: catalogHeader
39 title: qsTr("Aircraft hangars")
40 description: qsTr("Aircraft hangars are managed collections of aircraft, which can be " +
41 "downloaded, installed and updated inside FlightGear.")
42 }
43
44 Rectangle {
45 width: parent.width
46 height: catalogsColumn.childrenRect.height + Style.margin * 2
47 border.width: 1
48 border.color: Style.frameColor
49 clip: true
50 color: Style.panelBackground
51
52 Column {
53 id: catalogsColumn
54 width: parent.width
55 spacing: Style.margin
56
57 Repeater {
58 id: catalogsRepeater
59 model: _addOns.catalogs
60 delegate: CatalogDelegate {
61 width: catalogsColumn.width
62 }
63 }
64
65 Item {
66 id: bottomDivider
67 height: Style.margin
68 width: parent.width
69
70 Rectangle {
71 color: Style.frameColor
72 height: 1
73 width: parent.width - Style.strutSize
74 anchors.centerIn: parent
75 }
76 }
77
78 ClickableText {
79 visible: !_addOns.isOfficialHangarRegistered && !addCatalogPanel.isActive && _launcher.isNetworkAvailable
80 anchors { left: parent.left; right: parent.right; margins: Style.margin }
81 text : qsTr("The official FlightGear aircraft hangar is not set up. To add it, click here.");
82 onClicked: {
83 _addOns.catalogs.installDefaultCatalog(true)
84 }
85 }
86
87 AddCatalogPanel {
88 id: addCatalogPanel
89 anchors { left: parent.left; right: parent.right; margins: Style.margin }
90 }
91 }
92 }
93
94 //////////////////////////////////////////////////////////////////
95
96 Item {
97 // spacing item
98 width: parent.width
99 height: Style.margin * 2
100 }
101
102 AddOnsHeader {
103 id: addonModuleHeader
104 title: qsTr("Add-on Module folders")
105 description: qsTr("To use Add-on Modules that you download yourself, FlightGear needs to " +
106 "know the folder(s) containing the Add-on Modules.")
107 showAddButton: true
108 onAdd: {
109 var newPath = _addOns.addAddOnModulePath();
110 if (newPath !== "") {
111 _addOns.modulePaths.push(newPath)
112 }
113 }
114 }
115
116 Rectangle {
117 width: parent.width
118 height: addonModulePathsColumn.childrenRect.height + 1
119 border.width: 1
120 border.color: Style.frameColor
121 clip: true
122 color: Style.panelBackground
123
124 Column {
125 id: addonModulePathsColumn
126 width: parent.width - Style.margin * 2
127 x: Style.margin
128
129 Repeater {
130 id: addonModulesPathsRepeater
131 model: _addOns.modules
132 delegate: AddOnsDelegate {
133 width: addonModulePathsColumn.width
134 deletePromptText: qsTr("Remove the add-on module folder: '%1' from the list? (The folder contents will not be changed)").arg(model.path);
135 modelCount: _addOns.modulePaths.length
136
137 onPerformDelete: {
138 var modifiedPaths = _addOns.modulePaths.slice()
139 modifiedPaths.splice(model.index, 1);
140 _addOns.modulePaths = modifiedPaths;
141 }
142
143 onPerformMove: function(newIndex) {
144 var modifiedPaths = _addOns.modulePaths.slice()
145 modifiedPaths.splice(model.index, 1);
146 modifiedPaths.splice(newIndex, 0, model.path)
147 _addOns.modulePaths = modifiedPaths;
148 }
149
150 onShowDetails: function(detailIndex) {
151 root.showDetails(detailIndex);
152 }
153 }
154 }
155
156 StyledText {
157 visible: (addonModulesPathsRepeater.count == 0)
158 width: parent.width
159 text : qsTr("No custom add-on module paths are configured.");
160 }
161 }
162
163
164 }
165
166 //////////////////////////////////////////////////////////////////
167
168 Item {
169 // spacing item
170 width: parent.width
171 height: Style.margin * 2
172 }
173
174 StyledText {
175 id: commandLineDirsWarning
176 width: parent.width
177 visible: _addOns.havePathsFromCommandLine
178 color: Style.destructiveActionColor
179 text: qsTr("Additional aircraft or scenery folders were specified on the command-line. These are not listed here, but will be used when starting the simulator.")
180 }
181
182 Item {
183 // spacing item
184 width: parent.width
185 height: Style.margin * 2
186 visible: commandLineDirsWarning.visible
187 }
188
189 AddOnsHeader {
190 id: aircraftHeader
191 title: qsTr("Additional aircraft folders")
192 description: qsTr("To use aircraft you download yourself, FlightGear needs to " +
193 "know the folder(s) containing the aircraft data.")
194 showAddButton: true
195 onAdd: _addOns.addAircraftPath();
196 }
197
198 Rectangle {
199 width: parent.width
200 height: aircraftPathsColumn.childrenRect.height + 1
201 border.width: 1
202 border.color: Style.frameColor
203 clip: true
204 color: Style.panelBackground
205
206 Column {
207 id: aircraftPathsColumn
208 width: parent.width - Style.margin * 2
209 x: Style.margin
210
211 Repeater {
212 id: aircraftPathsRepeater
213 model: _addOns.aircraftPaths
214 delegate: PathListDelegate {
215 width: aircraftPathsColumn.width
216 deletePromptText: qsTr("Remove the aircraft folder: '%1' from the list? (The folder contents will not be changed)").arg(model.path);
217 modelCount: _addOns.aircraftPaths.count
218 onPerformDelete: _addOns.aircraftPaths.removePath(model.index)
219 onPerformMove: _addOns.aircraftPaths.swapIndices(model.index, newIndex);
220 }
221 }
222
223 StyledText {
224 visible: (aircraftPathsRepeater.count == 0)
225 width: parent.width
226 text : qsTr("No custom aircraft paths are configured.");
227 }
228 }
229
230
231 }
232
233 //////////////////////////////////////////////////////////////////
234
235 Item {
236 // spacing item
237 width: parent.width
238 height: Style.margin * 2
239 }
240
241 AddOnsHeader {
242 id: sceneryHeader
243 title: qsTr("Additional scenery folders")
244 description: qsTr("To use scenery you download yourself, FlightGear needs " +
245 "to know the folders containing the scenery data. " +
246 "Adjust the order of the list to control which scenery is used in a region.");
247 showAddButton: true
248 onAdd: _addOns.addSceneryPath();
249 }
250
251 Rectangle {
252 width: parent.width
253 height: sceneryPathsColumn.childrenRect.height + 1
254 border.width: 1
255 border.color: Style.frameColor
256 clip: true
257 color: Style.panelBackground
258
259 Column {
260 id: sceneryPathsColumn
261 width: parent.width - Style.margin * 2
262 x: Style.margin
263
264 Repeater {
265 id: sceneryPathsRepeater
266 model: _addOns.sceneryPaths
267
268 delegate: PathListDelegate {
269 width: sceneryPathsColumn.width
270 deletePromptText: qsTr("Remove the scenery folder: '%1' from the list? (The folder contents will not be changed)").arg(model.path);
271 modelCount: _addOns.sceneryPaths.count
272 onPerformDelete: _addOns.sceneryPaths.removePath(model.index)
273 onPerformMove: _addOns.sceneryPaths.swapIndices(model.index, newIndex);
274 }
275 }
276
277 StyledText {
278 visible: (sceneryPathsRepeater.count == 0)
279 width: parent.width
280 text : qsTr("No custom scenery paths are configured.");
281 }
282 }
283 }
284 } // of column
285 } // of Flickable
286
287 AddonsDetailsView
288 {
289 id: detailsView
290 anchors.fill: parent
291 visible: false
292 onGoBack: {
293 visible = false;
294 }
295
296 }
297 }
298