Fox presentations and refactor service item

This commit is contained in:
Tim Bentley 2013-05-24 21:17:47 +01:00
parent e616d976f5
commit 4b2868b271
7 changed files with 39 additions and 39 deletions

View File

@ -58,8 +58,7 @@ class ItemCapabilities(object):
Provides an enumeration of a service item's capabilities Provides an enumeration of a service item's capabilities
``CanPreview`` ``CanPreview``
The capability to allow the ServiceManager to add to the preview The capability to allow the ServiceManager to add to the preview tab when making the previous item live.
tab when making the previous item live.
``CanEdit`` ``CanEdit``
The capability to allow the ServiceManager to allow the item to be edited The capability to allow the ServiceManager to allow the item to be edited
@ -71,8 +70,7 @@ class ItemCapabilities(object):
Determines is the service_item needs a Media Player Determines is the service_item needs a Media Player
``CanLoop`` ``CanLoop``
The capability to allow the SlideController to allow the loop The capability to allow the SlideController to allow the loop processing.
processing.
``CanAppend`` ``CanAppend``
The capability to allow the ServiceManager to add leaves to the The capability to allow the ServiceManager to add leaves to the
@ -82,22 +80,19 @@ class ItemCapabilities(object):
The capability to remove lines breaks in the renderer The capability to remove lines breaks in the renderer
``OnLoadUpdate`` ``OnLoadUpdate``
The capability to update MediaManager when a service Item is The capability to update MediaManager when a service Item is loaded.
loaded.
``AddIfNewItem`` ``AddIfNewItem``
Not Used Not Used
``ProvidesOwnDisplay`` ``ProvidesOwnDisplay``
The capability to tell the SlideController the service Item has a The capability to tell the SlideController the service Item has a different display.
different display.
``HasDetailedTitleDisplay`` ``HasDetailedTitleDisplay``
ServiceItem provides a title Being Removed and decommissioned.
``HasVariableStartTime`` ``HasVariableStartTime``
The capability to tell the ServiceManager that a change to start The capability to tell the ServiceManager that a change to start time is possible.
time is possible.
``CanSoftBreak`` ``CanSoftBreak``
The capability to tell the renderer that Soft Break is allowed The capability to tell the renderer that Soft Break is allowed
@ -149,7 +144,7 @@ class ServiceItem(object):
if plugin: if plugin:
self.name = plugin.name self.name = plugin.name
self.title = u'' self.title = u''
self.shortname = u'' self.processor = None
self.audit = u'' self.audit = u''
self.items = [] self.items = []
self.iconic_representation = None self.iconic_representation = None
@ -353,7 +348,8 @@ class ServiceItem(object):
u'media_length': self.media_length, u'media_length': self.media_length,
u'background_audio': self.background_audio, u'background_audio': self.background_audio,
u'theme_overwritten': self.theme_overwritten, u'theme_overwritten': self.theme_overwritten,
u'will_auto_start': self.will_auto_start u'will_auto_start': self.will_auto_start,
u'processor': self.processor
} }
service_data = [] service_data = []
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
@ -387,7 +383,6 @@ class ServiceItem(object):
self.title = header[u'title'] self.title = header[u'title']
self.name = header[u'name'] self.name = header[u'name']
self.service_item_type = header[u'type'] self.service_item_type = header[u'type']
self.shortname = header[u'plugin']
self.theme = header[u'theme'] self.theme = header[u'theme']
self.add_icon(header[u'icon']) self.add_icon(header[u'icon'])
self.raw_footer = header[u'footer'] self.raw_footer = header[u'footer']
@ -406,7 +401,13 @@ class ServiceItem(object):
self.auto_play_slides_loop = header.get(u'auto_play_slides_loop', False) self.auto_play_slides_loop = header.get(u'auto_play_slides_loop', False)
self.timed_slide_interval = header.get(u'timed_slide_interval', 0) self.timed_slide_interval = header.get(u'timed_slide_interval', 0)
self.will_auto_start = header.get(u'will_auto_start', False) self.will_auto_start = header.get(u'will_auto_start', False)
self.processor = header.get(u'processor', None)
self.has_original_files = True self.has_original_files = True
#TODO Remove me in 2,3 build phase
if self.is_capable(ItemCapabilities.HasDetailedTitleDisplay):
self.capabilities.remove(ItemCapabilities.HasDetailedTitleDisplay)
self.processor = self.title
self.title = None
if u'background_audio' in header: if u'background_audio' in header:
self.background_audio = [] self.background_audio = []
for filename in header[u'background_audio']: for filename in header[u'background_audio']:
@ -429,6 +430,8 @@ class ServiceItem(object):
self.add_from_image(text_image[u'path'], text_image[u'title'], background) self.add_from_image(text_image[u'path'], text_image[u'title'], background)
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem[u'serviceitem'][u'data']: for text_image in serviceitem[u'serviceitem'][u'data']:
if not self.title:
self.title = text_image[u'title']
if path: if path:
self.has_original_files = False self.has_original_files = False
self.add_from_command(path, text_image[u'title'], text_image[u'image']) self.add_from_command(path, text_image[u'title'], text_image[u'image'])
@ -443,9 +446,7 @@ class ServiceItem(object):
if self.is_text(): if self.is_text():
return self.title return self.title
else: else:
if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities: if len(self._raw_frames) > 1:
return self._raw_frames[0][u'title']
elif len(self._raw_frames) > 1:
return self.title return self.title
else: else:
return self._raw_frames[0][u'title'] return self._raw_frames[0][u'title']

View File

@ -466,8 +466,8 @@ class MediaController(object):
The ServiceItem containing the details to be played. The ServiceItem containing the details to be played.
""" """
used_players = get_media_players()[0] used_players = get_media_players()[0]
if service_item.title != UiStrings().Automatic: if service_item.processor != UiStrings().Automatic:
used_players = [service_item.title.lower()] used_players = [service_item.processor.lower()]
if controller.media_info.file_info.isFile(): if controller.media_info.file_info.isFile():
suffix = u'*.%s' % controller.media_info.file_info.suffix().lower() suffix = u'*.%s' % controller.media_info.file_info.suffix().lower()
for title in used_players: for title in used_players:

View File

@ -155,7 +155,7 @@ class MediaMediaItem(MediaManagerItem):
if os.path.exists(filename): if os.path.exists(filename):
service_item = ServiceItem() service_item = ServiceItem()
service_item.title = u'webkit' service_item.title = u'webkit'
service_item.shortname = service_item.title service_item.processor = u'webkit'
(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)
if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True): if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True):
@ -185,9 +185,9 @@ class MediaMediaItem(MediaManagerItem):
translate('MediaPlugin.MediaItem', 'Missing Media File'), translate('MediaPlugin.MediaItem', 'Missing Media File'),
translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename) translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
return False return False
service_item.title = self.display_type_combo_box.currentText()
service_item.shortname = service_item.title
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.title = name
service_item.processor = self.display_type_combo_box.currentText()
service_item.add_from_command(path, name, CLAPPERBOARD) service_item.add_from_command(path, name, CLAPPERBOARD)
# Only get start and end times if going to a service # Only get start and end times if going to a service
if context == ServiceItemContext.Service: if context == ServiceItemContext.Service:
@ -196,7 +196,6 @@ class MediaMediaItem(MediaManagerItem):
return False 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)
if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked: if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked:
service_item.will_auto_start = True service_item.will_auto_start = True
# force a non-existent theme # force a non-existent theme
@ -208,6 +207,7 @@ class MediaMediaItem(MediaManagerItem):
self.list_view.setIconSize(QtCore.QSize(88, 50)) self.list_view.setIconSize(QtCore.QSize(88, 50))
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails')
check_directory_exists(self.servicePath) check_directory_exists(self.servicePath)
print self.settings_section + u'/media files'
self.load_list(Settings().value(self.settings_section + u'/media files')) self.load_list(Settings().value(self.settings_section + u'/media files'))
self.populateDisplayTypes() self.populateDisplayTypes()
@ -260,8 +260,7 @@ class MediaMediaItem(MediaManagerItem):
Settings().setValue(self.settings_section + u'/media files', self.get_file_list()) Settings().setValue(self.settings_section + u'/media files', self.get_file_list())
def load_list(self, media, target_group=None): def load_list(self, media, target_group=None):
# Sort the media by its filename considering language specific # Sort the media by its filename considering language specific characters.
# characters.
media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1])) media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
for track in media: for track in media:
track_info = QtCore.QFileInfo(track) track_info = QtCore.QFileInfo(track)

View File

@ -244,22 +244,20 @@ class PresentationMediaItem(MediaManagerItem):
items = self.list_view.selectedItems() items = self.list_view.selectedItems()
if len(items) > 1: if len(items) > 1:
return False return False
service_item.title = self.display_type_combo_box.currentText() service_item.processor = self.display_type_combo_box.currentText()
service_item.shortname = self.display_type_combo_box.currentText()
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) if not self.display_type_combo_box.currentText():
shortname = service_item.shortname
if not shortname:
return False return False
for bitem in items: for bitem in items:
filename = bitem.data(QtCore.Qt.UserRole) filename = bitem.data(QtCore.Qt.UserRole)
(path, name) = os.path.split(filename)
service_item.title = name
if os.path.exists(filename): if os.path.exists(filename):
if shortname == self.Automatic: if service_item.processor == self.Automatic:
service_item.shortname = self.findControllerByType(filename) service_item.processor = self.findControllerByType(filename)
if not service_item.shortname: if not service_item.processor:
return False return False
controller = self.controllers[service_item.shortname] controller = self.controllers[service_item.processor]
(path, name) = os.path.split(filename)
doc = controller.add_document(filename) doc = controller.add_document(filename)
if doc.get_thumbnail_path(1, True) is None: if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation() doc.load_presentation()

View File

@ -36,6 +36,7 @@ from openlp.core.ui import HideMode
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Controller(object): class Controller(object):
""" """
This is the Presentation listener who acts on events from the slide controller and passes the messages on the the This is the Presentation listener who acts on events from the slide controller and passes the messages on the the
@ -314,7 +315,7 @@ class MessageListener(object):
item = message[0] item = message[0]
hide_mode = message[2] hide_mode = message[2]
file = item.get_frame_path() file = item.get_frame_path()
self.handler = item.title self.handler = item.processor
if self.handler == self.media_item.Automatic: if self.handler == self.media_item.Automatic:
self.handler = self.media_item.findControllerByType(file) self.handler = self.media_item.findControllerByType(file)
if not self.handler: if not self.handler:

View File

@ -38,6 +38,7 @@ from openlp.core.utils import AppLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class PresentationDocument(object): class PresentationDocument(object):
""" """
Base class for presentation documents to inherit from. Loads and closes the presentation as well as triggering the Base class for presentation documents to inherit from. Loads and closes the presentation as well as triggering the
@ -322,7 +323,7 @@ class PresentationController(object):
``supports`` ``supports``
The primary native file types this application supports. The primary native file types this application supports.
``alsosupports`` ``also_supports``
Other file types the application can import, although not necessarily the first choice due to potential Other file types the application can import, although not necessarily the first choice due to potential
incompatibilities. incompatibilities.
@ -358,7 +359,7 @@ class PresentationController(object):
Name of the application, to appear in the application Name of the application, to appear in the application
""" """
self.supports = [] self.supports = []
self.alsosupports = [] self.also_supports = []
self.docs = [] self.docs = []
self.plugin = plugin self.plugin = plugin
self.name = name self.name = name

View File

@ -49,7 +49,7 @@ __default_settings__ = {
u'presentations/Powerpoint': QtCore.Qt.Checked, u'presentations/Powerpoint': QtCore.Qt.Checked,
u'presentations/Powerpoint Viewer': QtCore.Qt.Checked, u'presentations/Powerpoint Viewer': QtCore.Qt.Checked,
u'presentations/presentations files': [] u'presentations/presentations files': []
} }
class PresentationPlugin(Plugin): class PresentationPlugin(Plugin):