Stop service item generation running media twice

This commit is contained in:
Tim Bentley 2012-10-20 09:20:11 +01:00
parent 464480fc34
commit cf635c1459
8 changed files with 37 additions and 22 deletions

View File

@ -36,6 +36,14 @@ from PyQt4 import QtCore, QtGui, Qt
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ServiceItemContext(object):
"""
The context in which a Service Item is being generated
"""
Preview = 0
Live = 1
Service = 2
class ImageSource(object): class ImageSource(object):
""" """
@ -394,4 +402,4 @@ from dockwidget import OpenLPDockWidget
from imagemanager import ImageManager from imagemanager import ImageManager
from renderer import Renderer from renderer import Renderer
from mediamanageritem import MediaManagerItem from mediamanageritem import MediaManagerItem
from openlp.core.utils.actions import ActionList

View File

@ -35,7 +35,8 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD StringContent, build_icon, translate, Receiver, ListWidgetWithDnD, \
ServiceItemContext
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, create_widget_action, \ from openlp.core.lib.ui import UiStrings, create_widget_action, \
critical_error_message_box critical_error_message_box
@ -43,6 +44,7 @@ from openlp.core.lib.settings import Settings
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaManagerItem(QtGui.QWidget): class MediaManagerItem(QtGui.QWidget):
""" """
MediaManagerItem is a helper widget for plugins. MediaManagerItem is a helper widget for plugins.
@ -457,7 +459,7 @@ class MediaManagerItem(QtGui.QWidget):
pass pass
def generateSlideData(self, serviceItem, item=None, xmlVersion=False, def generateSlideData(self, serviceItem, item=None, xmlVersion=False,
remote=False): remote=False, context=ServiceItemContext.Live):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs ' raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin') u'to be defined by the plugin')
@ -548,7 +550,8 @@ class MediaManagerItem(QtGui.QWidget):
self.addToService(item) self.addToService(item)
def addToService(self, item=None, replace=None, remote=False): def addToService(self, item=None, replace=None, remote=False):
serviceItem = self.buildServiceItem(item, True, remote=remote) serviceItem = self.buildServiceItem(item, True, remote=remote,
context=ServiceItemContext.Service)
if serviceItem: if serviceItem:
serviceItem.from_plugin = False serviceItem.from_plugin = False
self.plugin.serviceManager.addServiceItem(serviceItem, self.plugin.serviceManager.addServiceItem(serviceItem,
@ -581,13 +584,15 @@ class MediaManagerItem(QtGui.QWidget):
unicode(translate('OpenLP.MediaManagerItem', unicode(translate('OpenLP.MediaManagerItem',
'You must select a %s service item.')) % self.title) 'You must select a %s service item.')) % self.title)
def buildServiceItem(self, item=None, xmlVersion=False, remote=False): def buildServiceItem(self, item=None, xmlVersion=False, remote=False,
context=ServiceItemContext.Live):
""" """
Common method for generating a service item Common method for generating a service item
""" """
serviceItem = ServiceItem(self.plugin) serviceItem = ServiceItem(self.plugin)
serviceItem.add_icon(self.plugin.iconPath) serviceItem.add_icon(self.plugin.iconPath)
if self.generateSlideData(serviceItem, item, xmlVersion, remote): if self.generateSlideData(serviceItem, item, xmlVersion, remote,
context):
return serviceItem return serviceItem
else: else:
return None return None

View File

@ -31,7 +31,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, create_separated_list translate, create_separated_list, ServiceItemContext
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \ from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
@ -893,7 +893,7 @@ class BibleMediaItem(MediaManagerItem):
return items return items
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False,context=ServiceItemContext.Service):
""" """
Generates and formats the slides for the service item as well as the Generates and formats the slides for the service item as well as the
service item's title. service item's title.

View File

@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_, func from sqlalchemy.sql import or_, func
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
check_item_selected, translate check_item_selected, translate, ServiceItemContext
from openlp.core.lib.ui import UiStrings from openlp.core.lib.ui import UiStrings
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.forms import EditCustomForm
@ -194,7 +194,7 @@ class CustomMediaItem(MediaManagerItem):
self.searchTextEdit.setFocus() self.searchTextEdit.setFocus()
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False, context=ServiceItemContext.Service):
item_id = self._getIdOfItemToGenerate(item, self.remoteCustom) item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
service_item.add_capability(ItemCapabilities.CanEdit) service_item.add_capability(ItemCapabilities.CanEdit)
service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanPreview)

View File

@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, check_directory_exists, \ SettingsManager, translate, check_item_selected, check_directory_exists, \
Receiver, create_thumb, validate_thumb Receiver, create_thumb, validate_thumb, ServiceItemContext
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.utils import AppLocation, delete_file, locale_compare, \ from openlp.core.utils import AppLocation, delete_file, locale_compare, \
@ -152,7 +152,7 @@ class ImageMediaItem(MediaManagerItem):
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False,context=ServiceItemContext.Service):
background = QtGui.QColor(Settings().value(self.settingsSection background = QtGui.QColor(Settings().value(self.settingsSection
+ u'/background color', QtCore.QVariant(u'#000000'))) + u'/background color', QtCore.QVariant(u'#000000')))
if item: if item:

View File

@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, Receiver, MediaType, \ SettingsManager, translate, check_item_selected, Receiver, MediaType, \
ServiceItem, build_html ServiceItem, build_html, ServiceItemContext
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
create_horizontal_adjusting_combo_box create_horizontal_adjusting_combo_box
@ -198,7 +198,7 @@ class MediaMediaItem(MediaManagerItem):
'the media file "%s" no longer exists.')) % filename) 'the media file "%s" no longer exists.')) % filename)
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False, context=ServiceItemContext.Live):
if item is None: if item is None:
item = self.listView.currentItem() item = self.listView.currentItem()
if item is None: if item is None:
@ -216,10 +216,12 @@ class MediaMediaItem(MediaManagerItem):
service_item.shortname = service_item.title service_item.shortname = service_item.title
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_command(path, name, CLAPPERBOARD) service_item.add_from_command(path, name, CLAPPERBOARD)
# Start media and obtain the length # Only get start and end times if going to a service
if not self.plugin.mediaController.media_length( if context == ServiceItemContext.Service:
self.mediaController, service_item): # Start media and obtain the length
return False if not self.plugin.mediaController.media_length(
self.mediaController, service_item):
return False
service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.RequiresMedia)
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)

View File

@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \ from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \ translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \
validate_thumb validate_thumb, ServiceItemContext
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
create_horizontal_adjusting_combo_box create_horizontal_adjusting_combo_box
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
@ -243,7 +243,7 @@ class PresentationMediaItem(MediaManagerItem):
u'presentations', self.getFileList()) u'presentations', self.getFileList())
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False, context=ServiceItemContext.Service):
""" """
Load the relevant information for displaying the presentation Load the relevant information for displaying the presentation
in the slidecontroller. In the case of powerpoints, an image in the slidecontroller. In the case of powerpoints, an image

View File

@ -36,7 +36,7 @@ from sqlalchemy.sql import or_
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, check_item_selected, PluginStatus, create_separated_list, \ translate, check_item_selected, PluginStatus, create_separated_list, \
check_directory_exists check_directory_exists, ServiceItemContext
from openlp.core.lib.ui import UiStrings, create_widget_action from openlp.core.lib.ui import UiStrings, create_widget_action
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
@ -449,7 +449,7 @@ class SongMediaItem(MediaManagerItem):
self.onSongListLoad() self.onSongListLoad()
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False): remote=False, context=ServiceItemContext.Service):
log.debug(u'generateSlideData: %s, %s, %s' % log.debug(u'generateSlideData: %s, %s, %s' %
(service_item, item, self.remoteSong)) (service_item, item, self.remoteSong))
item_id = self._getIdOfItemToGenerate(item, self.remoteSong) item_id = self._getIdOfItemToGenerate(item, self.remoteSong)