Finished moving alert code to plugin structure

This commit is contained in:
Tim Bentley 2010-02-12 18:42:09 +00:00
parent 944f45c8c8
commit 47a61a6581
8 changed files with 24 additions and 17 deletions

View File

@ -127,6 +127,7 @@ class Plugin(QtCore.QObject):
self.service_manager = plugin_helpers[u'service']
self.settings = plugin_helpers[u'settings']
self.mediadock = plugin_helpers[u'toolbox']
self.maindisplay = plugin_helpers[u'maindisplay']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.process_add_service_event)
@ -252,4 +253,4 @@ class Plugin(QtCore.QObject):
if self.media_item:
self.mediadock.insert_dock(self.media_item, self.icon, self.weight)
if self.settings_tab:
self.settings.insertTab(self.settings_tab, self.weight)
self.settings.insertTab(self.settings_tab, self.weight)

View File

@ -101,7 +101,7 @@ class PluginManager(object):
log.debug(u'Loaded plugin %s with helpers', unicode(p))
plugin_objects.append(plugin)
except TypeError:
log.error(u'loaded plugin %s has no helpers', unicode(p))
log.exception(u'loaded plugin %s has no helpers', unicode(p))
plugins_list = sorted(plugin_objects, self.order_by_weight)
for plugin in plugins_list:
if plugin.check_pre_conditions():

View File

@ -114,11 +114,9 @@ class MainDisplay(DisplayWidget):
self.displayBlank = False
self.blankFrame = None
self.frame = None
self.timer_id = 0
self.firstTime = True
self.mediaLoaded = False
self.hasTransition = False
self.alertList = []
self.mediaBackground = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)

View File

@ -510,6 +510,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.plugin_helpers[u'service'] = self.ServiceManagerContents
self.plugin_helpers[u'settings'] = self.settingsForm
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
self.plugin_helpers[u'maindisplay'] = self.mainDisplay
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
# hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here

View File

@ -29,7 +29,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus
#from openlp.plugins.alerts.lib import alertsManager
from openlp.plugins.alerts.lib import AlertsManager
from openlp.plugins.alerts.forms import AlertsTab, AlertForm
#from openlp.plugins.alerts.lib.models import alertsItem
@ -42,12 +42,13 @@ class alertsPlugin(Plugin):
Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers)
self.weight = -3
self.icon = build_icon(u':/media/media_image.png')
self.alertsmanager = None
self.alertsmanager = AlertsManager(self)
self.alertForm = AlertForm(self)
self.status = PluginStatus.Active
def get_settings_tab(self):
return AlertsTab(self.name)
self.alertsTab = AlertsTab(self.name)
return self.alertsTab
def add_tools_menu_item(self, tools_menu):
"""

View File

@ -26,6 +26,7 @@
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon
from openlp.plugins.alerts.lib import alertmanager
class AlertForm(QtGui.QDialog):
global log
@ -97,4 +98,4 @@ class AlertForm(QtGui.QDialog):
self.CancelButton.setText(self.trUtf8('Cancel'))
def onDisplayClicked(self):
self.parent.mainDisplay.displayAlert(unicode(self.AlertEntryEditItem.text()))
self.parent.alertsmanager.displayAlert(unicode(self.AlertEntryEditItem.text()))

View File

@ -22,4 +22,4 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from alertmanager import AlertManager
from alertsmanager import AlertsManager

View File

@ -6,7 +6,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import str_to_bool, Receiver
from openlp.core.lib import SettingsTab
class AlertManager(self):
class AlertsManager(QtCore.QObject):
"""
BiblesTab is the Bibles settings tab in the settings dialog.
"""
@ -14,7 +14,11 @@ class AlertManager(self):
log = logging.getLogger(u'AlertManager')
log.info(u'Alert Manager loaded')
def __init__(self):
def __init__(self, parent):
QtCore.QObject.__init__(self)
self.parent = parent
self.timer_id = 0
self.alertList = []
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
@ -26,9 +30,10 @@ class AlertManager(self):
display text
"""
log.debug(u'display alert called %s' % text)
self.parent.StatusBar.showMessage(self.trUtf8(u''))
self.screen = self.parent.maindisplay.screen
self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u''))
self.alertList.append(text)
if self.timer_id != 0 or self.mediaLoaded:
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
self.parent.StatusBar.showMessage(\
self.trUtf8(u'Alert message created and delayed'))
return
@ -39,9 +44,9 @@ class AlertManager(self):
if len(self.alertList) == 0:
return
text = self.alertList.pop(0)
alertTab = self.parent.settingsForm.AlertsTab
alertTab = self.parent.alertsTab
alertframe = \
QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight)
QtGui.QPixmap(self.screen[u'size'].width(), self.parent.maindisplay.alertHeight)
alertframe.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(alertframe)
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
@ -62,14 +67,14 @@ class AlertManager(self):
painter.drawText(
x, y + metrics.height() - metrics.descent() - 1, text)
painter.end()
self.display_alert.setPixmap(alertframe)
self.parent.maindisplay.display_alert.setPixmap(alertframe)
# check to see if we have a timer running
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
def timerEvent(self, event):
if event.timerId() == self.timer_id:
self.display_alert.setPixmap(self.transparent)
self.parent.maindisplay.display_alert.setPixmap(self.parent.maindisplay.transparent)
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()