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):
|
class Ui_AlertDialog(object):
|
||||||
|
"""
|
||||||
|
Alert UI Class
|
||||||
|
"""
|
||||||
def setupUi(self, alert_dialog):
|
def setupUi(self, alert_dialog):
|
||||||
"""
|
"""
|
||||||
Setup the Alert UI dialog
|
Setup the Alert UI dialog
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
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 openlp.plugins.alerts.lib.db import AlertItem
|
||||||
|
|
||||||
from .alertdialog import Ui_AlertDialog
|
from .alertdialog import Ui_AlertDialog
|
||||||
@ -46,8 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
|||||||
self.manager = plugin.manager
|
self.manager = plugin.manager
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.item_id = None
|
self.item_id = None
|
||||||
# TODO: Use Registry()
|
super(AlertForm, self).__init__( Registry().get('main_window'))
|
||||||
super(AlertForm, self).__init__(self.plugin.main_window)
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.display_button.clicked.connect(self.on_display_clicked)
|
self.display_button.clicked.connect(self.on_display_clicked)
|
||||||
self.display_close_button.clicked.connect(self.on_display_close_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.
|
displaying of alerts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
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(OpenLPMixin, RegistryMixin, QtCore.QObject):
|
||||||
|
|
||||||
|
|
||||||
class AlertsManager(QtCore.QObject):
|
|
||||||
"""
|
"""
|
||||||
AlertsManager manages the settings of Alerts.
|
AlertsManager manages the settings of Alerts.
|
||||||
"""
|
"""
|
||||||
log.info('Alert Manager loaded')
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(AlertsManager, self).__init__(parent)
|
super(AlertsManager, self).__init__(parent)
|
||||||
Registry().register('alerts_manager', self)
|
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.alert_list = []
|
self.alert_list = []
|
||||||
Registry().register_function('live_display_active', self.generate_alert)
|
Registry().register_function('live_display_active', self.generate_alert)
|
||||||
@ -71,7 +63,7 @@ class AlertsManager(QtCore.QObject):
|
|||||||
|
|
||||||
:param text: The text to display
|
:param text: The text to display
|
||||||
"""
|
"""
|
||||||
log.debug('display alert called %s' % text)
|
self.log_debug('display alert called %s' % text)
|
||||||
if text:
|
if text:
|
||||||
self.alert_list.append(text)
|
self.alert_list.append(text)
|
||||||
if self.timer_id != 0:
|
if self.timer_id != 0:
|
||||||
@ -85,7 +77,6 @@ class AlertsManager(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
Format and request the Alert and start the timer.
|
Format and request the Alert and start the timer.
|
||||||
"""
|
"""
|
||||||
log.debug('Generate Alert called')
|
|
||||||
if not self.alert_list:
|
if not self.alert_list:
|
||||||
return
|
return
|
||||||
text = self.alert_list.pop(0)
|
text = self.alert_list.pop(0)
|
||||||
@ -101,10 +92,9 @@ class AlertsManager(QtCore.QObject):
|
|||||||
|
|
||||||
:param event: the QT event that has been triggered.
|
:param event: the QT event that has been triggered.
|
||||||
"""
|
"""
|
||||||
log.debug('timer event')
|
|
||||||
if event.timerId() == self.timer_id:
|
if event.timerId() == self.timer_id:
|
||||||
alertTab = self.parent().settings_tab
|
alert_tab = self.parent().settings_tab
|
||||||
self.live_controller.display.alert('', alertTab.location)
|
self.live_controller.display.alert('', alert_tab.location)
|
||||||
self.killTimer(self.timer_id)
|
self.killTimer(self.timer_id)
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.generate_alert()
|
self.generate_alert()
|
||||||
|
Loading…
Reference in New Issue
Block a user