forked from openlp/openlp
Update service items on service load
This commit is contained in:
commit
bdc924093e
@ -193,6 +193,14 @@ class EventReceiver(QtCore.QObject):
|
|||||||
``{plugin}_add_service_item``
|
``{plugin}_add_service_item``
|
||||||
Ask the plugin to push the selected items to the service item
|
Ask the plugin to push the selected items to the service item
|
||||||
|
|
||||||
|
``{plugin}_service_load``
|
||||||
|
Ask the plugin to process an individual service item after it has been
|
||||||
|
loaded
|
||||||
|
|
||||||
|
``service_item_update``
|
||||||
|
Passes back to the service manager the service item after it has been
|
||||||
|
processed by the plugin
|
||||||
|
|
||||||
``alerts_text``
|
``alerts_text``
|
||||||
Displays an alert message
|
Displays an alert message
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import context_menu_action, context_menu_separator, \
|
from openlp.core.lib import context_menu_action, context_menu_separator, \
|
||||||
SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate
|
SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate, \
|
||||||
|
Receiver
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -119,6 +120,9 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.requiredIcons()
|
self.requiredIcons()
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'%s_service_load' % self.parent.name.lower()),
|
||||||
|
self.serviceLoad)
|
||||||
|
|
||||||
def requiredIcons(self):
|
def requiredIcons(self):
|
||||||
"""
|
"""
|
||||||
@ -540,3 +544,11 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
return service_item
|
return service_item
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def serviceLoad(self, message):
|
||||||
|
"""
|
||||||
|
Method to add processing when a service has been loaded and
|
||||||
|
individual service items need to be processed by the plugins
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ class ItemCapabilities(object):
|
|||||||
AllowsLoop = 5
|
AllowsLoop = 5
|
||||||
AllowsAdditions = 6
|
AllowsAdditions = 6
|
||||||
NoLineBreaks = 7
|
NoLineBreaks = 7
|
||||||
|
OnLoadUpdate = 8
|
||||||
|
AddIfNewItem = 9
|
||||||
|
|
||||||
|
|
||||||
class ServiceItem(object):
|
class ServiceItem(object):
|
||||||
"""
|
"""
|
||||||
@ -98,6 +101,7 @@ class ServiceItem(object):
|
|||||||
self.main = None
|
self.main = None
|
||||||
self.footer = None
|
self.footer = None
|
||||||
self.bg_image_bytes = None
|
self.bg_image_bytes = None
|
||||||
|
self._new_item()
|
||||||
|
|
||||||
def _new_item(self):
|
def _new_item(self):
|
||||||
"""
|
"""
|
||||||
|
@ -223,6 +223,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
|
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'theme_update_global'), self.themeChange)
|
QtCore.SIGNAL(u'theme_update_global'), self.themeChange)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate)
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
self.service_theme = unicode(QtCore.QSettings().value(
|
self.service_theme = unicode(QtCore.QSettings().value(
|
||||||
self.parent.serviceSettingsSection + u'/service theme',
|
self.parent.serviceSettingsSection + u'/service theme',
|
||||||
@ -711,6 +713,9 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
serviceitem.set_from_service(item, self.servicePath)
|
serviceitem.set_from_service(item, self.servicePath)
|
||||||
self.validateItem(serviceitem)
|
self.validateItem(serviceitem)
|
||||||
self.addServiceItem(serviceitem)
|
self.addServiceItem(serviceitem)
|
||||||
|
if serviceitem.is_capable(ItemCapabilities.OnLoadUpdate):
|
||||||
|
Receiver.send_message(u'%s_service_load' %
|
||||||
|
serviceitem.name.lower(), serviceitem)
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(p_file):
|
if os.path.isfile(p_file):
|
||||||
os.remove(p_file)
|
os.remove(p_file)
|
||||||
@ -801,6 +806,14 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
# does not impact the saved song so True may also be valid
|
# does not impact the saved song so True may also be valid
|
||||||
self.parent.serviceChanged(False, self.serviceName)
|
self.parent.serviceChanged(False, self.serviceName)
|
||||||
|
|
||||||
|
def serviceItemUpdate(self, message):
|
||||||
|
"""
|
||||||
|
Triggered from plugins to update service items.
|
||||||
|
"""
|
||||||
|
print message
|
||||||
|
for item in self.serviceItems:
|
||||||
|
print item[u'service_item'].title, item[u'service_item']._uuid
|
||||||
|
|
||||||
def addServiceItem(self, item, rebuild=False, expand=True, replace=False):
|
def addServiceItem(self, item, rebuild=False, expand=True, replace=False):
|
||||||
"""
|
"""
|
||||||
Add a Service item to the list
|
Add a Service item to the list
|
||||||
|
@ -324,6 +324,8 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
|
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||||
|
service_item.add_capability(ItemCapabilities.AddIfNewItem)
|
||||||
song = self.parent.manager.get_object(Song, item_id)
|
song = self.parent.manager.get_object(Song, item_id)
|
||||||
service_item.theme = song.theme_name
|
service_item.theme = song.theme_name
|
||||||
service_item.editId = item_id
|
service_item.editId = item_id
|
||||||
@ -371,3 +373,10 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
song.title, author_audit, song.copyright, unicode(song.ccli_number)
|
song.title, author_audit, song.copyright, unicode(song.ccli_number)
|
||||||
]
|
]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def serviceLoad(self, item):
|
||||||
|
"""
|
||||||
|
Triggered by a song being loaded by the service item
|
||||||
|
"""
|
||||||
|
Receiver.send_message(u'service_item_update', u'0:0')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user