Commit ef046629 authored by Don Gagne's avatar Don Gagne

parent 63680cba
......@@ -743,6 +743,10 @@ void SimpleMissionItem::_setDefaultsForCommand(void)
// No need to carry across previous lat/lon
_missionItem._param5Fact.setRawValue(0);
_missionItem._param6Fact.setRawValue(0);
} else if ((specifiesCoordinate() || isStandaloneCoordinate()) && _missionItem._param5Fact.rawValue().toDouble() == 0 && _missionItem._param6Fact.rawValue().toDouble() == 0) {
// We switched from a command without a coordinate to a command with a coordinate. Use the hint.
_missionItem._param5Fact.setRawValue(_mapCenterHint.latitude());
_missionItem._param6Fact.setRawValue(_mapCenterHint.longitude());
}
// Set global defaults first, then if there are param defaults they will get reset
......
......@@ -49,6 +49,11 @@ public:
Q_PROPERTY(QmlObjectListModel* textFieldFacts READ textFieldFacts CONSTANT)
Q_PROPERTY(QmlObjectListModel* nanFacts READ nanFacts CONSTANT)
/// This should be called before changing the command. It is needed if the command changes
/// from an item which does not include a coordinate to an item which requires a coordinate.
/// It uses this value to set that new coordinate.
Q_INVOKABLE void setMapCenterHintForCommandChange(QGeoCoordinate mapCenter) { _mapCenterHint = mapCenter; };
/// Scans the loaded items for additional section settings
/// @param visualItems List of all visual items
/// @param scanIndex Index to start scanning from
......@@ -162,6 +167,7 @@ private:
bool _rawEdit;
bool _dirty;
bool _ignoreDirtyChangeSignals;
QGeoCoordinate _mapCenterHint;
SpeedSection* _speedSection;
CameraSection* _cameraSection;
......
......@@ -204,7 +204,8 @@ Rectangle {
id: commandDialog
MissionCommandDialog {
missionItem: _root.missionItem
missionItem: _root.missionItem
map: _root.map
}
}
......
......@@ -20,6 +20,7 @@ QGCViewDialog {
id: root
property var missionItem
property var map
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle
......@@ -96,6 +97,7 @@ QGCViewDialog {
MouseArea {
anchors.fill: parent
onClicked: {
missionItem.setMapCenterHintForCommandChange(map.center)
missionItem.command = mavCmdInfo.command
root.reject()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment