Debian Codegraph @

src/GUI/qml/Settings.qml

raw
1 // SPDX-FileCopyrightText: 2018 James Turner
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 import QtQuick 2.4
5 import QtQuick.Controls 2.2
6
7 import FlightGear.Launcher 1.0
8 import FlightGear 1.0
9
10 Item {
11 id: settings
12
13 Rectangle {
14 visible: _launcher.isSearchActive
15 anchors.fill: parent
16 color: Style.backgroundColor
17 }
18
19 Rectangle {
20 // search 'dimming' rectangle
21 visible: _launcher.isSearchActive
22 anchors.fill: parent
23 color: "#7f7f7f"
24 }
25
26 Binding {
27 target: _launcher
28 property: "settingsSummary"
29 value: generalSettings.summary().concat(mpSettings.summary(),
30 downloadSettings.summary(),
31 windowSettings.summary(),
32 renderSection.summary());
33 }
34
35 Flickable
36 {
37 id: settingsFlick
38 contentHeight: sectionColumn.childrenRect.height
39 flickableDirection: Flickable.VerticalFlick
40 height: parent.height
41 width: parent.width - Style.margin * 2
42 x: Style.margin
43
44 ScrollBar.vertical: ScrollBar {}
45
46 Column
47 {
48 id: sectionColumn
49 width: parent.width
50
51 GettingStartedScope.controller: tips.controller
52
53 Item {
54 // top margin
55 width: parent.width
56 height: Style.margin
57 }
58
59 Item {
60 id: header
61 width: parent.width
62 height: headerText.height
63
64 StyledText {
65 id: headerText
66 text: qsTr("Settings")
67 font.pixelSize: Style.headingFontPixelSize
68 anchors.left: parent.left
69 anchors.leftMargin: Style.inset
70 }
71
72 SearchButton {
73 id: search
74 width: Style.strutSize * 4
75 anchors.right: parent.right
76 anchors.rightMargin: Style.margin
77 anchors.verticalCenter: parent.verticalCenter
78 autoSubmitTimeout: 250
79 onSearch: function(term) {
80 _launcher.settingsSearchTerm = term
81 }
82
83 GettingStartedTip {
84 tipId: "searchSettingsTip"
85 nextTip: "expandSectionTip"
86
87 anchors {
88 horizontalCenter: parent.horizontalCenter
89 top: parent.bottom
90 }
91 arrow: GettingStartedTip.TopRight
92 text: qsTr("Enter text here to search for a setting")
93 }
94 }
95 }
96
97 Item {
98 // below header margin
99 width: parent.width
100 height: Style.margin
101 }
102
103 Section {
104 id: generalSettings
105 title: qsTr("General")
106 settingGroup: "general"
107
108 function summary()
109 {
110 var result = [];
111 if (startPaused.checked) result.push(qsTr("paused"));
112 if (!showConsoleWin.hidden && showConsoleWin.checked) result.push(qsTr("console"));
113 return result;
114 }
115
116 contents: [
117 SettingCheckbox {
118 id: startPaused
119 label: qsTr("Start paused")
120 description: qsTr("Automatically pause the simulator when launching. This is useful "
121 + "when starting in the air.")
122 keywords: ["pause", "freeze"]
123 option: "freeze"
124 setting: "start-paused"
125 },
126
127 SettingCheckbox {
128 id: autoCoordination
129 label: qsTr("Enable auto-coordination")
130 description: qsTr("When flying with the mouse, or a joystick lacking a rudder axis, "
131 + "it's difficult to manually coordinate aileron and rudder movements during "
132 + "turn. This option automatically commands the rudder to maintain zero "
133 + "slip angle when banking");
134 advanced: true
135 keywords: ["input", "mouse", "control", "rudder"]
136 option: "auto-coordination"
137 setting: "auto-coordination"
138 },
139
140 SettingCheckbox {
141 id: showConsoleWin
142 label: qsTr("Show debugging console")
143 description: qsTr("Open a console window showing debug output from the application.")
144 advanced: true
145 hidden: _osName !== "win"
146 keywords: ["console", "terminal", "log", "debug"]
147 setting: "console"
148 },
149
150 SettingCheckbox {
151 id: enableCrashReporting
152 label: qsTr("Enable crash & error reporting")
153 description: qsTr("Send crash and error reports to the development team for analysis.")
154 defaultValue: true
155 keywords: ["crash", "report", "telemetry", "sentry", "segfault"]
156 setting: "enable-sentry"
157 },
158
159 SettingCheckbox {
160 id: developerMode
161 advanced: true
162 label: qsTr("Enable developer mode")
163 description: qsTr("Enable simulator & aircraft development features, such as increased error messages in log files.")
164 defaultValue: false
165 keywords: ["develop", "developer"]
166 setting: "develop"
167 },
168
169 SettingCheckbox {
170 id: restartLauncher
171 label: qsTr("Re-open FlightGear on exit")
172 description: qsTr("Re-open this window when exiting FlightGear, to start another flight immediately.")
173 keywords: ["restart", "reopen"]
174 setting: "restart-launcher"
175 }
176 ]
177
178 onApply: {
179 if (!showConsoleWin.hidden && showConsoleWin.checked) _config.setArg("console");
180 _config.setEnableDisableOption("sentry", enableCrashReporting.checked);
181 if (developerMode.checked) _config.setArg("developer");
182 if (restartLauncher.checked) _config.setArg("restart-launcher");
183 }
184 }
185
186 Section {
187 id: mpSettings
188 title: qsTr("Multi-player")
189 settingGroup: "mp"
190
191 readonly property int defaultMPPort: 5000
192
193 function summary()
194 {
195 var result = [];
196 if (enableMP.checked) result.push(qsTr("multi-player"));
197 return result;
198 }
199
200 contents: [
201 Note {
202 visible:!_launcher.isNetworkAvailable
203 width: parent.width
204 text: qsTr("No network connection was detected, so multi-player flight will not be available.");
205 },
206
207 SettingCheckbox {
208 id: enableMP
209 label: qsTr("Connect to the multi-player network")
210 description: qsTr("FlightGear supporters maintain a network of servers to enable global multi-user "
211 + "flight. This requires a moderately fast Internet connection to be usable. Your aircraft "
212 + "will be visible to other users online, and you will see their aircraft.")
213 keywords: ["network", "mp", "multiplay","online"]
214 setting: "enabled"
215
216 onValueChanged: {
217 if (value) {
218 _launcher.queryMPServers();
219 }
220 }
221 },
222
223 SettingLineEdit {
224 id: callSign
225 enabled: enableMP.checked
226 label: qsTr("Callsign")
227 description: qsTr("Enter a callsign you will use online. This is visible to all users and is " +
228 "how ATC services and other pilots will refer to you. " +
229 "(Maximum of seven characters permitted)")
230 placeholder: "D-FGFS"
231 suggestedWidthString: "MMMMMMMMMMM"
232 keywords: ["callsign", "handle", "name"]
233
234 // between one and seven alphanumerics, underscores and/or hyphens
235 // spaces not permitted
236 validation: RegExpValidator { regExp: /[\w-]{1,7}/ }
237 setting: "callsign"
238 },
239
240 SettingsComboBox {
241 id: mpServer
242 label: qsTr("Server")
243 enabled: enableMP.checked
244 description: qsTr("Select a server close to you for better responsiveness and reduced lag when flying online.")
245 model: _launcher.mpServersModel
246
247 readonly property bool currentIsCustom: (_launcher.mpServersModel.currentServer === "__custom__")
248 readonly property bool currentIsNoServers: (_launcher.mpServersModel.currentServer === "__noservers__")
249 property string __savedServer;
250
251 keywords: ["server", "hostname"]
252 setting: "server"
253
254 // following three elements are to deal with the irregular way we save the
255 // MP server state, because the index is unstable, and the time to query online servers
256 // is determined by the MPServersModel. So we let that code do the state
257 // restoration, and emit a signal we handler here, when it wants to update the UI.
258 function saveState()
259 {
260 // these values match the code in MPServersModel.cpp, sorry for that
261 // nastiness
262 _config.setValueForKey("mpSettings", "mp-server", _launcher.mpServersModel.currentServer);
263 }
264
265 function restoreState()
266 {
267 // no-op, this is triggered by MPServersModel::restoreMPServerSelection
268 }
269
270 // can't use a Binding here, since we need a bidirectional link
271 onSelectedIndexChanged: _launcher.mpServersModel.currentIndex = selectedIndex
272
273 Connections
274 {
275 target: _launcher.mpServersModel
276 function onCurrentIndexChanged() {
277 mpServer.selectedIndex = _launcher.mpServersModel.currentIndex;
278 }
279 }
280 },
281
282 SettingLineEdit {
283 id: mpCustomServer
284 enabled: enableMP.checked
285 label: qsTr("Custom server")
286 hidden: !mpServer.currentIsCustom
287 description: qsTr("Enter a server hostname or IP address, and optionally a port number. (Default port is 5000) For example 'localhost:5001'")
288 placeholder: "localhost:5001"
289 suggestedWidthString: "MMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
290 setting: "custom-server"
291 }
292 ]
293
294 onApply: {
295 if (enableMP.checked) {
296 if (mpServer.currentIsNoServers) {
297 console.warn("MP enabled but no valid server selected, skipping");
298 } else if (mpServer.currentIsCustom) {
299 var pieces = mpCustomServer.value.split(':')
300 var customPort = defaultMPPort;
301 if (pieces.length > 1) {
302 customPort = pieces[1];
303 }
304
305 if (pieces[0].length > 0) {
306 _config.setProperty("/sim/multiplay/txhost", pieces[0]);
307 _config.setProperty("/sim/multiplay/txport", customPort);
308 } else {
309 console.warn("Custom MP server selected but no hostname defined");
310 }
311 } else {
312 var host = _launcher.mpServersModel.currentServer;
313 if (host.length > 0) {
314 _config.setProperty("/sim/multiplay/txhost", host);
315 }
316
317 var port = _launcher.mpServersModel.currentPort;
318 if (port === 0) {
319 console.info("Using default MP port");
320 port = defaultMPPort;
321 }
322
323 _config.setProperty("/sim/multiplay/txport", port);
324 }
325
326 if (callSign.value.length > 0) {
327 _config.setArg("callsign", callSign.value)
328 }
329 }
330 }
331 }
332
333 Section {
334 id: downloadSettings
335 title: qsTr("Downloads")
336 width: parent.width
337 settingGroup: "downloads"
338
339 function summary()
340 {
341 var result = [];
342 if (terrasync.checked) result.push(qsTr("scenery downloads"));
343 return result;
344 }
345
346 contents: [
347 Note {
348 visible:!_launcher.isNetworkAvailable
349 width: parent.width
350 text: qsTr("No network connection was detected, so scenery will not be downloaded or updated. Previously downloaded scenery will be available as normal.");
351 },
352
353 SettingCheckbox {
354 id: terrasync
355 label: qsTr("Download scenery automatically")
356 description: qsTr("FlightGear can automatically download scenery as needed, and check for updates to "
357 + "the scenery. If you disable this option, you will need to download & install scenery "
358 + "using an alternative method.")
359 keywords: ["terrasync", "download", "scenery"]
360 option: "terrasync"
361 setting: "terrasync"
362 defaultValue: true
363
364 // ensure we pass --disable-terrasync when unchecked, because
365 // terrasync state is autosaved and hence can stick inside the sim
366 setIfDefault: true
367 },
368
369 SettingsComboBox {
370 id: terraSyncDnsMode
371 label: qsTr("TerraSync DNS Server")
372 description: qsTr("Select the DNS server used for TerraSync lookup.")
373 advanced: true
374 choices: [qsTr("Default"), qsTr("Google"), qsTr("Custom DNS Server") ]
375 defaultIndex: 0
376 readonly property bool isGoogle: selectedIndex == 1
377 readonly property bool isCustom: selectedIndex == 2
378 keywords: ["terrasync", "dns", "network", "download", "scenery"]
379 setting: "terrasync-dns-mode"
380 },
381
382 SettingLineEdit {
383 id: terraSyncCustomDns
384 hidden: !terraSyncDnsMode.isCustom
385 label: qsTr("Custom DNS Server")
386 advanced: true
387 description: qsTr("Enter a custom DNS server IP address, for example '8.8.8.8'")
388 // validation: RegExpValidator { regExp: /[\d]{1,7}[\s]*x[\s]*[\d]{1,7}$/ }
389 suggestedWidthString: "255.255.255.255"
390 setting: "terrasync-dns-custom-server"
391 },
392
393 SettingPathChooser {
394 id: downloadDir
395 label: qsTr("Download location")
396 description: qsTr("FlightGear stores downloaded files (scenery and aircraft) in this location. "
397 + "Depending on your settings, it may grow to a considerable size (many gigabytes). "
398 + "If you change the download location, files will need to be downloaded again. "
399 + "When changing this setting, FlightGear will restart to use the new location correctly.")
400 advanced: true
401 chooseDirectory: true
402 defaultPath: _config.defaultDownloadDir
403 dialogPrompt: qsTr("Choose a location to store download files.")
404 setting: "download-dir"
405
406 // we disable this UI if the user passes --download-dir when starting the
407 // launcher, otherwise we coudld end up in a complete mess
408 enabled: _config.enableDownloadDirUI
409
410 keywords: ["download", "storage", "disk"]
411
412 onPathChanged: {
413 // lots of special work needs to be done immediately that this
414 // value is changed.
415 _launcher.downloadDirChanged(path);
416 }
417
418 function saveState()
419 {
420 // ensure this is a no-op, we write the value explicitly
421 // in LauncherController::downloadDirChanged
422 }
423 }
424 ]
425
426 onApply: {
427 // note we do /not/ apply the downloadDir setting here, since it's
428 // only permitted to occur once, and we set it via other means;
429 // on startup via runLauncherDialog, and if it changes, via
430 // LauncherMainWindow::downloadDirChanged
431
432 if (terraSyncDnsMode.isCustom) {
433 _config.setProperty("/sim/terrasync/dns-server", terraSyncCustomDns.value);
434 } else if (terraSyncDnsMode.isGoogle) {
435 // DNSClient.cxx handles this as a special value
436 _config.setProperty("/sim/terrasync/dns-server", "google");
437 }
438 }
439
440 summary: terrasync.checked ? "scenery downloads;" : ""
441 }
442
443 Section {
444 id: windowSettings
445 title: qsTr("View & Window")
446 width: parent.width
447 settingGroup: "window"
448
449 function summary()
450 {
451 var result = [];
452 if (fullscreen.checked) result.push(qsTr("full-screen"));
453 return result;
454 }
455
456 contents: [
457 SettingCheckbox {
458 id: fullscreen
459 label: qsTr("Start full-screen")
460 description: qsTr("Start the simulator in full-screen mode.");
461 setting: "fullscreen"
462 option: "fullscreen"
463 // always set, so launcher overrides autosave.xml
464 // https://gitlab.com/flightgear/flightgear/-/issues/3079
465 setIfDefault: true
466 },
467
468 SettingsComboBox {
469 id: windowSize
470 enabled: !fullscreen.checked
471 label: qsTr("Window size")
472 description: qsTr("Select the initial size of the window (this has no effect in full-screen mode).")
473 advanced: true
474 choices: ["640x480", "800x600", "1024x768", "1920x1080", "2560x1600", qsTr("Custom Size") ]
475 defaultIndex: 2
476 readonly property bool isDefault: selectedIndex == defaultIndex
477 readonly property bool isCustom: selectedIndex == 5
478 keywords: ["window", "geometry", "size", "resolution"]
479 setting: "window-size"
480 },
481
482 SettingLineEdit {
483 id: customWindowSize
484 hidden: !windowSize.isCustom
485 label: qsTr("Custom size")
486 advanced: true
487 description: qsTr("Enter a custom window size in the form 'WWWWW x HHHHH', for example '1280 x 900'")
488 validation: RegExpValidator { regExp: /[\d]{1,7}[\s]*x[\s]*[\d]{1,7}$/ }
489 setting: "custom-size"
490 suggestedWidthString: "0000000 x 0000000"
491
492 }
493
494 ]
495
496 onApply: {
497 if (windowSize.isCustom) {
498 _config.setArg("geometry", customWindowSize.value);
499 } else if (!windowSize.isDefault) {
500 _config.setArg("geometry", windowSize.choices[windowSize.selectedIndex]);
501 }
502 }
503 }
504
505 Section {
506 id: renderSection
507 title: qsTr("Rendering")
508 width: parent.width
509 settingGroup: "render"
510
511 readonly property bool msaaEnabled: (msaa.selectedIndex > 0)
512 readonly property bool ws30Enabled: (sceneryversion.selectedIndex > 0)
513
514 function summary()
515 {
516 var result = [];
517 if (msaaEnabled) result.push(qsTr("anti-aliasing"));
518 if (ws30Enabled) result.push(qsTr("scenery v3.0"));
519 return result;
520 }
521
522 contents: [
523 SettingsComboBox {
524 id: msaa
525 label: qsTr("Anti-aliasing")
526 setting: "aa"
527 description: qsTr("Anti-aliasing improves the appearance of high-contrast edges and lines. " +
528 "This is especially noticeable on sloping or diagonal edges. " +
529 "Higher settings can reduce performance.")
530 keywords: ["msaa", "anti", "aliasing", "multi", "sample"]
531 choices: [qsTr("Off"), "2x", "4x", "8x"]
532 property var data: [0, 2, 4, 8];
533 defaultIndex: 0
534 },
535
536 SettingCheckbox {
537 id: compressTextures
538 setting: "texture-compression"
539 keywords: ["texture", "compression", "memory", "dxt", "cache"]
540 // no option, since we need to set a property
541 advanced: true
542
543 label: qsTr("Cache graphics for faster loading")
544 description: qsTr("By converting images used in rendering to an optimised format " +
545 "loading times and memory use can be improved. This will consume " +
546 "some disk space and take initial time while images are converted, " +
547 "but subsequent loads will be faster, and use less memory.")
548 },
549
550 SettingsComboBox {
551 id: sceneryversion
552 setting: "scenery-version"
553 advanced: true
554
555 label: qsTr("Scenery version")
556 description: qsTr("Scenery version 2.0 is available for the whole world and works well for " +
557 "lower powered systems. Scenery version 3.0 is currently under development, but is only " +
558 "available for limited areas. It is more detailed and performs better on high powered systems.")
559 keywords: ["scenery", "ws2.0", "ws20", "ws3.0", "ws30"]
560 choices: ["V2.0", "V3.0"]
561 property var data: [0, 1];
562 defaultIndex: 0
563 }
564 ]
565
566 onApply: {
567 if (msaaEnabled) {
568 _config.setProperty("/sim/rendering/multi-sample-buffers", 1)
569 _config.setProperty("/sim/rendering/multi-samples", msaa.data[msaa.selectedIndex])
570 }
571
572 if (ws30Enabled) {
573 _config.setProperty("/scenery/use-vpb", true)
574 _config.setProperty("/sim/rendering/scenery-path-suffix[98]/enabled", true)
575 } else {
576 _config.setProperty("/scenery/use-vpb", false)
577 _config.setProperty("/sim/rendering/scenery-path-suffix[98]/enabled", false)
578 }
579
580 _config.setProperty("/sim/rendering/texture-cache/cache-enabled", compressTextures.value);
581 }
582 }
583
584 Section {
585 id: extraArgsSection
586 title: qsTr("Additional Settings")
587 settingGroup: "extraArgs"
588 width: parent.width
589 contents: [
590 SettingExtraArguments {
591 id: extraArgs
592 keywords: ["property", "extra", "command", "argument"]
593 setting: "extra-args"
594 }
595 ]
596 }
597 } // of Column
598
599 GettingStartedTipLayer {
600 id: tips
601 anchors.fill: parent
602 scopeId: "settings"
603 }
604 } // of Flickable
605 }