Show warning when quitting while any tabs are active

This commit is contained in:
Micah Lee 2019-10-27 16:18:56 -07:00
parent 654fccc009
commit b7a095d64d
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
4 changed files with 50 additions and 22 deletions

View file

@ -268,8 +268,32 @@ class MainWindow(QtWidgets.QMainWindow):
def closeEvent(self, e):
self.common.log("MainWindow", "closeEvent")
if self.tabs.are_tabs_active():
# Open the warning dialog
dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle(strings._("gui_quit_warning_title"))
dialog.setText(strings._("gui_quit_warning_description"))
dialog.setIcon(QtWidgets.QMessageBox.Critical)
dialog.addButton(
strings._("gui_quit_warning_quit"), QtWidgets.QMessageBox.YesRole
)
cancel_button = dialog.addButton(
strings._("gui_quit_warning_cancel"), QtWidgets.QMessageBox.NoRole
)
dialog.setDefaultButton(cancel_button)
reply = dialog.exec_()
# Close
if reply == 0:
self.system_tray.hide()
e.accept()
# Cancel
else:
e.ignore()
return
self.system_tray.hide()
# TODO: Run the tab's close_event
e.accept()
def cleanup(self):