1
0
Fork 0

Launcher: altitude entry for runway-approach

This commit is contained in:
James Turner 2018-07-02 16:45:17 +01:00
parent f76be60459
commit 08c7707782
9 changed files with 205 additions and 134 deletions

View file

@ -958,10 +958,31 @@ void LocationController::setLocationProperties()
static_cast<int>(m_location->guid()));
applyPositionOffset();
applyAltitude();
} // of navaid location
}
void LocationController::applyPositionOffset()
{
if (m_speedEnabled) {
m_config->setArg("vc", QString::number(m_airspeedKnots));
}
if (m_headingEnabled) {
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
// command-line compatability so compensating here instead
int offsetAzimuth = m_offsetRadial - 180;
m_config->setArg("offset-azimuth", QString::number(offsetAzimuth));
m_config->setArg("offset-distance", QString::number(m_offsetNm));
}
}
void LocationController::applyAltitude()
{
switch (m_altitudeType) {
case Off:
@ -980,23 +1001,6 @@ void LocationController::applyPositionOffset()
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));
}
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
// command-line compatability so compensating here instead
int offsetAzimuth = m_offsetRadial - 180;
m_config->setArg("offset-azimuth", QString::number(offsetAzimuth));
m_config->setArg("offset-distance", QString::number(m_offsetNm));
}
}
void LocationController::onCollectConfig()
@ -1043,6 +1047,8 @@ void LocationController::onCollectConfig()
if (m_speedEnabled) {
m_config->setArg("vc", QString::number(m_airspeedKnots));
}
applyAltitude();
}
} else if (m_airportLocation->type() == FGPositioned::HELIPORT) {
m_config->setArg("runway", QString::fromStdString(m_detailLocation->ident()));
@ -1079,6 +1085,7 @@ void LocationController::onCollectConfig()
// set disambiguation property
m_config->setProperty("/sim/presets/navaid-id", QString::number(m_location->guid()));
applyPositionOffset();
applyAltitude();
} // of navaid location
}

View file

@ -211,6 +211,7 @@ private:
void setNavRadioOption();
void applyPositionOffset();
void applyAltitude();
NavSearchModel* m_searchModel = nullptr;

View file

@ -35,12 +35,11 @@ Item {
// not very declarative, try to remove this over time
function syncUIFromController()
{
runwayRadio.selected = (_location.detail.isRunwayType);
parkingRadio.selected = (_location.detail.type == Positioned.Parking);
if (_location.detail.isRunwayType) {
runwayRadio.select();
runwayChoice.syncCurrentIndex();
} else if (_location.detail.type == Positioned.Parking) {
parkingRadio.select()
parkingChoice.syncCurrentIndex();
}
}
@ -59,6 +58,7 @@ Item {
color: "transparent"
border.width: 1
border.color: Style.frameColor
clip: true
anchors {
left: parent.left
@ -154,73 +154,91 @@ Item {
}
}
// runway offset row
Row {
x: Style.strutSize
// runway offset
ToggleBox {
id: onFinalBox
anchors.left: parent.left
anchors.leftMargin: Style.strutSize
height: onFinalContents.height + onFinalContents.y + Style.margin
anchors.right: parent.right
anchors.rightMargin: Style.margin
// no offset for helipads
visible: !isHeliport
readonly property bool enableOnFinal: runwayRadio.selected && _location.onFinal
enabled: runwayRadio.selected
selected: _location.onFinal
ToggleSwitch {
id: onFinalToggle
label: qsTr("On final approach at ")
anchors.verticalCenter: parent.verticalCenter
checked: _location.onFinal
enabled:runwayRadio.selected
onCheckedChanged: _location.onFinal = checked
}
label: qsTr("On final approach")
DoubleSpinbox {
id: offsetNmEdit
value: _location.offsetNm
onCommit: _location.offsetNm = newValue;
onSelectedChanged: _location.onFinal = selected
readonly property bool enableOnFinal: enabled && selected
suffix: "Nm"
min: 0.0
max: 40.0
decimals: 1
maxDigits: 5
live: true
Column {
id: onFinalContents
y: parent.contentVerticalOffset
spacing: Style.margin
width: parent.width
anchors.verticalCenter: parent.verticalCenter
enabled: parent.enableOnFinal
}
Row {
height: offsetNmEdit.height
DoubleSpinbox {
id: offsetNmEdit
value: _location.offsetNm
onCommit: _location.offsetNm = newValue;
label: qsTr("At")
suffix: "Nm"
min: 0.0
max: 40.0
decimals: 1
maxDigits: 5
live: true
anchors.verticalCenter: parent.verticalCenter
enabled: onFinalBox.enableOnFinal
}
StyledText {
text: qsTr(" from the threshold")
anchors.verticalCenter: parent.verticalCenter
enabled: parent.enableOnFinal
}
StyledText {
text: qsTr(" from the threshold")
anchors.verticalCenter: parent.verticalCenter
enabled: onFinalBox.enableOnFinal
}
Item {
// padding
width: Style.strutSize
height: 1
}
Item {
height: 1; width: Style.strutSize
}
ToggleSwitch {
id: airspeedToggle
enabled: parent.enableOnFinal
checked: _location.speedEnabled
onCheckedChanged: _location.speedEnabled = checked;
anchors.verticalCenter: parent.verticalCenter
}
ToggleSwitch {
id: airspeedToggle
enabled: onFinalBox.enableOnFinal
checked: _location.speedEnabled
onCheckedChanged: _location.speedEnabled = checked;
anchors.verticalCenter: parent.verticalCenter
}
IntegerSpinbox {
id: airspeedSpinbox
label: qsTr("Airspeed:")
suffix: "kts"
min: 0
max: 10000 // more for spaceships?
step: 5
maxDigits: 5
enabled: _location.speedEnabled && onFinalBox.enableOnFinal
value: _location.airspeedKnots
onCommit: _location.airspeedKnots = newValue
anchors.verticalCenter: parent.verticalCenter
}
}
LocationAltitudeRow
{
enabled: onFinalBox.enableOnFinal
width: parent.width
}
} // of column
} // of runway offset group
IntegerSpinbox {
label: qsTr("Airspeed:")
suffix: "kts"
min: 0
max: 10000 // more for spaceships?
step: 5
maxDigits: 5
enabled: _location.speedEnabled && parent.enableOnFinal
value: _location.airspeedKnots
onCommit: _location.airspeedKnots = newValue
anchors.verticalCenter: parent.verticalCenter
}
}
ToggleSwitch {
x: Style.strutSize

View file

@ -0,0 +1,66 @@
import QtQuick 2.4
import "."
import FlightGear.Launcher 1.0
Row {
id: root
height: childrenRect.height
spacing: Style.margin
property bool enabled: true
ToggleSwitch {
id: altitudeToggle
checked: _location.altitudeType !== LocationController.Off
function toggle(newChecked) {
_location.altitudeType = (newChecked ? LocationController.MSL_Feet
: LocationController.Off)
}
enabled: parent.enabled
}
readonly property bool __rowEnabled: root.enabled && altitudeToggle.checked
IntegerSpinbox {
label: qsTr("Altitude:")
suffix: "ft"
min: -1000 // Dead Sea, Schiphol
max: 200000
step: 100
maxDigits: 6
enabled: __rowEnabled
visible: !altitudeTypeChoice.isFlightLevel
value: _location.altitudeFt
onCommit: _location.altitudeFt = newValue
}
IntegerSpinbox {
label: qsTr("Altitude:")
prefix: "FL"
min: 0
max: 1000
step: 10
maxDigits: 3
enabled: __rowEnabled
visible: altitudeTypeChoice.isFlightLevel
value: _location.flightLevel
onCommit: _location.flightLevel = newValue
}
PopupChoice {
id: altitudeTypeChoice
enabled: __rowEnabled && (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;
}
}
}

View file

@ -120,62 +120,9 @@ Item {
}
}
Row {
height: childrenRect.height
LocationAltitudeRow
{
width: parent.width
spacing: Style.margin
ToggleSwitch {
id: altitudeToggle
checked: _location.altitudeType !== LocationController.Off
function toggle(newChecked) {
_location.altitudeType = (newChecked ? LocationController.MSL_Feet
: LocationController.Off)
}
}
IntegerSpinbox {
label: qsTr("Altitude:")
suffix: "ft"
min: -1000 // Dead Sea, Schiphol
max: 200000
step: 100
maxDigits: 6
enabled: altitudeToggle.checked
visible: !altitudeTypeChoice.isFlightLevel
value: _location.altitudeFt
onCommit: _location.altitudeFt = newValue
}
IntegerSpinbox {
label: qsTr("Altitude:")
prefix: "FL"
min: 0
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

View file

@ -96,6 +96,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
StyledText {
enabled: root.enabled
id: currentChoiceText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left

View file

@ -13,6 +13,13 @@ Item {
implicitHeight: outerRing.height + Style.margin
implicitWidth: outerRing.width + Style.margin
function select()
{
if (root.group) {
root.group.selected = root;
}
}
Binding {
when: root.group != null
target: root
@ -58,10 +65,7 @@ Item {
anchors.fill: parent
hoverEnabled: true
onClicked: {
if (root.group) {
root.group.selected = root;
}
root.select();
root.clicked()
}
}

25
src/GUI/qml/ToggleBox.qml Normal file
View file

@ -0,0 +1,25 @@
import QtQuick 2.4
import "."
Item {
property bool enabled: true
property alias label: switchToggle.label
property alias selected: switchToggle.checked
readonly property int contentVerticalOffset: switchToggle.height + Style.margin
readonly property int __lineTop: switchToggle.height * 0.5
ToggleSwitch {
enabled: parent.enabled
id: switchToggle
x: Style.strutSize
}
readonly property string lineColor: enabled ? Style.themeColor : Style.disabledThemeColor
// we want to show a border, but with a cut out. Easiest is to use
// 1px rectangles as lines
Rectangle { height: 1; color: lineColor; y: __lineTop; width: switchToggle.x }
Rectangle { height: 1; color: lineColor; y: __lineTop; anchors { left: switchToggle.right; right: parent.right;} }
Rectangle { height: 1; color: lineColor; width: parent.width; anchors.bottom: parent.bottom }
}

View file

@ -104,6 +104,8 @@
<file>qml/BaseMenuItem.qml</file>
<file>qml/MenuItem.qml</file>
<file>qml/MenuDivider.qml</file>
<file>qml/ToggleBox.qml</file>
<file>qml/LocationAltitudeRow.qml</file>
</qresource>
<qresource prefix="/preview">
<file alias="close-icon">preview-close.png</file>