forked from openlp/openlp
Renamed some of the ItemCapabilities.
This commit is contained in:
parent
f099329217
commit
015249407d
@ -248,9 +248,7 @@ from settingsmanager import SettingsManager
|
||||
from plugin import PluginStatus, StringContent, Plugin
|
||||
from pluginmanager import PluginManager
|
||||
from settingstab import SettingsTab
|
||||
from serviceitem import ServiceItem
|
||||
from serviceitem import ServiceItemType
|
||||
from serviceitem import ItemCapabilities
|
||||
from serviceitem import ServiceItem, ServiceItemType, ItemCapabilities
|
||||
from htmlbuilder import build_html, build_lyrics_format_css, \
|
||||
build_lyrics_outline_css
|
||||
from toolbar import OpenLPToolbar
|
||||
|
@ -222,7 +222,7 @@ class Renderer(object):
|
||||
if item.is_capable(ItemCapabilities.NoLineBreaks):
|
||||
line_end = u' '
|
||||
# Bibles
|
||||
if item.is_capable(ItemCapabilities.AllowsWordSplit):
|
||||
if item.is_capable(ItemCapabilities.HasWordSplit):
|
||||
pages = self._paginate_slide_words(text.split(u'\n'), line_end)
|
||||
else:
|
||||
# Clean up line endings.
|
||||
@ -230,7 +230,7 @@ class Renderer(object):
|
||||
pages = self._paginate_slide(lines, line_end)
|
||||
if len(pages) > 1:
|
||||
# Songs and Custom
|
||||
if item.is_capable(ItemCapabilities.AllowsVirtualSplit):
|
||||
if item.is_capable(ItemCapabilities.HasVirtualSplit):
|
||||
# Do not forget the line breaks!
|
||||
slides = text.split(u'[---]')
|
||||
pages = []
|
||||
|
@ -52,20 +52,21 @@ class ItemCapabilities(object):
|
||||
"""
|
||||
Provides an enumeration of a serviceitem's capabilities
|
||||
"""
|
||||
AllowsPreview = 1
|
||||
AllowsEdit = 2
|
||||
AllowsMaintain = 3
|
||||
CanPreview = 1
|
||||
CanEdit = 2
|
||||
CanMaintain = 3
|
||||
RequiresMedia = 4
|
||||
AllowsLoop = 5
|
||||
AllowsAdditions = 6
|
||||
CanLoop = 5
|
||||
HasAdditions = 6
|
||||
NoLineBreaks = 7
|
||||
OnLoadUpdate = 8
|
||||
AddIfNewItem = 9
|
||||
ProvidesOwnDisplay = 10
|
||||
AllowsDetailedTitleDisplay = 11
|
||||
AllowsVariableStartTime = 12
|
||||
AllowsVirtualSplit = 13
|
||||
AllowsWordSplit = 14
|
||||
HasDetailedTitleDisplay = 11
|
||||
HasVariableStartTime = 12
|
||||
HasVirtualSplit = 13
|
||||
HasWordSplit = 14
|
||||
HasBackgroundAudio = 15
|
||||
|
||||
|
||||
class ServiceItem(object):
|
||||
@ -116,6 +117,7 @@ class ServiceItem(object):
|
||||
self.media_length = 0
|
||||
self.from_service = False
|
||||
self.image_border = u'#000000'
|
||||
self.background_audio = []
|
||||
self._new_item()
|
||||
|
||||
def _new_item(self):
|
||||
@ -159,7 +161,7 @@ class ServiceItem(object):
|
||||
"""
|
||||
The render method is what generates the frames for the screen and
|
||||
obtains the display information from the renderemanager.
|
||||
At this point all the slides are build for the given
|
||||
At this point all the slides are built for the given
|
||||
display size.
|
||||
"""
|
||||
log.debug(u'Render called')
|
||||
@ -256,6 +258,7 @@ class ServiceItem(object):
|
||||
file to represent this item.
|
||||
"""
|
||||
service_header = {
|
||||
u'uuid': self._uuid,
|
||||
u'name': self.name,
|
||||
u'plugin': self.name,
|
||||
u'theme': self.theme,
|
||||
@ -272,7 +275,8 @@ class ServiceItem(object):
|
||||
u'xml_version': self.xml_version,
|
||||
u'start_time': self.start_time,
|
||||
u'end_time': self.end_time,
|
||||
u'media_length': self.media_length
|
||||
u'media_length': self.media_length,
|
||||
u'background_audio': self.background_audio
|
||||
}
|
||||
service_data = []
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
@ -320,6 +324,8 @@ class ServiceItem(object):
|
||||
self.end_time = header[u'end_time']
|
||||
if u'media_length' in header:
|
||||
self.media_length = header[u'media_length']
|
||||
if u'background_audio' in header:
|
||||
self.background_audio = header[u'background_audio']
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
for slide in serviceitem[u'serviceitem'][u'data']:
|
||||
self._raw_frames.append(slide)
|
||||
@ -341,7 +347,7 @@ class ServiceItem(object):
|
||||
if self.is_text():
|
||||
return self.title
|
||||
else:
|
||||
if ItemCapabilities.AllowsDetailedTitleDisplay in self.capabilities:
|
||||
if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities:
|
||||
return self._raw_frames[0][u'title']
|
||||
elif len(self._raw_frames) > 1:
|
||||
return self.title
|
||||
|
@ -470,22 +470,33 @@ class ServiceManager(QtGui.QWidget):
|
||||
if not self.fileName():
|
||||
return self.saveFileAs()
|
||||
path_file_name = unicode(self.fileName())
|
||||
(path, file_name) = os.path.split(path_file_name)
|
||||
(basename, extension) = os.path.splitext(file_name)
|
||||
service_file_name = basename + '.osd'
|
||||
path, file_name = os.path.split(path_file_name)
|
||||
basename, extension = os.path.splitext(file_name)
|
||||
service_file_name = '%s.osd' % basename
|
||||
log.debug(u'ServiceManager.saveFile - %s' % path_file_name)
|
||||
SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection,
|
||||
path)
|
||||
service = []
|
||||
write_list = []
|
||||
audio_files = []
|
||||
total_size = 0
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
# Number of items + 1 to zip it
|
||||
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
||||
for item in self.serviceItems:
|
||||
self.mainwindow.incrementProgressBar()
|
||||
service.append({u'serviceitem':
|
||||
item[u'service_item'].get_service_repr()})
|
||||
service_item = item[u'service_item'].get_service_repr()
|
||||
# Get all the audio files, and ready them for embedding in the
|
||||
# service file.
|
||||
if len(service_item[u'header'][u'background_audio']) > 0:
|
||||
for i, filename in \
|
||||
enumerate(service_item[u'header'][u'background_audio']):
|
||||
new_file = os.path.join(u'audio', item._uuid,
|
||||
os.path.split(filename)[1])
|
||||
audio_files.append((filename, new_file))
|
||||
service_item[u'header'][u'background_audio'][i] = new_file
|
||||
# Add the service item to the service.
|
||||
service.append({u'serviceitem': service_item})
|
||||
if not item[u'service_item'].uses_file():
|
||||
continue
|
||||
skipMissing = False
|
||||
@ -683,16 +694,16 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.maintainAction.setVisible(False)
|
||||
self.notesAction.setVisible(False)
|
||||
self.timeAction.setVisible(False)
|
||||
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit)\
|
||||
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanEdit)\
|
||||
and serviceItem[u'service_item'].edit_id:
|
||||
self.editAction.setVisible(True)
|
||||
if serviceItem[u'service_item']\
|
||||
.is_capable(ItemCapabilities.AllowsMaintain):
|
||||
.is_capable(ItemCapabilities.CanMaintain):
|
||||
self.maintainAction.setVisible(True)
|
||||
if item.parent() is None:
|
||||
self.notesAction.setVisible(True)
|
||||
if serviceItem[u'service_item']\
|
||||
.is_capable(ItemCapabilities.AllowsVariableStartTime):
|
||||
.is_capable(ItemCapabilities.HasVariableStartTime):
|
||||
self.timeAction.setVisible(True)
|
||||
self.themeMenu.menuAction().setVisible(False)
|
||||
# Set up the theme menu.
|
||||
@ -963,7 +974,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
(unicode(translate('OpenLP.ServiceManager', 'Notes')),
|
||||
cgi.escape(unicode(serviceitem.notes))))
|
||||
if item[u'service_item'] \
|
||||
.is_capable(ItemCapabilities.AllowsVariableStartTime):
|
||||
.is_capable(ItemCapabilities.HasVariableStartTime):
|
||||
tips.append(item[u'service_item'].get_media_time())
|
||||
treewidgetitem.setToolTip(0, u'<br>'.join(tips))
|
||||
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
||||
@ -1196,7 +1207,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
item += 1
|
||||
if self.serviceItems and item < len(self.serviceItems) and \
|
||||
self.serviceItems[item][u'service_item'].is_capable(
|
||||
ItemCapabilities.AllowsPreview):
|
||||
ItemCapabilities.CanPreview):
|
||||
self.mainwindow.previewController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], 0)
|
||||
self.mainwindow.liveController.previewListWidget.setFocus()
|
||||
@ -1214,7 +1225,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
item = self.findServiceItem()[0]
|
||||
if self.serviceItems[item][u'service_item']\
|
||||
.is_capable(ItemCapabilities.AllowsEdit):
|
||||
.is_capable(ItemCapabilities.CanEdit):
|
||||
Receiver.send_message(u'%s_edit' %
|
||||
self.serviceItems[item][u'service_item'].name.lower(),
|
||||
u'L:%s' % self.serviceItems[item][u'service_item'].edit_id)
|
||||
@ -1297,7 +1308,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
serviceItem = self.serviceItems[pos]
|
||||
if (plugin == serviceItem[u'service_item'].name and
|
||||
serviceItem[u'service_item'].is_capable(
|
||||
ItemCapabilities.AllowsAdditions)):
|
||||
ItemCapabilities.HasAdditions)):
|
||||
action = self.dndMenu.exec_(QtGui.QCursor.pos())
|
||||
# New action required
|
||||
if action == self.newAction:
|
||||
|
@ -518,7 +518,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.parent().songsSettingsSection + u'/display songbar',
|
||||
QtCore.QVariant(True)).toBool() and len(self.slideList) > 0:
|
||||
self.toolbar.makeWidgetsVisible([u'Song Menu'])
|
||||
if item.is_capable(ItemCapabilities.AllowsLoop) and \
|
||||
if item.is_capable(ItemCapabilities.CanLoop) and \
|
||||
len(item.get_frames()) > 1:
|
||||
self.toolbar.makeWidgetsVisible(self.loopList)
|
||||
if item.is_media():
|
||||
@ -538,7 +538,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.toolbar.hide()
|
||||
self.mediabar.setVisible(False)
|
||||
self.toolbar.makeWidgetsInvisible(self.songEditList)
|
||||
if item.is_capable(ItemCapabilities.AllowsEdit) and item.from_plugin:
|
||||
if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin:
|
||||
self.toolbar.makeWidgetsVisible(self.songEditList)
|
||||
elif item.is_media():
|
||||
self.toolbar.setVisible(False)
|
||||
|
@ -860,9 +860,9 @@ class BibleMediaItem(MediaManagerItem):
|
||||
not second_bible:
|
||||
# Split the line but do not replace line breaks in renderer.
|
||||
service_item.add_capability(ItemCapabilities.NoLineBreaks)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsWordSplit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.HasWordSplit)
|
||||
# Service Item: Title
|
||||
service_item.title = u', '.join(raw_title)
|
||||
# Service Item: Theme
|
||||
|
@ -227,10 +227,10 @@ class CustomMediaItem(MediaManagerItem):
|
||||
slide = None
|
||||
theme = None
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsVirtualSplit)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.HasVirtualSplit)
|
||||
customSlide = self.plugin.manager.get_object(CustomSlide, item_id)
|
||||
title = customSlide.title
|
||||
credit = customSlide.credits
|
||||
|
@ -149,10 +149,10 @@ class ImageMediaItem(MediaManagerItem):
|
||||
if not items:
|
||||
return False
|
||||
service_item.title = unicode(self.plugin.nameStrings[u'plural'])
|
||||
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||
service_item.add_capability(ItemCapabilities.CanMaintain)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.HasAdditions)
|
||||
# force a nonexistent theme
|
||||
service_item.theme = -1
|
||||
missing_items = []
|
||||
|
@ -165,7 +165,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.mediaObject.stop()
|
||||
service_item.media_length = self.mediaObject.totalTime() / 1000
|
||||
service_item.add_capability(
|
||||
ItemCapabilities.AllowsVariableStartTime)
|
||||
ItemCapabilities.HasVariableStartTime)
|
||||
service_item.title = unicode(self.plugin.nameStrings[u'singular'])
|
||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||
# force a non-existent theme
|
||||
|
@ -248,7 +248,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
||||
service_item.shortname = unicode(self.displayTypeComboBox.currentText())
|
||||
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
||||
service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay)
|
||||
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
|
||||
shortname = service_item.shortname
|
||||
if shortname:
|
||||
for bitem in items:
|
||||
|
@ -395,12 +395,12 @@ class SongMediaItem(MediaManagerItem):
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
||||
log.debug(u'generateSlideData (%s:%s)' % (service_item, item))
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||
service_item.add_capability(ItemCapabilities.AddIfNewItem)
|
||||
service_item.add_capability(ItemCapabilities.AllowsVirtualSplit)
|
||||
service_item.add_capability(ItemCapabilities.HasVirtualSplit)
|
||||
song = self.plugin.manager.get_object(Song, item_id)
|
||||
service_item.theme = song.theme_name
|
||||
service_item.edit_id = item_id
|
||||
@ -471,6 +471,10 @@ class SongMediaItem(MediaManagerItem):
|
||||
service_item.data_string = {u'title': song.search_title,
|
||||
u'authors': u', '.join(author_list)}
|
||||
service_item.xml_version = self.openLyrics.song_to_xml(song)
|
||||
# Add the audio file to the service item.
|
||||
if len(song.media_files) > 0:
|
||||
service_item.add_capability(ItemCapabilities.HasBackgroundAudio)
|
||||
|
||||
return True
|
||||
|
||||
def serviceLoad(self, item):
|
||||
|
Loading…
Reference in New Issue
Block a user