Commit aa26bcb0 authored by DonLakeFlyer's avatar DonLakeFlyer

parent 1c68e56f
...@@ -196,47 +196,66 @@ ApplicationWindow { ...@@ -196,47 +196,66 @@ ApplicationWindow {
mainWindow.close() 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 { MessageDialog {
id: activeConnectionsCloseDialog id: unsavedMissionCloseDialog
title: qsTr("%1 close").arg(QGroundControl.appName) title: qsTr("%1 close").arg(QGroundControl.appName)
text: qsTr("There are still active connections to vehicles. Are you sure you want to exit?") 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.Cancel standardButtons: StandardButton.Yes | StandardButton.No
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
visible: false visible: false
onYes: finishCloseProcess() onYes: pendingParameterWritesCloseDialog.check()
function check() { function check() {
if (QGroundControl.multiVehicleManager.activeVehicle) { if (planMasterControllerPlan && planMasterControllerPlan.dirty) {
activeConnectionsCloseDialog.open() unsavedMissionCloseDialog.open()
} else { } else {
finishCloseProcess() pendingParameterWritesCloseDialog.check()
} }
} }
} }
//------------------------------------------------------------------------- MessageDialog {
//-- Check for unsaved missions id: pendingParameterWritesCloseDialog
title: qsTr("%1 close").arg(QGroundControl.appName)
onClosing: { text: qsTr("You have pending parameter updates to a vehicle. If you close you will lose changes. Are you sure you want to close?")
// Check first for unsaved missions and active connections standardButtons: StandardButton.Yes | StandardButton.No
if (!_forceClose) { modality: Qt.ApplicationModal
unsavedMissionCloseDialog.check() visible: false
close.accepted = false onYes: activeConnectionsCloseDialog.check()
function check() {
for (var index=0; index<QGroundControl.multiVehicleManager.vehicles.count; index++) {
if (QGroundControl.multiVehicleManager.vehicles.get(index).parameterManager.pendingWrites) {
pendingParameterWritesCloseDialog.open()
return
}
}
activeConnectionsCloseDialog.check()
} }
} }
MessageDialog { MessageDialog {
id: unsavedMissionCloseDialog id: activeConnectionsCloseDialog
title: qsTr("%1 close").arg(QGroundControl.appName) title: qsTr("%1 close").arg(QGroundControl.appName)
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?") text: qsTr("There are still active connections to vehicles. Are you sure you want to exit?")
standardButtons: StandardButton.Yes | StandardButton.No standardButtons: StandardButton.Yes | StandardButton.Cancel
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
visible: false visible: false
onYes: activeConnectionsCloseDialog.check() onYes: finishCloseProcess()
function check() { function check() {
if (planMasterControllerPlan && planMasterControllerPlan.dirty) { if (QGroundControl.multiVehicleManager.activeVehicle) {
unsavedMissionCloseDialog.open() activeConnectionsCloseDialog.open()
} else { } else {
activeConnectionsCloseDialog.check() finishCloseProcess()
} }
} }
} }
......
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