Debian Codegraph @

src/GUI/qml/SettingExtraArguments.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 FlightGear.Launcher 1.0
6 import FlightGear 1.0
7
8 SettingControl {
9 id: root
10 implicitHeight: col.height + Style.margin * 2
11 readonly property string placeholder: "--option=value --prop:/sim/name=value"
12 property alias value: edit.text
13 option: "xxx" // non-empty value so apply() is called
14 property string defaultValue: "" // needed to type save/restore logic to string
15
16 Column
17 {
18 id: col
19 y: Style.margin
20 width: parent.width
21 spacing: Style.margin
22
23 SettingDescription {
24 id: description
25 enabled: root.enabled
26 text: qsTr("Enter additional command-line arguments if any are required. " +
27 "See <a href=\"%1\">documentation</a> " +
28 "for possible arguments. " +
29 "<br>" +
30 "<b>Warning:</b> values entered here always override other settings; see the " +
31 "<a href=\"#view-command-line\">final set of arguments</a> that will be used."
32 ).arg("https://wiki.flightgear.org/Command_line_options");
33
34 onLinkActivated: {
35 if (link == "#view-command-line") {
36 _launcher.viewCommandLine();
37 } else {
38 Qt.openUrlExternally(link)
39 }
40 }
41
42 width: parent.width
43 }
44
45 SettingDescription {
46 id: warningText
47 enabled: root.enabled
48 visible: tokenizer.haveUnsupportedArgs
49 width: parent.width
50 text: qsTr("<b>Warning:</b> specifying <tt>--fg-root</tt>, <tt>--fg-aircraft</tt> or <tt>--fg-scenery</tt> " +
51 "using this section is not recommended, and may cause problems or prevent the simulator from running. " +
52 "Please use the add-ons page to setup scenery and aircraft directories, and the 'Select data files location' " +
53 "menu item to change the root data directory.");
54 }
55
56 SettingDescription {
57 id: positionalArgsText
58 enabled: root.enabled
59 visible: tokenizer.havePositionalArgs
60 width: parent.width
61 text: qsTr("<b>Note:</b> you have entered arguments relating to the startup location below. " +
62 "To prevent problems caused by conflicting settings, the values entered on the location " +
63 "page (for example, airport or altitude) will be ignored.");
64 }
65
66 SettingDescription {
67 id: aircraftArgsText
68 enabled: root.enabled
69 visible: tokenizer.haveAircraftArgs
70 width: parent.width
71 text: qsTr("<b>Note:</b> you have entered arguments relating to the selected aircraft. " +
72 "To prevent problems caused by conflicting settings, the aircraft page will be ignored.");
73 }
74
75 PlainTextEditBox
76 {
77 id: edit
78 width: parent.width
79 enabled: root.enabled
80 placeholder: root.placeholder
81 }
82 }
83
84 function apply()
85 {
86 var tokens = tokenizer.tokens;
87 for (var i = 0; i < tokens.length; i++) {
88 var tk = tokens[i];
89 if (tk.arg.substring(0, 5) === "prop:") {
90 _config.setProperty(tk.arg.substring(5), tk.value, LaunchConfig.ExtraArgs);
91 } else {
92 _config.setArg(tk.arg, tk.value, LaunchConfig.ExtraArgs);
93 }
94 }
95 }
96
97 Binding {
98 target: _location
99 property: "skipFromArgs"
100 value: tokenizer.havePositionalArgs
101 }
102
103 Binding {
104 target: _launcher
105 property: "skipAircraftFromArgs"
106 value: tokenizer.haveAircraftArgs
107 }
108
109 ArgumentTokenizer {
110 id: tokenizer
111 argString: edit.text
112 }
113 }