diff --git a/openlp/core/display/window.py b/openlp/core/display/window.py index 4fb471eee..aa5825e37 100644 --- a/openlp/core/display/window.py +++ b/openlp/core/display/window.py @@ -424,9 +424,6 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin): if self.isHidden(): self.setVisible(True) self.hide_mode = None - # Trigger actions when display is active again. - if self.is_display: - Registry().execute('live_display_active') def hide_display(self, mode=HideMode.Screen): """ diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 101909635..2a1998d05 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -26,7 +26,6 @@ import json from PyQt5 import QtCore, QtGui -from openlp.core.common.i18n import translate from openlp.core.common.mixins import LogMixin, RegistryProperties from openlp.core.common.registry import Registry, RegistryBase from openlp.core.display.screens import ScreenList @@ -40,9 +39,6 @@ class AlertsManager(QtCore.QObject, RegistryBase, LogMixin, RegistryProperties): def __init__(self, parent): super(AlertsManager, self).__init__() - self.timer_id = 0 - self.alert_list = [] - Registry().register_function('live_display_active', self.generate_alert) Registry().register_function('alerts_text', self.alert_text) self.alerts_text.connect(self.alert_text) @@ -65,56 +61,25 @@ class AlertsManager(QtCore.QObject, RegistryBase, LogMixin, RegistryProperties): :param text: The text to display """ - self.log_debug('display alert called {text}'.format(text=text)) - if text: - self.alert_list.append(text) - if self.timer_id != 0: - self.main_window.show_status_message( - translate('AlertsPlugin.AlertsManager', 'Alert message created and displayed.')) - return - self.main_window.show_status_message('') - self.generate_alert() - - def generate_alert(self): - """ - Format and request the Alert and start the timer. - """ - if not self.alert_list or (len(ScreenList()) == 1 and - not self.settings.value('core/display on monitor')): + self.log_debug(f'display alert called "{text}"') + if not text: + return + if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'): return - text = self.alert_list.pop(0) - - # Get the rgb color format of the font & background hex colors from settings - rgb_font_color = self.hex_to_rgb(QtGui.QColor(self.settings.value('alerts/font color'))) - rgb_background_color = self.hex_to_rgb(QtGui.QColor(self.settings.value('alerts/background color'))) - # Put alert settings together in dict that will be passed to Display in Javascript alert_settings = { - 'backgroundColor': rgb_background_color, + 'backgroundColor': self._hex_to_rgb(QtGui.QColor(self.settings.value('alerts/background color'))), 'location': self.settings.value('alerts/location'), 'fontFace': self.settings.value('alerts/font face'), 'fontSize': self.settings.value('alerts/font size'), - 'fontColor': rgb_font_color, + 'fontColor': self._hex_to_rgb(QtGui.QColor(self.settings.value('alerts/font color'))), 'timeout': self.settings.value('alerts/timeout'), 'repeat': self.settings.value('alerts/repeat'), 'scroll': self.settings.value('alerts/scroll') } - self.live_controller.displays[0].alert(text, json.dumps(alert_settings)) + self.live_controller.display.alert(text, json.dumps(alert_settings)) - def timerEvent(self, event): - """ - Time has finished so if our time then request the next Alert if there is one and reset the timer. - - :param event: the QT event that has been triggered. - """ - if event.timerId() == self.timer_id: - alert_tab = self.parent().settings_tab - self.live_controller.display.alert('', alert_tab.location) - self.killTimer(self.timer_id) - self.timer_id = 0 - self.generate_alert() - - def hex_to_rgb(self, rgb_values): + def _hex_to_rgb(self, rgb_values): """ Converts rgb color values from QColor to rgb string diff --git a/tests/openlp_core/display/test_window.py b/tests/openlp_core/display/test_window.py index 2b43f0f8e..fd5ab42b8 100644 --- a/tests/openlp_core/display/test_window.py +++ b/tests/openlp_core/display/test_window.py @@ -483,7 +483,6 @@ def test_show_display(mocked_screenlist, mocked_registry_execute, display_window # THEN: Should show the display and set the hide mode to none display_window.setVisible.assert_called_once_with(True) display_window.run_javascript.assert_called_once_with('Display.show();') - mocked_registry_execute.assert_called_once_with('live_display_active') @patch('openlp.core.display.window.ScreenList')