Debian Codegraph @

src/GUI/qml/+qt6/Settings.qml

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