forked from openlp/openlp
Add epub, cbz, and fb2 support to pdf controller
This commit is contained in:
parent
1c23a1f372
commit
605eadb0c2
@ -333,7 +333,7 @@ class MessageListener(object):
|
|||||||
# the conversion has already been done at this point.
|
# the conversion has already been done at this point.
|
||||||
file_type = file_path.suffix.lower()[1:]
|
file_type = file_path.suffix.lower()[1:]
|
||||||
if file_type in PDF_CONTROLLER_FILETYPES:
|
if file_type in PDF_CONTROLLER_FILETYPES:
|
||||||
log.debug('Converting from pdf/xps/oxps to images for serviceitem with file {name}'.format(name=file_path))
|
log.debug('Converting from pdf/xps/oxps/epub/cbz/fb2 to images for serviceitem with file {name}'.format(name=file_path))
|
||||||
# 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)
|
||||||
item.__init__(None)
|
item.__init__(None)
|
||||||
|
@ -42,7 +42,7 @@ except ImportError:
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
PDF_CONTROLLER_FILETYPES = ['pdf', 'xps', 'oxps']
|
PDF_CONTROLLER_FILETYPES = ['pdf', 'xps', 'oxps', 'epub', 'cbz', 'fb2']
|
||||||
|
|
||||||
|
|
||||||
class PdfController(PresentationController):
|
class PdfController(PresentationController):
|
||||||
@ -128,7 +128,7 @@ class PdfController(PresentationController):
|
|||||||
elif program_type == 'mutool':
|
elif program_type == 'mutool':
|
||||||
self.mutoolbin = program_path
|
self.mutoolbin = program_path
|
||||||
elif PYMUPDF_AVAILABLE:
|
elif PYMUPDF_AVAILABLE:
|
||||||
self.also_supports = ['xps', 'oxps']
|
self.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
# Fallback to autodetection
|
# Fallback to autodetection
|
||||||
@ -156,7 +156,7 @@ class PdfController(PresentationController):
|
|||||||
elif (application_path / 'mutool').is_file():
|
elif (application_path / 'mutool').is_file():
|
||||||
self.mutoolbin = application_path / 'mutool'
|
self.mutoolbin = application_path / 'mutool'
|
||||||
if self.mudrawbin or self.mutoolbin:
|
if self.mudrawbin or self.mutoolbin:
|
||||||
self.also_supports = ['xps', 'oxps']
|
self.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
|
||||||
return True
|
return True
|
||||||
elif self.gsbin:
|
elif self.gsbin:
|
||||||
return True
|
return True
|
||||||
|
@ -65,7 +65,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
pdf_controller = MagicMock()
|
pdf_controller = MagicMock()
|
||||||
pdf_controller.enabled.return_value = True
|
pdf_controller.enabled.return_value = True
|
||||||
pdf_controller.supports = ['pdf']
|
pdf_controller.supports = ['pdf']
|
||||||
pdf_controller.also_supports = ['xps', 'oxps']
|
pdf_controller.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
|
||||||
# Mock the controllers.
|
# Mock the controllers.
|
||||||
self.media_item.controllers = {
|
self.media_item.controllers = {
|
||||||
'Impress': impress_controller,
|
'Impress': impress_controller,
|
||||||
@ -85,6 +85,9 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
assert '*.pdf' in self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension'
|
assert '*.pdf' in self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension'
|
||||||
assert '*.xps' in self.media_item.on_new_file_masks, 'The file mask should contain the xps extension'
|
assert '*.xps' in self.media_item.on_new_file_masks, 'The file mask should contain the xps extension'
|
||||||
assert '*.oxps' in self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension'
|
assert '*.oxps' in self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension'
|
||||||
|
assert '*.epub' in self.media_item.on_new_file_masks, 'The file mask should contain the epub extension'
|
||||||
|
assert '*.cbz' in self.media_item.on_new_file_masks, 'The file mask should contain the cbz extension'
|
||||||
|
assert '*.fb2' in self.media_item.on_new_file_masks, 'The file mask should contain the fb2 extension'
|
||||||
|
|
||||||
def test_clean_up_thumbnails(self):
|
def test_clean_up_thumbnails(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user