2018-03-19 08:22:11 +00:00
|
|
|
import QtQuick 2.4
|
2017-12-15 15:42:36 +00:00
|
|
|
import FlightGear.Launcher 1.0
|
|
|
|
import "."
|
|
|
|
|
|
|
|
SettingControl {
|
|
|
|
id: root
|
2018-06-03 09:07:21 +01:00
|
|
|
implicitHeight: col.height + Style.margin * 2
|
2017-12-15 15:42:36 +00:00
|
|
|
readonly property string placeholder: "--option=value --prop:/sim/name=value"
|
|
|
|
property alias value: edit.text
|
|
|
|
option: "xxx" // non-empty value so apply() is called
|
|
|
|
property string defaultValue: "" // needed to type save/restore logic to string
|
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
Column
|
|
|
|
{
|
|
|
|
id: col
|
|
|
|
y: Style.margin
|
2017-12-15 15:42:36 +00:00
|
|
|
width: parent.width
|
2018-06-03 09:07:21 +01:00
|
|
|
spacing: Style.margin
|
2017-12-15 15:42:36 +00:00
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
SettingDescription {
|
|
|
|
id: description
|
|
|
|
enabled: root.enabled
|
|
|
|
text: qsTr("Enter additional command-line arguments if any are required. " +
|
|
|
|
"See <a href=\"http://flightgear.sourceforge.net/getstart-en/getstart-enpa2.html#x5-450004.5\">here</a> " +
|
|
|
|
"for documentation on possible arguments.");
|
|
|
|
width: parent.width
|
|
|
|
}
|
2017-12-15 15:42:36 +00:00
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
SettingDescription {
|
|
|
|
id: warningText
|
|
|
|
enabled: root.enabled
|
|
|
|
visible: tokenizer.warnProtectedArgs
|
|
|
|
width: parent.width
|
|
|
|
text: qsTr("<b>Warning:</b> certain arguments such as the aircraft, location and time are set directly " +
|
|
|
|
"by this launcher. Attempting to set them here will <b>not</b> work as expected, " +
|
|
|
|
"since the same or conflicting arguments may be set. (For exmmple, this may cause " +
|
|
|
|
"you to start at the wrong position)");
|
|
|
|
}
|
2017-12-15 15:42:36 +00:00
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
Rectangle {
|
|
|
|
id: editFrame
|
|
|
|
height: edit.height + Style.margin
|
|
|
|
border.color: edit.activeFocus ? Style.frameColor : Style.minorFrameColor
|
|
|
|
border.width: 1
|
|
|
|
width: parent.width
|
2017-12-15 15:42:36 +00:00
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
TextEdit {
|
|
|
|
id: edit
|
|
|
|
enabled: root.enabled
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.margins: Style.margin
|
|
|
|
height: Math.max(Style.strutSize * 4, implicitHeight)
|
|
|
|
textFormat: TextEdit.PlainText
|
|
|
|
font.family: "Courier"
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: TextEdit.WordWrap
|
2017-12-15 15:42:36 +00:00
|
|
|
|
2018-06-03 09:07:21 +01:00
|
|
|
Text {
|
|
|
|
id: placeholder
|
|
|
|
visible: (edit.text.length == 0) && !edit.activeFocus
|
|
|
|
text: root.placeholder
|
|
|
|
color: Style.baseTextColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-15 15:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function apply()
|
|
|
|
{
|
|
|
|
var tokens = tokenizer.tokens;
|
|
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
|
|
var tk = tokens[i];
|
2018-06-03 09:07:21 +01:00
|
|
|
if (tk.arg.substring(0, 5) === "prop:") {
|
2017-12-15 15:42:36 +00:00
|
|
|
_config.setProperty(tk.arg.substring(5), tk.value);
|
|
|
|
} else {
|
|
|
|
_config.setArg(tk.arg, tk.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ArgumentTokenizer {
|
|
|
|
id: tokenizer
|
|
|
|
argString: edit.text
|
|
|
|
}
|
|
|
|
}
|