forked from openlp/openlp
Clean up Alerts
This commit is contained in:
parent
743ad7b44a
commit
68d8f58b5c
|
@ -35,6 +35,9 @@ from openlp.core.lib.ui import create_button, create_button_box
|
|||
|
||||
|
||||
class Ui_AlertDialog(object):
|
||||
"""
|
||||
Alert UI Class
|
||||
"""
|
||||
def setupUi(self, alert_dialog):
|
||||
"""
|
||||
Setup the Alert UI dialog
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.core.common import Registry, translate
|
||||
from openlp.plugins.alerts.lib.db import AlertItem
|
||||
|
||||
from .alertdialog import Ui_AlertDialog
|
||||
|
@ -46,8 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
|||
self.manager = plugin.manager
|
||||
self.plugin = plugin
|
||||
self.item_id = None
|
||||
# TODO: Use Registry()
|
||||
super(AlertForm, self).__init__(self.plugin.main_window)
|
||||
super(AlertForm, self).__init__( Registry().get('main_window'))
|
||||
self.setupUi(self)
|
||||
self.display_button.clicked.connect(self.on_display_clicked)
|
||||
self.display_close_button.clicked.connect(self.on_display_close_clicked)
|
||||
|
|
|
@ -31,25 +31,17 @@ The :mod:`~openlp.plugins.alerts.lib.alertsmanager` module contains the part of
|
|||
displaying of alerts.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.common import Registry, translate
|
||||
from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, translate
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AlertsManager(QtCore.QObject):
|
||||
class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject):
|
||||
"""
|
||||
AlertsManager manages the settings of Alerts.
|
||||
"""
|
||||
log.info('Alert Manager loaded')
|
||||
|
||||
def __init__(self, parent):
|
||||
super(AlertsManager, self).__init__(parent)
|
||||
Registry().register('alerts_manager', self)
|
||||
self.timer_id = 0
|
||||
self.alert_list = []
|
||||
Registry().register_function('live_display_active', self.generate_alert)
|
||||
|
@ -71,7 +63,7 @@ class AlertsManager(QtCore.QObject):
|
|||
|
||||
:param text: The text to display
|
||||
"""
|
||||
log.debug('display alert called %s' % text)
|
||||
self.log_debug('display alert called %s' % text)
|
||||
if text:
|
||||
self.alert_list.append(text)
|
||||
if self.timer_id != 0:
|
||||
|
@ -85,7 +77,6 @@ class AlertsManager(QtCore.QObject):
|
|||
"""
|
||||
Format and request the Alert and start the timer.
|
||||
"""
|
||||
log.debug('Generate Alert called')
|
||||
if not self.alert_list:
|
||||
return
|
||||
text = self.alert_list.pop(0)
|
||||
|
@ -101,10 +92,9 @@ class AlertsManager(QtCore.QObject):
|
|||
|
||||
:param event: the QT event that has been triggered.
|
||||
"""
|
||||
log.debug('timer event')
|
||||
if event.timerId() == self.timer_id:
|
||||
alertTab = self.parent().settings_tab
|
||||
self.live_controller.display.alert('', alertTab.location)
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue