forked from openlp/openlp
Finished moving alert code to plugin structure
This commit is contained in:
parent
944f45c8c8
commit
47a61a6581
@ -127,6 +127,7 @@ class Plugin(QtCore.QObject):
|
|||||||
self.service_manager = plugin_helpers[u'service']
|
self.service_manager = plugin_helpers[u'service']
|
||||||
self.settings = plugin_helpers[u'settings']
|
self.settings = plugin_helpers[u'settings']
|
||||||
self.mediadock = plugin_helpers[u'toolbox']
|
self.mediadock = plugin_helpers[u'toolbox']
|
||||||
|
self.maindisplay = plugin_helpers[u'maindisplay']
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||||
self.process_add_service_event)
|
self.process_add_service_event)
|
||||||
|
@ -101,7 +101,7 @@ class PluginManager(object):
|
|||||||
log.debug(u'Loaded plugin %s with helpers', unicode(p))
|
log.debug(u'Loaded plugin %s with helpers', unicode(p))
|
||||||
plugin_objects.append(plugin)
|
plugin_objects.append(plugin)
|
||||||
except TypeError:
|
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)
|
plugins_list = sorted(plugin_objects, self.order_by_weight)
|
||||||
for plugin in plugins_list:
|
for plugin in plugins_list:
|
||||||
if plugin.check_pre_conditions():
|
if plugin.check_pre_conditions():
|
||||||
|
@ -114,11 +114,9 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.displayBlank = False
|
self.displayBlank = False
|
||||||
self.blankFrame = None
|
self.blankFrame = None
|
||||||
self.frame = None
|
self.frame = None
|
||||||
self.timer_id = 0
|
|
||||||
self.firstTime = True
|
self.firstTime = True
|
||||||
self.mediaLoaded = False
|
self.mediaLoaded = False
|
||||||
self.hasTransition = False
|
self.hasTransition = False
|
||||||
self.alertList = []
|
|
||||||
self.mediaBackground = False
|
self.mediaBackground = False
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
|
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
|
||||||
|
@ -510,6 +510,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
||||||
self.plugin_helpers[u'settings'] = self.settingsForm
|
self.plugin_helpers[u'settings'] = self.settingsForm
|
||||||
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
|
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
|
||||||
|
self.plugin_helpers[u'maindisplay'] = self.mainDisplay
|
||||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
||||||
# hook methods have to happen after find_plugins. Find plugins needs
|
# hook methods have to happen after find_plugins. Find plugins needs
|
||||||
# the controllers hence the hooks have moved from setupUI() to here
|
# the controllers hence the hooks have moved from setupUI() to here
|
||||||
|
@ -29,7 +29,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus
|
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.forms import AlertsTab, AlertForm
|
||||||
#from openlp.plugins.alerts.lib.models import alertsItem
|
#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)
|
Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers)
|
||||||
self.weight = -3
|
self.weight = -3
|
||||||
self.icon = build_icon(u':/media/media_image.png')
|
self.icon = build_icon(u':/media/media_image.png')
|
||||||
self.alertsmanager = None
|
self.alertsmanager = AlertsManager(self)
|
||||||
self.alertForm = AlertForm(self)
|
self.alertForm = AlertForm(self)
|
||||||
self.status = PluginStatus.Active
|
self.status = PluginStatus.Active
|
||||||
|
|
||||||
def get_settings_tab(self):
|
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):
|
def add_tools_menu_item(self, tools_menu):
|
||||||
"""
|
"""
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import build_icon
|
from openlp.core.lib import build_icon
|
||||||
|
from openlp.plugins.alerts.lib import alertmanager
|
||||||
|
|
||||||
class AlertForm(QtGui.QDialog):
|
class AlertForm(QtGui.QDialog):
|
||||||
global log
|
global log
|
||||||
@ -97,4 +98,4 @@ class AlertForm(QtGui.QDialog):
|
|||||||
self.CancelButton.setText(self.trUtf8('Cancel'))
|
self.CancelButton.setText(self.trUtf8('Cancel'))
|
||||||
|
|
||||||
def onDisplayClicked(self):
|
def onDisplayClicked(self):
|
||||||
self.parent.mainDisplay.displayAlert(unicode(self.AlertEntryEditItem.text()))
|
self.parent.alertsmanager.displayAlert(unicode(self.AlertEntryEditItem.text()))
|
||||||
|
@ -22,4 +22,4 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
from alertmanager import AlertManager
|
from alertsmanager import AlertsManager
|
||||||
|
@ -6,7 +6,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.lib import str_to_bool, Receiver
|
from openlp.core.lib import str_to_bool, Receiver
|
||||||
from openlp.core.lib import SettingsTab
|
from openlp.core.lib import SettingsTab
|
||||||
|
|
||||||
class AlertManager(self):
|
class AlertsManager(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
BiblesTab is the Bibles settings tab in the settings dialog.
|
BiblesTab is the Bibles settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
@ -14,7 +14,11 @@ class AlertManager(self):
|
|||||||
log = logging.getLogger(u'AlertManager')
|
log = logging.getLogger(u'AlertManager')
|
||||||
log.info(u'Alert Manager loaded')
|
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.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
|
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
|
||||||
|
|
||||||
@ -26,9 +30,10 @@ class AlertManager(self):
|
|||||||
display text
|
display text
|
||||||
"""
|
"""
|
||||||
log.debug(u'display alert called %s' % 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)
|
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.parent.StatusBar.showMessage(\
|
||||||
self.trUtf8(u'Alert message created and delayed'))
|
self.trUtf8(u'Alert message created and delayed'))
|
||||||
return
|
return
|
||||||
@ -39,9 +44,9 @@ class AlertManager(self):
|
|||||||
if len(self.alertList) == 0:
|
if len(self.alertList) == 0:
|
||||||
return
|
return
|
||||||
text = self.alertList.pop(0)
|
text = self.alertList.pop(0)
|
||||||
alertTab = self.parent.settingsForm.AlertsTab
|
alertTab = self.parent.alertsTab
|
||||||
alertframe = \
|
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)
|
alertframe.fill(QtCore.Qt.transparent)
|
||||||
painter = QtGui.QPainter(alertframe)
|
painter = QtGui.QPainter(alertframe)
|
||||||
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
|
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
|
||||||
@ -62,14 +67,14 @@ class AlertManager(self):
|
|||||||
painter.drawText(
|
painter.drawText(
|
||||||
x, y + metrics.height() - metrics.descent() - 1, text)
|
x, y + metrics.height() - metrics.descent() - 1, text)
|
||||||
painter.end()
|
painter.end()
|
||||||
self.display_alert.setPixmap(alertframe)
|
self.parent.maindisplay.display_alert.setPixmap(alertframe)
|
||||||
# check to see if we have a timer running
|
# check to see if we have a timer running
|
||||||
if self.timer_id == 0:
|
if self.timer_id == 0:
|
||||||
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
|
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
|
||||||
|
|
||||||
def timerEvent(self, event):
|
def timerEvent(self, event):
|
||||||
if event.timerId() == self.timer_id:
|
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.killTimer(self.timer_id)
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.generateAlert()
|
self.generateAlert()
|
Loading…
Reference in New Issue
Block a user