1
0
Fork 0

Launcher: don’t set empty METAR

When an invalid custom METAR is entered, don’t pass it to FlightGear
This commit is contained in:
James Turner 2020-12-30 17:01:21 +00:00
parent bcdcef6d2e
commit c478a80c5c

View file

@ -1,4 +1,5 @@
import QtQuick 2.4 import QtQuick 2.4
import QtQml 2.4
import FlightGear.Launcher 1.0 import FlightGear.Launcher 1.0
import "." import "."
@ -150,10 +151,10 @@ Item {
SettingLineEdit { SettingLineEdit {
id: customMETAR id: customMETAR
property bool __cachedValid: true property bool isMETARValid: false
function revalidate() { function revalidate() {
__cachedValid = _launcher.validateMetarString(value); isMETARValid = _launcher.validateMetarString(value);
} }
hidden: !weatherScenario.isCustomMETAR hidden: !weatherScenario.isCustomMETAR
@ -162,7 +163,7 @@ Item {
placeholder: "XXXX 012345Z 28035G50KT 250V300 9999 TSRA SCT022CB BKN030 13/09 Q1005" placeholder: "XXXX 012345Z 28035G50KT 250V300 9999 TSRA SCT022CB BKN030 13/09 Q1005"
useFullWidth: true useFullWidth: true
setting: "custom-metar" setting: "custom-metar"
description: __cachedValid ? qsTr("Enter a custom METAR string, e.g: '%1'").arg(placeholder) description: isMETARValid ? qsTr("Enter a custom METAR string, e.g: '%1'").arg(placeholder)
: qsTr("The entered METAR string doesn't seem to be valid.") : qsTr("The entered METAR string doesn't seem to be valid.")
onValueChanged: { onValueChanged: {
@ -203,7 +204,9 @@ Item {
} }
} else { } else {
if (weatherScenario.isCustomMETAR) { if (weatherScenario.isCustomMETAR) {
if (customMETAR.isMETARValid && (customMETAR.value != "")) {
_config.setArg("metar", customMETAR.value) _config.setArg("metar", customMETAR.value)
}
} else { } else {
_config.setArg("metar", _weatherScenarios.metarForItem(index)) _config.setArg("metar", _weatherScenarios.metarForItem(index))
} }