forked from openlp/openlp
Allow overwriting functions in registry, and use it when registring MainDisplay. Fixes bug 1397287
Fixes: https://launchpad.net/bugs/1397287
This commit is contained in:
parent
e9410de13c
commit
1c71efc532
@ -105,7 +105,7 @@ class Registry(object):
|
|||||||
if key in self.service_list:
|
if key in self.service_list:
|
||||||
del self.service_list[key]
|
del self.service_list[key]
|
||||||
|
|
||||||
def register_function(self, event, function):
|
def register_function(self, event, function, overwrite=False):
|
||||||
"""
|
"""
|
||||||
Register an event and associated function to be called
|
Register an event and associated function to be called
|
||||||
|
|
||||||
@ -113,8 +113,9 @@ class Registry(object):
|
|||||||
will/may need to respond to a single action and the caller does not need to understand or know about the
|
will/may need to respond to a single action and the caller does not need to understand or know about the
|
||||||
recipients.
|
recipients.
|
||||||
:param function: The function to be called when the event happens.
|
:param function: The function to be called when the event happens.
|
||||||
|
:param overwrite: There should only be one function with the registred name.
|
||||||
"""
|
"""
|
||||||
if event in self.functions_list:
|
if not overwrite and event in self.functions_list:
|
||||||
self.functions_list[event].append(function)
|
self.functions_list[event].append(function)
|
||||||
else:
|
else:
|
||||||
self.functions_list[event] = [function]
|
self.functions_list[event] = [function]
|
||||||
|
@ -153,9 +153,9 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||||
self.set_transparency(False)
|
self.set_transparency(False)
|
||||||
if self.is_live:
|
if self.is_live:
|
||||||
Registry().register_function('live_display_hide', self.hide_display)
|
Registry().register_function('live_display_hide', self.hide_display, True)
|
||||||
Registry().register_function('live_display_show', self.show_display)
|
Registry().register_function('live_display_show', self.show_display, True)
|
||||||
Registry().register_function('update_display_css', self.css_changed)
|
Registry().register_function('update_display_css', self.css_changed, True)
|
||||||
|
|
||||||
def set_transparency(self, enabled):
|
def set_transparency(self, enabled):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user