From aa26bcb009c31aefd81ac78ccc6ecb221c255929 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 9 Nov 2019 21:27:28 -0800 Subject: [PATCH] Check for pending param writes on app close --- src/ui/MainRootWindow.qml | 63 +++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml index 8111f221a..0468d92cb 100644 --- a/src/ui/MainRootWindow.qml +++ b/src/ui/MainRootWindow.qml @@ -196,47 +196,66 @@ ApplicationWindow { mainWindow.close() } + // On attempting an application close we check for: + // Unsaved missions - then + // Pending parameter writes - then + // Active connections + onClosing: { + if (!_forceClose) { + unsavedMissionCloseDialog.check() + close.accepted = false + } + } + MessageDialog { - id: activeConnectionsCloseDialog + id: unsavedMissionCloseDialog title: qsTr("%1 close").arg(QGroundControl.appName) - text: qsTr("There are still active connections to vehicles. Are you sure you want to exit?") - standardButtons: StandardButton.Yes | StandardButton.Cancel + text: qsTr("You have a mission edit in progress which has not been saved/sent. If you close you will lose changes. Are you sure you want to close?") + standardButtons: StandardButton.Yes | StandardButton.No modality: Qt.ApplicationModal visible: false - onYes: finishCloseProcess() + onYes: pendingParameterWritesCloseDialog.check() function check() { - if (QGroundControl.multiVehicleManager.activeVehicle) { - activeConnectionsCloseDialog.open() + if (planMasterControllerPlan && planMasterControllerPlan.dirty) { + unsavedMissionCloseDialog.open() } else { - finishCloseProcess() + pendingParameterWritesCloseDialog.check() } } } - //------------------------------------------------------------------------- - //-- Check for unsaved missions - - onClosing: { - // Check first for unsaved missions and active connections - if (!_forceClose) { - unsavedMissionCloseDialog.check() - close.accepted = false + MessageDialog { + id: pendingParameterWritesCloseDialog + title: qsTr("%1 close").arg(QGroundControl.appName) + text: qsTr("You have pending parameter updates to a vehicle. If you close you will lose changes. Are you sure you want to close?") + standardButtons: StandardButton.Yes | StandardButton.No + modality: Qt.ApplicationModal + visible: false + onYes: activeConnectionsCloseDialog.check() + function check() { + for (var index=0; index