Made presenting PDF from the servicemanager work

This commit is contained in:
Tomas Groth 2013-12-27 17:44:12 +00:00
parent ffa3cd32b3
commit 685258b744
4 changed files with 34 additions and 15 deletions

View File

@ -420,7 +420,11 @@ class ServiceItem(object):
self._raw_frames.append(slide) self._raw_frames.append(slide)
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
settings_section = serviceitem['serviceitem']['header']['name'] settings_section = serviceitem['serviceitem']['header']['name']
background = QtGui.QColor(Settings().value(settings_section + '/background color')) background = None
try:
background = QtGui.QColor(Settings().value(settings_section + '/background color'))
except Exception:
pass
if path: if path:
self.has_original_files = False self.has_original_files = False
for text_image in serviceitem['serviceitem']['data']: for text_image in serviceitem['serviceitem']['data']:

View File

@ -438,7 +438,7 @@ class SlideController(DisplayController):
# "V1" was the slide we wanted to go. # "V1" was the slide we wanted to go.
self.preview_widget.change_slide(self.slideList[self.current_shortcut]) self.preview_widget.change_slide(self.slideList[self.current_shortcut])
self.slide_selected() self.slide_selected()
# Reset the shortcut. # Reset the shortcut.
self.current_shortcut = '' self.current_shortcut = ''
def set_live_hotkeys(self, parent=None): def set_live_hotkeys(self, parent=None):
@ -733,7 +733,7 @@ class SlideController(DisplayController):
if old_item and self.is_live and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay): if old_item and self.is_live and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
self._reset_blank() self._reset_blank()
Registry().execute( Registry().execute(
'%s_start' % service_item.name.lower(), [service_item, self.is_live, self.hide_mode(), slideno]) '%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slideno])
self.slideList = {} self.slideList = {}
if self.is_live: if self.is_live:
self.song_menu.menu().clear() self.song_menu.menu().clear()

View File

@ -238,7 +238,7 @@ class PresentationMediaItem(MediaManagerItem):
Settings().setValue(self.settings_section + '/presentations files', self.get_file_list()) Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())
def generate_slide_data(self, service_item, item=None, xml_version=False, def generate_slide_data(self, service_item, item=None, xml_version=False,
remote=False, context=ServiceItemContext.Service): remote=False, context=ServiceItemContext.Service, presentation_file=None):
""" """
Load the relevant information for displaying the presentation in the slidecontroller. In the case of Load the relevant information for displaying the presentation in the slidecontroller. In the case of
powerpoints, an image for each slide. powerpoints, an image for each slide.
@ -249,7 +249,9 @@ 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
filename = items[0].data(QtCore.Qt.UserRole) filename = presentation_file
if filename is None:
filename = items[0].data(QtCore.Qt.UserRole)
file_type = os.path.splitext(filename)[1][1:] file_type = os.path.splitext(filename)[1][1:]
if not self.display_type_combo_box.currentText(): if not self.display_type_combo_box.currentText():
return False return False
@ -261,7 +263,9 @@ class PresentationMediaItem(MediaManagerItem):
# force a nonexistent theme # force a nonexistent theme
service_item.theme = -1 service_item.theme = -1
for bitem in items: for bitem in items:
filename = bitem.data(QtCore.Qt.UserRole) filename = presentation_file
if filename is None:
filename = bitem.data(QtCore.Qt.UserRole)
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.title = name service_item.title = name
if os.path.exists(filename): if os.path.exists(filename):
@ -298,7 +302,7 @@ class PresentationMediaItem(MediaManagerItem):
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.title = name service_item.title = name
if os.path.exists(filename): if os.path.exists(filename):
if service_item.processor == self.Automatic: if service_item.processor == self.automatic:
service_item.processor = self.findControllerByType(filename) service_item.processor = self.findControllerByType(filename)
if not service_item.processor: if not service_item.processor:
return False return False

View File

@ -33,7 +33,7 @@ from PyQt4 import QtCore
from openlp.core.lib import Registry from openlp.core.lib import Registry
from openlp.core.ui import HideMode from openlp.core.ui import HideMode
from openlp.core.lib import ServiceItemContext from openlp.core.lib import ServiceItemContext, ServiceItem
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -318,14 +318,26 @@ class MessageListener(object):
hide_mode = message[2] hide_mode = message[2]
file = item.get_frame_path() file = item.get_frame_path()
self.handler = item.processor self.handler = item.processor
#self.media_item.generate_slide_data(self, service_item, item=None, xml_version=False,remote=False, context=ServiceItemContext.Service) # When starting presentation from the servicemanager/slidecontroller we convert
# PDF/XPS-serviceitems into image-serviceitems. When started from the mediamanager
# the conversion has already been done.
if file.endswith('.pdf') or file.endswith('.xps'): if file.endswith('.pdf') or file.endswith('.xps'):
log.debug('Trying to convert from pdf to images for service-item') log.debug('Converting from pdf/xps to images for serviceitem with file %s', file)
# Create a new image-serviceitem which will overwrite the old one
new_item = ServiceItem()
new_item.name = 'images'
if is_live: if is_live:
self.media_item.generate_slide_data(self, item, None, False, False, ServiceItemContext.Live) self.media_item.generate_slide_data(new_item, item, False, False, ServiceItemContext.Live, file)
else: else:
self.media_item.generate_slide_data(self, item, None, False, False, ServiceItemContext.Preview) self.media_item.generate_slide_data(new_item, item, False, False, ServiceItemContext.Preview, file)
# We need to overwrite the current serviceitem to make the slidecontroller
# present the images, so we do some copying
service_repr = {'serviceitem': new_item.get_service_repr(True) }
item.set_from_service(service_repr)
item._raw_frames = new_item._raw_frames
# When presenting PDF or XPS, we are using the image presentation code,
# so handler & processor is set to None, and we skip adding the handler.
self.handler = None
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:
@ -334,9 +346,8 @@ class MessageListener(object):
controller = self.live_handler controller = self.live_handler
else: else:
controller = self.preview_handler controller = self.preview_handler
# when presenting PDF, we're using the image presentation code, # When presenting PDF or XPS, we are using the image presentation code,
# so handler & processor is set to None, and we skip adding the handler. # so handler & processor is set to None, and we skip adding the handler.
log.debug('file: %s' % file)
if self.handler == None: if self.handler == None:
self.controller = controller self.controller = controller
else: else: