← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/closeevent into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/closeevent into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/closeevent/+merge/274471

Ignore close event in maindisplay unless it is trigger by OpenLP itself. Ignores ALT+F4 on windows.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/closeevent into lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2015-09-08 19:13:59 +0000
+++ openlp/core/ui/maindisplay.py	2015-10-14 21:44:08 +0000
@@ -173,6 +173,19 @@
             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 @@
             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):


Follow ups