From 949bf4a8a78bf6e6d5e4e22e7c63ccef7aebde51 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 13 Oct 2015 22:52:33 +0100 Subject: [PATCH] Ignore close event in maindisplay unless it is trigger by OpenLP itself. Ignores ALT+F4 on windows. --- openlp/core/ui/maindisplay.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 61e43d161..d59090d40 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -173,6 +173,19 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): Registry().register_function('live_display_hide', self.hide_display) Registry().register_function('live_display_show', self.show_display) Registry().register_function('update_display_css', self.css_changed) + self.close_display = False + + def closeEvent(self, event): + """ + Catch the close event, and check that the close event is triggered by OpenLP closing the display. + On Windows this event can be triggered by pressing ALT+F4, which we want to ignore. + + :param event: The triggered event + """ + if self.close_display: + super().closeEvent(event) + else: + event.ignore() def close(self): """ @@ -182,6 +195,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): Registry().remove_function('live_display_hide', self.hide_display) Registry().remove_function('live_display_show', self.show_display) Registry().remove_function('update_display_css', self.css_changed) + self.close_display = True super().close() def set_transparency(self, enabled):