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())); static_cast<int>(m_location->guid()));
applyPositionOffset(); applyPositionOffset();
applyAltitude();
} // of navaid location } // of navaid location
} }
void LocationController::applyPositionOffset() 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) { switch (m_altitudeType) {
case Off: case Off:
@ -980,23 +1001,6 @@ void LocationController::applyPositionOffset()
m_config->setArg("altitude", QString::number(m_flightLevel * 100)); m_config->setArg("altitude", QString::number(m_flightLevel * 100));
break; 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() void LocationController::onCollectConfig()
@ -1043,6 +1047,8 @@ void LocationController::onCollectConfig()
if (m_speedEnabled) { if (m_speedEnabled) {
m_config->setArg("vc", QString::number(m_airspeedKnots)); m_config->setArg("vc", QString::number(m_airspeedKnots));
} }
applyAltitude();
} }
} else if (m_airportLocation->type() == FGPositioned::HELIPORT) { } else if (m_airportLocation->type() == FGPositioned::HELIPORT) {
m_config->setArg("runway", QString::fromStdString(m_detailLocation->ident())); m_config->setArg("runway", QString::fromStdString(m_detailLocation->ident()));
@ -1079,6 +1085,7 @@ void LocationController::onCollectConfig()
// set disambiguation property // set disambiguation property
m_config->setProperty("/sim/presets/navaid-id", QString::number(m_location->guid())); m_config->setProperty("/sim/presets/navaid-id", QString::number(m_location->guid()));
applyPositionOffset(); applyPositionOffset();
applyAltitude();
} // of navaid location } // of navaid location
} }

View file

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

View file

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

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 { LocationAltitudeRow
height: childrenRect.height
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; width: parent.width
}
}
} }
// offset row // offset row

View file

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

View file

@ -13,6 +13,13 @@ Item {
implicitHeight: outerRing.height + Style.margin implicitHeight: outerRing.height + Style.margin
implicitWidth: outerRing.width + Style.margin implicitWidth: outerRing.width + Style.margin
function select()
{
if (root.group) {
root.group.selected = root;
}
}
Binding { Binding {
when: root.group != null when: root.group != null
target: root target: root
@ -58,10 +65,7 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
if (root.group) { root.select();
root.group.selected = root;
}
root.clicked() 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/BaseMenuItem.qml</file>
<file>qml/MenuItem.qml</file> <file>qml/MenuItem.qml</file>
<file>qml/MenuDivider.qml</file> <file>qml/MenuDivider.qml</file>
<file>qml/ToggleBox.qml</file>
<file>qml/LocationAltitudeRow.qml</file>
</qresource> </qresource>
<qresource prefix="/preview"> <qresource prefix="/preview">
<file alias="close-icon">preview-close.png</file> <file alias="close-icon">preview-close.png</file>