Skip to content

Commit 2cdb79b

Browse files
rubenp02DonLakeFlyer
authored andcommitted
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 390bbfc commit 2cdb79b

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
@@ -383,18 +383,20 @@ FlightMap {
383383

384384
property bool inGotoFlightMode: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.gotoFlightMode : false
385385

386+
property var _committedCoordinate: null
387+
386388
onInGotoFlightModeChanged: {
387389
if (!inGotoFlightMode && gotoLocationItem.visible) {
388390
// Hide goto indicator when vehicle falls out of guided mode
389-
gotoLocationItem.visible = false
391+
hide()
390392
}
391393
}
392394

393395
Connections {
394396
target: QGroundControl.multiVehicleManager
395397
function onActiveVehicleChanged(activeVehicle) {
396398
if (!activeVehicle) {
397-
gotoLocationItem.visible = false
399+
hide()
398400
}
399401
}
400402
}
@@ -409,11 +411,29 @@ FlightMap {
409411
}
410412

411413
function actionConfirmed() {
414+
_commitCoordinate()
415+
412416
// We leave the indicator visible. The handling for onInGuidedModeChanged will hide it.
413417
}
414418

415419
function actionCancelled() {
416-
hide()
420+
_restoreCoordinate()
421+
}
422+
423+
function _commitCoordinate() {
424+
// Must deep copy
425+
_committedCoordinate = QtPositioning.coordinate(
426+
coordinate.latitude,
427+
coordinate.longitude
428+
);
429+
}
430+
431+
function _restoreCoordinate() {
432+
if (_committedCoordinate) {
433+
coordinate = _committedCoordinate
434+
} else {
435+
hide()
436+
}
417437
}
418438
}
419439

0 commit comments

Comments
 (0)