forked from openlp/openlp
Made the code a bit more readable by introducing PDF_CONTROLLER_FILETYPES
This commit is contained in:
parent
773a1cef39
commit
c02ef96fff
@ -38,7 +38,7 @@ from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemConte
|
|||||||
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||||
from openlp.core.utils import get_locale_key
|
from openlp.core.utils import get_locale_key
|
||||||
from openlp.plugins.presentations.lib import MessageListener
|
from openlp.plugins.presentations.lib import MessageListener
|
||||||
|
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -260,11 +260,11 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
filename = presentation_file
|
filename = presentation_file
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = items[0].data(QtCore.Qt.UserRole)
|
filename = items[0].data(QtCore.Qt.UserRole)
|
||||||
file_type = os.path.splitext(filename)[1][1:]
|
file_type = os.path.splitext(filename.lower())[1][1:]
|
||||||
if not self.display_type_combo_box.currentText():
|
if not self.display_type_combo_box.currentText():
|
||||||
return False
|
return False
|
||||||
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
||||||
if (file_type == 'pdf' or file_type == 'xps' or filetype == 'oxps') and context != ServiceItemContext.Service:
|
if file_type in PDF_CONTROLLER_FILETYPES and context != ServiceItemContext.Service:
|
||||||
service_item.add_capability(ItemCapabilities.CanMaintain)
|
service_item.add_capability(ItemCapabilities.CanMaintain)
|
||||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||||
|
@ -29,12 +29,14 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import copy
|
import copy
|
||||||
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.common import Registry
|
from openlp.core.common import Registry
|
||||||
from openlp.core.ui import HideMode
|
from openlp.core.ui import HideMode
|
||||||
from openlp.core.lib import ServiceItemContext, ServiceItem
|
from openlp.core.lib import ServiceItemContext, ServiceItem
|
||||||
|
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -322,7 +324,8 @@ class MessageListener(object):
|
|||||||
# When starting presentation from the servicemanager we convert
|
# When starting presentation from the servicemanager we convert
|
||||||
# PDF/XPS/OXPS-serviceitems into image-serviceitems. When started from the mediamanager
|
# PDF/XPS/OXPS-serviceitems into image-serviceitems. When started from the mediamanager
|
||||||
# the conversion has already been done at this point.
|
# the conversion has already been done at this point.
|
||||||
if file.endswith('.pdf') or file.endswith('xps'):
|
file_type = os.path.splitext(file.lower())[1][1:]
|
||||||
|
if file_type in PDF_CONTROLLER_FILETYPES:
|
||||||
log.debug('Converting from pdf/xps/oxps to images for serviceitem with file %s', file)
|
log.debug('Converting from pdf/xps/oxps to images for serviceitem with file %s', file)
|
||||||
# Create a copy of the original item, and then clear the original item so it can be filled with images
|
# Create a copy of the original item, and then clear the original item so it can be filled with images
|
||||||
item_cpy = copy.copy(item)
|
item_cpy = copy.copy(item)
|
||||||
@ -338,7 +341,7 @@ class MessageListener(object):
|
|||||||
item.image_border = item_cpy.image_border
|
item.image_border = item_cpy.image_border
|
||||||
item.main = item_cpy.main
|
item.main = item_cpy.main
|
||||||
item.theme_data = item_cpy.theme_data
|
item.theme_data = item_cpy.theme_data
|
||||||
# When presenting PDF or XPS, we are using the image presentation code,
|
# When presenting PDF/XPS/OXPS, 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.
|
||||||
self.handler = None
|
self.handler = None
|
||||||
if self.handler == self.media_item.automatic:
|
if self.handler == self.media_item.automatic:
|
||||||
@ -349,7 +352,7 @@ class MessageListener(object):
|
|||||||
controller = self.live_handler
|
controller = self.live_handler
|
||||||
else:
|
else:
|
||||||
controller = self.preview_handler
|
controller = self.preview_handler
|
||||||
# When presenting PDF or XPS, we are using the image presentation code,
|
# When presenting PDF/XPS/OXPS, 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.
|
||||||
if self.handler is None:
|
if self.handler is None:
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
@ -43,6 +43,8 @@ if is_win():
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PDF_CONTROLLER_FILETYPES = ['pdf', 'xps', 'oxps']
|
||||||
|
|
||||||
|
|
||||||
class PdfController(PresentationController):
|
class PdfController(PresentationController):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user