Launcher: optional alt/spd/hdg select
Bring this feature up to parity with the release branch.
This commit is contained in:
parent
198f9ccb70
commit
240ac0f458
5 changed files with 141 additions and 22 deletions
|
@ -681,9 +681,20 @@ void LocationController::restoreLocation(QVariantMap l)
|
|||
}
|
||||
}
|
||||
|
||||
m_altitudeFt = l.value("altitude", 6000).toInt();
|
||||
if (l.contains("altitude-type")) {
|
||||
m_altitudeFt = l.value("altitude", 6000).toInt();
|
||||
m_flightLevel = l.value("flight-level").toInt();
|
||||
m_altitudeType = static_cast<AltitudeType>(l.value("altitude-type").toInt());
|
||||
} else {
|
||||
m_altitudeType = Off;
|
||||
}
|
||||
|
||||
m_speedEnabled = l.contains("speed");
|
||||
m_headingEnabled = l.contains("heading");
|
||||
|
||||
m_airspeedKnots = l.value("speed", 120).toInt();
|
||||
m_headingDeg = l.value("heading").toInt();
|
||||
|
||||
m_offsetEnabled = l.value("offset-enabled").toBool();
|
||||
m_offsetRadial = l.value("offset-bearing").toInt();
|
||||
m_offsetNm = l.value("offset-distance", 10).toInt();
|
||||
|
@ -752,11 +763,30 @@ QVariantMap LocationController::saveLocation() const
|
|||
} // of location is an airport
|
||||
} // of m_location is valid
|
||||
|
||||
locationSet.insert("altitude", m_altitudeFt);
|
||||
locationSet.insert("speed", m_airspeedKnots);
|
||||
locationSet.insert("offset-enabled", m_offsetEnabled);
|
||||
locationSet.insert("offset-bearing", m_offsetRadial);
|
||||
locationSet.insert("offset-distance",m_offsetNm);
|
||||
if (m_altitudeType != Off) {
|
||||
if ((m_altitudeType == MSL_Feet) || (m_altitudeType == AGL_Feet)) {
|
||||
locationSet.insert("altitude", m_altitudeFt);
|
||||
}
|
||||
|
||||
if (m_altitudeType == FlightLevel) {
|
||||
locationSet.insert("flight-level", m_flightLevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_speedEnabled) {
|
||||
locationSet.insert("speed", m_airspeedKnots);
|
||||
}
|
||||
|
||||
if (m_headingEnabled) {
|
||||
locationSet.insert("heading", m_headingDeg);
|
||||
}
|
||||
|
||||
if (m_offsetEnabled) {
|
||||
locationSet.insert("offset-enabled", m_offsetEnabled);
|
||||
locationSet.insert("offset-bearing", m_offsetRadial);
|
||||
locationSet.insert("offset-distance",m_offsetNm);
|
||||
}
|
||||
|
||||
locationSet.insert("text", description());
|
||||
locationSet.insert("tune-nav1-radio", m_tuneNAV1);
|
||||
|
||||
|
@ -874,13 +904,32 @@ void LocationController::setLocationProperties()
|
|||
|
||||
void LocationController::applyPositionOffset()
|
||||
{
|
||||
if (m_altitudeFt > 0) {
|
||||
switch (m_altitudeType) {
|
||||
case Off:
|
||||
break;
|
||||
case MSL_Feet:
|
||||
m_config->setArg("altitude", QString::number(m_altitudeFt));
|
||||
break;
|
||||
|
||||
case AGL_Feet:
|
||||
// fixme - allow the sim to accpet AGL start position
|
||||
m_config->setArg("altitude", QString::number(m_altitudeFt));
|
||||
break;
|
||||
|
||||
case FlightLevel:
|
||||
// FIXME - allow the sim to accept real FlightLevel arguments
|
||||
m_config->setArg("altitude", QString::number(m_flightLevel * 100));
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_speedEnabled) {
|
||||
m_config->setArg("vc", QString::number(m_airspeedKnots));
|
||||
}
|
||||
|
||||
if (m_headingEnabled) {
|
||||
m_config->setArg("heading", QString::number(m_headingDeg));
|
||||
}
|
||||
|
||||
m_config->setArg("vc", QString::number(m_airspeedKnots));
|
||||
m_config->setArg("heading", QString::number(m_headingDeg));
|
||||
|
||||
if (m_offsetEnabled) {
|
||||
// flip direction of azimuth to balance the flip done in fgApplyStartOffset
|
||||
// I don't know why that flip exists but changing it there will break
|
||||
|
|
|
@ -48,8 +48,15 @@ class LocationController : public QObject
|
|||
Q_PROPERTY(bool offsetBearingIsTrue MEMBER m_offsetBearingIsTrue NOTIFY offsetChanged)
|
||||
Q_PROPERTY(double offsetNm READ offsetNm WRITE setOffsetNm NOTIFY offsetChanged)
|
||||
|
||||
Q_PROPERTY(bool headingEnabled MEMBER m_headingEnabled NOTIFY configChanged)
|
||||
Q_PROPERTY(bool speedEnabled MEMBER m_speedEnabled NOTIFY configChanged)
|
||||
|
||||
Q_PROPERTY(AltitudeType altitudeType MEMBER m_altitudeType NOTIFY configChanged)
|
||||
|
||||
Q_PROPERTY(int headingDeg MEMBER m_headingDeg NOTIFY configChanged)
|
||||
Q_PROPERTY(int altitudeFt MEMBER m_altitudeFt NOTIFY configChanged)
|
||||
Q_PROPERTY(int flightLevel MEMBER m_flightLevel NOTIFY configChanged)
|
||||
|
||||
Q_PROPERTY(int airspeedKnots MEMBER m_airspeedKnots NOTIFY configChanged)
|
||||
Q_PROPERTY(bool onFinal READ onFinal WRITE setOnFinal NOTIFY configChanged)
|
||||
|
||||
|
@ -65,6 +72,16 @@ public:
|
|||
explicit LocationController(QObject *parent = nullptr);
|
||||
~LocationController();
|
||||
|
||||
enum AltitudeType
|
||||
{
|
||||
Off = 0,
|
||||
MSL_Feet,
|
||||
AGL_Feet,
|
||||
FlightLevel
|
||||
};
|
||||
|
||||
Q_ENUMS(AltitudeType)
|
||||
|
||||
void setLaunchConfig(LaunchConfig* config);
|
||||
|
||||
QString description() const;
|
||||
|
@ -192,12 +209,16 @@ private:
|
|||
double m_offsetNm = 0.0;
|
||||
bool m_offsetBearingIsTrue = false;
|
||||
int m_headingDeg = 0;
|
||||
int m_altitudeFt= -9999;
|
||||
int m_airspeedKnots = 120;
|
||||
int m_altitudeFt= 0;
|
||||
int m_airspeedKnots = 150;
|
||||
bool m_onFinal = false;
|
||||
bool m_useActiveRunway = true;
|
||||
bool m_tuneNAV1;
|
||||
bool m_tuneNAV1 = false;
|
||||
bool m_useAvailableParking;
|
||||
bool m_headingEnabled = false;
|
||||
bool m_speedEnabled = false;
|
||||
AltitudeType m_altitudeType = Off;
|
||||
int m_flightLevel = 0;
|
||||
};
|
||||
|
||||
#endif // LOCATION_CONTROLLER_HXX
|
||||
|
|
|
@ -73,6 +73,10 @@ void RecentLocationsModel::insert(QVariant location)
|
|||
[locDesc](QVariant v) { return v.toMap().value("text") == locDesc; });
|
||||
if (!m_data.empty() && (it == m_data.begin())) {
|
||||
// special, common case - nothing to do
|
||||
// we use the description to determine equality,
|
||||
// but it doesn't mention altitude/speed/heading so always
|
||||
// update the actual stored value
|
||||
*it = location;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,16 @@ Item {
|
|||
width: parent.width
|
||||
|
||||
Text { // heading text
|
||||
visible: navaidData.valid
|
||||
id: heading
|
||||
id: headingText
|
||||
width: parent.width
|
||||
text: "Navaid: " + navaidData.ident + " / " + navaidData.name
|
||||
text: "format lat-lon as string!"
|
||||
|
||||
Binding {
|
||||
when: navaidData.valid
|
||||
target: headingText
|
||||
property: "text"
|
||||
value: "Navaid: " + navaidData.ident + " / " + navaidData.name
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
|
@ -69,6 +75,12 @@ Item {
|
|||
width: parent.width
|
||||
spacing: Style.margin
|
||||
|
||||
ToggleSwitch {
|
||||
id: airspeedToggle
|
||||
checked: _location.speedEnabled
|
||||
onCheckedChanged: _location.speedEnabled = checked;
|
||||
}
|
||||
|
||||
IntegerSpinbox {
|
||||
label: qsTr("Airspeed:")
|
||||
suffix: "kts"
|
||||
|
@ -76,10 +88,23 @@ Item {
|
|||
max: 10000 // more for spaceships?
|
||||
step: 5
|
||||
maxDigits: 5
|
||||
enabled: _location.speedEnabled
|
||||
value: _location.airspeedKnots
|
||||
onCommit: _location.airspeedKnots = newValue
|
||||
}
|
||||
|
||||
Item {
|
||||
// padding
|
||||
width: Style.strutSize
|
||||
height: 1
|
||||
}
|
||||
|
||||
ToggleSwitch {
|
||||
id: headingToggle
|
||||
checked: _location.headingEnabled
|
||||
onCheckedChanged: _location.headingEnabled = checked;
|
||||
}
|
||||
|
||||
IntegerSpinbox {
|
||||
label: qsTr("Heading:")
|
||||
suffix: "deg" // FIXME use Unicode degree symbol
|
||||
|
@ -87,6 +112,7 @@ Item {
|
|||
max: 359
|
||||
live: true
|
||||
maxDigits: 3
|
||||
enabled: _location.headingEnabled
|
||||
value: _location.headingDeg
|
||||
onCommit: _location.headingDeg = newValue
|
||||
}
|
||||
|
@ -97,6 +123,13 @@ Item {
|
|||
width: parent.width
|
||||
spacing: Style.margin
|
||||
|
||||
ToggleSwitch {
|
||||
id: altitudeToggle
|
||||
checked: _location.altitudeType !== LocationController.Off
|
||||
onCheckedChanged: _location.altitudeType = (checked ? LocationController.MSL_Feet
|
||||
: LocationController.Off)
|
||||
}
|
||||
|
||||
IntegerSpinbox {
|
||||
label: qsTr("Altitude:")
|
||||
suffix: "ft"
|
||||
|
@ -104,7 +137,7 @@ Item {
|
|||
max: 200000
|
||||
step: 100
|
||||
maxDigits: 6
|
||||
|
||||
enabled: altitudeToggle.checked
|
||||
visible: !altitudeTypeChoice.isFlightLevel
|
||||
value: _location.altitudeFt
|
||||
onCommit: _location.altitudeFt = newValue
|
||||
|
@ -117,24 +150,31 @@ Item {
|
|||
max: 1000
|
||||
step: 10
|
||||
maxDigits: 3
|
||||
enabled: altitudeToggle.checked
|
||||
visible: altitudeTypeChoice.isFlightLevel
|
||||
value: _location.flightLevel
|
||||
onCommit: _location.flightLevel = newValue
|
||||
}
|
||||
|
||||
PopupChoice {
|
||||
id: altitudeTypeChoice
|
||||
|
||||
enabled: _location.altitudeType !== LocationController.Off
|
||||
currentIndex: Math.max(0, _location.altitudeType - 1)
|
||||
readonly property bool isFlightLevel: (currentIndex == 2)
|
||||
|
||||
model: [qsTr("Above mean sea-level (MSL)"),
|
||||
qsTr("Above ground (AGL)"),
|
||||
qsTr("Flight-level")]
|
||||
|
||||
function select(index)
|
||||
{
|
||||
_location.altitudeType = index + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// offset row
|
||||
Row {
|
||||
x: Style.strutSize
|
||||
|
||||
ToggleSwitch {
|
||||
id: offsetToggle
|
||||
label: qsTr("Offset ")
|
||||
|
|
|
@ -20,6 +20,11 @@ Item {
|
|||
implicitHeight: Math.max(label.implicitHeight, currentChoiceFrame.height)
|
||||
implicitWidth: label.implicitWidth + Style.margin + currentChoiceFrame.__naturalWidth
|
||||
|
||||
function select(index)
|
||||
{
|
||||
root.currentIndex = index;
|
||||
}
|
||||
|
||||
Item {
|
||||
Repeater {
|
||||
id: internalModel
|
||||
|
@ -181,8 +186,8 @@ Item {
|
|||
height: parent.height
|
||||
z: -1 // so header can do other mouse behaviours
|
||||
onClicked: {
|
||||
root.currentIndex = -1;
|
||||
popupFrame.visible = false
|
||||
root.select(-1);
|
||||
}
|
||||
}
|
||||
} // of header loader
|
||||
|
@ -206,8 +211,8 @@ Item {
|
|||
width: popupFrame.width // full width of the popup
|
||||
height: parent.height
|
||||
onClicked: {
|
||||
root.currentIndex = model.index
|
||||
popupFrame.visible = false
|
||||
root.select(model.index)
|
||||
}
|
||||
}
|
||||
} // of Text delegate
|
||||
|
|
Loading…
Add table
Reference in a new issue