1
0
Fork 0

Launcher: detect user-entered aircraft args

Avoid double-setting or conflicting aircraft arguments being passed:
when the user enters an aircraft related argument manually, disable
the launcher setting them.
This commit is contained in:
James Turner 2021-03-17 12:42:54 +00:00
parent 85da09d5d5
commit b76b6548a1
7 changed files with 47 additions and 5 deletions

View file

@ -170,3 +170,10 @@ bool LauncherArgumentTokenizer::havePositionalArgs() const
{
return haveArgsIn(positionalArgs);
}
const std::set<std::string> aircraftArgs({"state", "aircraft", "aircraft-dir", "vehicle"});
bool LauncherArgumentTokenizer::haveAircraftArgs() const
{
return haveArgsIn(aircraftArgs);
}

View file

@ -27,6 +27,7 @@ class LauncherArgumentTokenizer : public QObject
Q_PROPERTY(bool valid READ isValid NOTIFY argStringChanged)
Q_PROPERTY(bool havePositionalArgs READ havePositionalArgs NOTIFY argStringChanged)
Q_PROPERTY(bool haveUnsupportedArgs READ haveUnsupportedArgs NOTIFY argStringChanged)
Q_PROPERTY(bool haveAircraftArgs READ haveAircraftArgs NOTIFY argStringChanged)
public:
LauncherArgumentTokenizer();
@ -43,6 +44,7 @@ public:
bool haveUnsupportedArgs() const;
bool havePositionalArgs() const;
bool haveAircraftArgs() const;
public slots:
void setArgString(QString argString);

View file

@ -288,6 +288,9 @@ void LauncherController::saveSettings()
void LauncherController::collectAircraftArgs()
{
if (m_skipAircraftFromArgs)
return;
// aircraft
if (!m_selectedAircraft.isEmpty()) {
if (m_selectedAircraft.isLocalFile()) {

View file

@ -96,6 +96,8 @@ class LauncherController : public QObject
Q_PROPERTY(int launchCount READ launchCount CONSTANT);
Q_PROPERTY(int versionLaunchCount READ versionLaunchCount CONSTANT);
// property to indicate if we're disabling the aircraft selection because the user entered it manuall
Q_PROPERTY(bool skipAircraftFromArgs MEMBER m_skipAircraftFromArgs NOTIFY skipAircraftFromArgsChanged)
public:
explicit LauncherController(QObject *parent, QWindow* win);
@ -244,6 +246,7 @@ signals:
void installedAircraftCountChanged(int installedAircraftCount);
void didResetGettingStartedTips();
void skipAircraftFromArgsChanged();
public slots:
void setSelectedAircraft(QUrl selectedAircraft);
@ -330,6 +333,7 @@ private:
int m_launchCount = 0;
int m_versionLaunchCount = 0;
bool m_flyRequested = false;
bool m_skipAircraftFromArgs = false;
};
#endif // LAUNCHERCONTROLLER_HXX

View file

@ -64,6 +64,11 @@ Item {
onSkipFromArgsChanged: startupPagesModel.setProperty(2, "buttonDisabled", _location.skipFromArgs)
}
Connections {
target: _launcher
onSkipAircraftFromArgsChanged: startupPagesModel.setProperty(1, "buttonDisabled", _launcher.skipAircraftFromArgs)
}
state: "loader"
states: [
State {

View file

@ -60,6 +60,15 @@ SettingControl {
"page (for example, airport or altitude) will be ignored.");
}
SettingDescription {
id: aircraftArgsText
enabled: root.enabled
visible: tokenizer.haveAircraftArgs
width: parent.width
text: qsTr("<b>Note:</b> you have entered arguments relating to the selected aircraft. " +
"To prevent problems caused by conflicting settings, the aircraft page will be ignored.");
}
PlainTextEditBox
{
id: edit
@ -88,6 +97,12 @@ SettingControl {
value: tokenizer.havePositionalArgs
}
Binding {
target: _launcher
property: "skipAircraftFromArgs"
value: tokenizer.haveAircraftArgs
}
ArgumentTokenizer {
id: tokenizer
argString: edit.text

View file

@ -155,9 +155,12 @@ Item {
}
ClickableText {
text: _launcher.selectedAircraftInfo.name === "" ?
qsTr("No aircraft selected") : _launcher.selectedAircraftInfo.name
enabled: _launcher.selectedAircraftInfo.name !== ""
text: {
if (_launcher.skipAircraftFromArgs) return qsTr("<i>set from user arguments (in Settings)</i>");
if (_launcher.selectedAircraftInfo.name === "") return qsTr("No aircraft selected");
return _launcher.selectedAircraftInfo.name;
}
enabled: _launcher.selectedAircraftInfo.name !== "" && !_launcher.skipAircraftFromArgs
font.pixelSize: Style.headingFontPixelSize
onClicked: root.showSelectedAircraft();
@ -166,7 +169,7 @@ Item {
HistoryPopup {
id: aircraftHistoryPopup
model: _launcher.aircraftHistory
enabled: !_launcher.aircraftHistory.isEmpty
enabled: !_launcher.aircraftHistory.isEmpty && !_launcher.skipAircraftFromArgs
onSelected: {
_launcher.selectedAircraft = _launcher.aircraftHistory.uriAt(index)
}
@ -187,12 +190,14 @@ Item {
// empty space in next row (thumbnail, long aircraft description)
Item {
width: 1; height: 1
visible: aircraftDetailsRow.visible
}
Item {
id: aircraftDetailsRow
width: summaryGrid.middleColumnWidth
height: Math.max(thumbnail.height, aircraftDescriptionText.height)
visible: !_launcher.skipAircraftFromArgs
ThumbnailImage {
id: thumbnail
@ -219,6 +224,7 @@ Item {
Item {
width: 1; height: 1
visible: aircraftDetailsRow.visible
}
// aircraft state row, if enabled
@ -229,7 +235,7 @@ Item {
Column {
id: stateSelectionGroup
visible: _launcher.selectedAircraftInfo.hasStates
visible: _launcher.selectedAircraftInfo.hasStates && !_launcher.skipAircraftFromArgs
width: summaryGrid.middleColumnWidth
spacing: Style.margin