Skip to content

Commit 7c50572

Browse files
committed
Restore previous Go here map item on cancellation
Added logic to commit and revert coordinate changes for the Go here map item. Updated the Go To action handlers to utilize this logic, allowing the previous Go here item to be restored when a Go To action is cancelled.
1 parent ee7bc77 commit 7c50572

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/FlightDisplay/FlyViewMap.qml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,20 @@ FlightMap {
394394

395395
property bool inGotoFlightMode: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.gotoFlightMode : false
396396

397+
property var _committedCoordinate: null
398+
397399
onInGotoFlightModeChanged: {
398400
if (!inGotoFlightMode && gotoLocationItem.visible) {
399401
// Hide goto indicator when vehicle falls out of guided mode
400-
gotoLocationItem.visible = false
402+
hide()
401403
}
402404
}
403405

404406
Connections {
405407
target: QGroundControl.multiVehicleManager
406408
function onActiveVehicleChanged(activeVehicle) {
407409
if (!activeVehicle) {
408-
gotoLocationItem.visible = false
410+
hide()
409411
}
410412
}
411413
}
@@ -420,11 +422,29 @@ FlightMap {
420422
}
421423

422424
function actionConfirmed() {
425+
_commitCoordinate()
426+
423427
// We leave the indicator visible. The handling for onInGuidedModeChanged will hide it.
424428
}
425429

426430
function actionCancelled() {
427-
hide()
431+
_restoreCoordinate()
432+
}
433+
434+
function _commitCoordinate() {
435+
// Must deep copy
436+
_committedCoordinate = QtPositioning.coordinate(
437+
coordinate.latitude,
438+
coordinate.longitude
439+
);
440+
}
441+
442+
function _restoreCoordinate() {
443+
if (_committedCoordinate) {
444+
coordinate = _committedCoordinate
445+
} else {
446+
hide()
447+
}
428448
}
429449
}
430450

0 commit comments

Comments
 (0)