From db4f579ac0e1b40fdb86302ab0178ec1cb82b4e7 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 4 Mar 2024 13:01:25 +0100 Subject: [PATCH] astrodatagui: ask before closing in all occasions --- astrodatagui/AstrodataGUI.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/astrodatagui/AstrodataGUI.py b/astrodatagui/AstrodataGUI.py index 6d9fac0..a2d5655 100644 --- a/astrodatagui/AstrodataGUI.py +++ b/astrodatagui/AstrodataGUI.py @@ -30,8 +30,16 @@ class AstrodataGUI(QtWidgets.QMainWindow): print(title) print(msg) + def closeEvent(self, event): + confirmation = QtWidgets.QMessageBox.question(self, "Confirmation", "Are you sure you want to close the application?", + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) + if confirmation == QtWidgets.QMessageBox.Yes: + event.accept() # Close the app + else: + event.ignore() # Don't close the app + def actionExitTriggered(self): for starDB in StarDB.getAllInstances(): starDB.close() - exit() \ No newline at end of file + self.close() \ No newline at end of file