forked from openlp/openlp
head
This commit is contained in:
commit
3cfdd3de45
@ -7,7 +7,7 @@
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
@ -144,6 +144,59 @@ def image_to_byte(image):
|
||||
# convert to base64 encoding so does not get missed!
|
||||
return byte_array.toBase64()
|
||||
|
||||
def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
||||
"""
|
||||
Create a thumbnail from the given image path and depending on
|
||||
``return_icon`` it returns an icon from this thumb.
|
||||
|
||||
``image_path``
|
||||
The image file to create the icon from.
|
||||
|
||||
``thumb_path``
|
||||
The filename to save the thumbnail to.
|
||||
|
||||
``return_icon``
|
||||
States if an icon should be build and returned from the thumb. Defaults
|
||||
to ``True``.
|
||||
|
||||
``size``
|
||||
Allows to state a own size to use. Defaults to ``None``, which means
|
||||
that a default height of 88 is used.
|
||||
"""
|
||||
ext = os.path.splitext(thumb_path)[1].lower()
|
||||
reader = QtGui.QImageReader(image_path)
|
||||
if size is None:
|
||||
ratio = float(reader.size().width()) / float(reader.size().height())
|
||||
reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
|
||||
else:
|
||||
reader.setScaledSize(size)
|
||||
thumb = reader.read()
|
||||
thumb.save(thumb_path, ext[1:])
|
||||
if not return_icon:
|
||||
return
|
||||
if os.path.exists(thumb_path):
|
||||
return build_icon(unicode(thumb_path))
|
||||
# Fallback for files with animation support.
|
||||
return build_icon(unicode(image_path))
|
||||
|
||||
def validate_thumb(file_path, thumb_path):
|
||||
"""
|
||||
Validates whether an file's thumb still exists and if is up to date.
|
||||
**Note**, you must **not** call this function, before checking the
|
||||
existence of the file.
|
||||
|
||||
``file_path``
|
||||
The path to the file. The file **must** exist!
|
||||
|
||||
``thumb_path``
|
||||
The path to the thumb.
|
||||
"""
|
||||
if not os.path.exists(unicode(thumb_path)):
|
||||
return False
|
||||
image_date = os.stat(unicode(file_path)).st_mtime
|
||||
thumb_date = os.stat(unicode(thumb_path)).st_mtime
|
||||
return image_date <= thumb_date
|
||||
|
||||
def resize_image(image_path, width, height, background=u'#000000'):
|
||||
"""
|
||||
Resize an image to fit on the current screen.
|
||||
@ -158,7 +211,7 @@ def resize_image(image_path, width, height, background=u'#000000'):
|
||||
The new image height.
|
||||
|
||||
``background``
|
||||
The background colour defaults to black.
|
||||
The background colour. Defaults to black.
|
||||
|
||||
DO NOT REMOVE THE DEFAULT BACKGROUND VALUE!
|
||||
"""
|
||||
|
@ -51,9 +51,6 @@ class EventReceiver(QtCore.QObject):
|
||||
``config_screen_changed``
|
||||
The display monitor has been changed
|
||||
|
||||
``slidecontroller_{live|preview}_first``
|
||||
Moves to the first slide
|
||||
|
||||
``slidecontroller_{live|preview}_next``
|
||||
Moves to the next slide
|
||||
|
||||
@ -66,9 +63,6 @@ class EventReceiver(QtCore.QObject):
|
||||
``slidecontroller_{live|preview}_previous_noloop``
|
||||
Moves to the previous slide, without auto advance
|
||||
|
||||
``slidecontroller_{live|preview}_last``
|
||||
Moves to the last slide
|
||||
|
||||
``slidecontroller_{live|preview}_set``
|
||||
Moves to a specific slide, by index
|
||||
|
||||
@ -82,11 +76,6 @@ class EventReceiver(QtCore.QObject):
|
||||
``slidecontroller_{live|preview}_changed``
|
||||
Broadcasts that the slidecontroller has changed the current slide
|
||||
|
||||
``slidecontroller_{live|preview}_text_request``
|
||||
Request the text for the current item in the controller
|
||||
Returns a slidecontroller_{live|preview}_text_response with an
|
||||
array of dictionaries with the tag and verse text
|
||||
|
||||
``slidecontroller_{live|preview}_blank``
|
||||
Request that the output screen is blanked
|
||||
|
||||
|
@ -425,44 +425,6 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
count += 1
|
||||
return filelist
|
||||
|
||||
def validate(self, image, thumb):
|
||||
"""
|
||||
Validates whether an image still exists and, if it does, is the
|
||||
thumbnail representation of the image up to date.
|
||||
"""
|
||||
if not os.path.exists(unicode(image)):
|
||||
return False
|
||||
if os.path.exists(thumb):
|
||||
imageDate = os.stat(unicode(image)).st_mtime
|
||||
thumbDate = os.stat(unicode(thumb)).st_mtime
|
||||
# If image has been updated rebuild icon
|
||||
if imageDate > thumbDate:
|
||||
self.iconFromFile(image, thumb)
|
||||
else:
|
||||
self.iconFromFile(image, thumb)
|
||||
return True
|
||||
|
||||
def iconFromFile(self, image_path, thumb_path):
|
||||
"""
|
||||
Create a thumbnail icon from a given image.
|
||||
|
||||
``image_path``
|
||||
The image file to create the icon from.
|
||||
|
||||
``thumb_path``
|
||||
The filename to save the thumbnail to.
|
||||
"""
|
||||
ext = os.path.splitext(thumb_path)[1].lower()
|
||||
reader = QtGui.QImageReader(image_path)
|
||||
ratio = float(reader.size().width()) / float(reader.size().height())
|
||||
reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
|
||||
thumb = reader.read()
|
||||
thumb.save(thumb_path, ext[1:])
|
||||
if os.path.exists(thumb_path):
|
||||
return build_icon(unicode(thumb_path))
|
||||
# Fallback for files with animation support.
|
||||
return build_icon(unicode(image_path))
|
||||
|
||||
def loadList(self, list):
|
||||
raise NotImplementedError(u'MediaManagerItem.loadList needs to be '
|
||||
u'defined by the plugin')
|
||||
|
@ -201,7 +201,8 @@ class Renderer(object):
|
||||
if not self.force_page:
|
||||
self.display.buildHtml(serviceItem)
|
||||
raw_html = serviceItem.get_rendered_frame(0)
|
||||
preview = self.display.text(raw_html)
|
||||
self.display.text(raw_html)
|
||||
preview = self.display.preview()
|
||||
# Reset the real screen size for subsequent render requests
|
||||
self._calculate_default()
|
||||
return preview
|
||||
|
@ -194,7 +194,6 @@ class MainDisplay(QtGui.QGraphicsView):
|
||||
self.setGeometry(self.screen[u'size'])
|
||||
self.frame.evaluateJavaScript(u'show_text("%s")' %
|
||||
slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
|
||||
return self.preview()
|
||||
|
||||
def alert(self, text):
|
||||
"""
|
||||
@ -256,7 +255,6 @@ class MainDisplay(QtGui.QGraphicsView):
|
||||
image = self.imageManager.get_image_bytes(name)
|
||||
self.resetVideo()
|
||||
self.displayImage(image)
|
||||
return self.preview()
|
||||
|
||||
def displayImage(self, image):
|
||||
"""
|
||||
@ -387,7 +385,6 @@ class MainDisplay(QtGui.QGraphicsView):
|
||||
# Update the preview frame.
|
||||
if self.isLive:
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
return self.preview()
|
||||
|
||||
def videoState(self, newState, oldState):
|
||||
"""
|
||||
@ -455,9 +452,8 @@ class MainDisplay(QtGui.QGraphicsView):
|
||||
self.setVisible(True)
|
||||
else:
|
||||
self.setVisible(True)
|
||||
preview = QtGui.QImage(self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height(),
|
||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
preview = QtGui.QPixmap(self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height())
|
||||
painter = QtGui.QPainter(preview)
|
||||
painter.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
self.frame.render(painter)
|
||||
|
@ -118,7 +118,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.previewListWidget.horizontalHeader().setVisible(False)
|
||||
self.previewListWidget.setColumnWidth(0, self.controller.width())
|
||||
self.previewListWidget.isLive = self.isLive
|
||||
self.previewListWidget.setObjectName(u'PreviewListWidget')
|
||||
self.previewListWidget.setObjectName(u'previewListWidget')
|
||||
self.previewListWidget.setSelectionBehavior(
|
||||
QtGui.QAbstractItemView.SelectRows)
|
||||
self.previewListWidget.setSelectionMode(
|
||||
@ -288,14 +288,14 @@ class SlideController(QtGui.QWidget):
|
||||
QtGui.QSizePolicy.Label))
|
||||
self.previewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
|
||||
self.previewFrame.setFrameShadow(QtGui.QFrame.Sunken)
|
||||
self.previewFrame.setObjectName(u'PreviewFrame')
|
||||
self.previewFrame.setObjectName(u'previewFrame')
|
||||
self.grid = QtGui.QGridLayout(self.previewFrame)
|
||||
self.grid.setMargin(8)
|
||||
self.grid.setObjectName(u'grid')
|
||||
self.slideLayout = QtGui.QVBoxLayout()
|
||||
self.slideLayout.setSpacing(0)
|
||||
self.slideLayout.setMargin(0)
|
||||
self.slideLayout.setObjectName(u'SlideLayout')
|
||||
self.slideLayout.setObjectName(u'slideLayout')
|
||||
if not self.isLive:
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
self.video = Phonon.VideoWidget()
|
||||
@ -319,7 +319,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.slidePreview.setFrameShadow(QtGui.QFrame.Plain)
|
||||
self.slidePreview.setLineWidth(1)
|
||||
self.slidePreview.setScaledContents(True)
|
||||
self.slidePreview.setObjectName(u'SlidePreview')
|
||||
self.slidePreview.setObjectName(u'slidePreview')
|
||||
self.slideLayout.insertWidget(0, self.slidePreview)
|
||||
self.grid.addLayout(self.slideLayout, 0, 0, 1, 1)
|
||||
# Signals
|
||||
@ -328,8 +328,6 @@ class SlideController(QtGui.QWidget):
|
||||
if self.isLive:
|
||||
QtCore.QObject.connect(self.volumeSlider,
|
||||
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_spin_delay'),
|
||||
self.receiveSpinDelay)
|
||||
@ -351,18 +349,12 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
|
||||
self.onStopLoop)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_first' % self.typePrefix),
|
||||
self.onSlideSelectedFirst)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.typePrefix),
|
||||
self.onSlideSelectedNext)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.typePrefix),
|
||||
self.onSlideSelectedPrevious)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_last' % self.typePrefix),
|
||||
self.onSlideSelectedLast)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.typePrefix),
|
||||
self.onSlideChange)
|
||||
@ -375,9 +367,6 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix),
|
||||
self.onSlideUnblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.typePrefix),
|
||||
self.onTextRequest)
|
||||
|
||||
def setPreviewHotkeys(self, parent=None):
|
||||
self.previousItem.setObjectName(u'previousItemPreview')
|
||||
@ -669,7 +658,7 @@ class SlideController(QtGui.QWidget):
|
||||
label.setMargin(4)
|
||||
label.setScaledContents(True)
|
||||
if self.serviceItem.is_command():
|
||||
image = QtGui.QImage(frame[u'image'])
|
||||
label.setPixmap(QtGui.QPixmap(frame[u'image']))
|
||||
else:
|
||||
# If current slide set background to image
|
||||
if framenumber == slideno:
|
||||
@ -723,41 +712,7 @@ class SlideController(QtGui.QWidget):
|
||||
else:
|
||||
self.__checkUpdateSelectedSlide(slideno)
|
||||
|
||||
def onTextRequest(self):
|
||||
"""
|
||||
Return the text for the current item in controller
|
||||
"""
|
||||
data = []
|
||||
if self.serviceItem:
|
||||
for framenumber, frame in enumerate(self.serviceItem.get_frames()):
|
||||
dataItem = {}
|
||||
if self.serviceItem.is_text():
|
||||
dataItem[u'tag'] = unicode(frame[u'verseTag'])
|
||||
dataItem[u'text'] = unicode(frame[u'html'])
|
||||
else:
|
||||
dataItem[u'tag'] = unicode(framenumber)
|
||||
dataItem[u'text'] = u''
|
||||
dataItem[u'selected'] = \
|
||||
(self.previewListWidget.currentRow() == framenumber)
|
||||
data.append(dataItem)
|
||||
Receiver.send_message(u'slidecontroller_%s_text_response'
|
||||
% self.typePrefix, data)
|
||||
|
||||
# Screen event methods
|
||||
def onSlideSelectedFirst(self):
|
||||
"""
|
||||
Go to the first slide.
|
||||
"""
|
||||
if not self.serviceItem:
|
||||
return
|
||||
if self.serviceItem.is_command():
|
||||
Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive])
|
||||
self.updatePreview()
|
||||
else:
|
||||
self.previewListWidget.selectRow(0)
|
||||
self.slideSelected()
|
||||
|
||||
def onSlideSelectedIndex(self, message):
|
||||
"""
|
||||
Go to the requested slide
|
||||
@ -936,20 +891,18 @@ class SlideController(QtGui.QWidget):
|
||||
Receiver.send_message(
|
||||
u'%s_slide' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive, row])
|
||||
self.updatePreview()
|
||||
else:
|
||||
toDisplay = self.serviceItem.get_rendered_frame(row)
|
||||
if self.serviceItem.is_text():
|
||||
frame = self.display.text(toDisplay)
|
||||
self.display.text(toDisplay)
|
||||
else:
|
||||
if start:
|
||||
self.display.buildHtml(self.serviceItem, toDisplay)
|
||||
frame = self.display.preview()
|
||||
else:
|
||||
frame = self.display.image(toDisplay)
|
||||
self.display.image(toDisplay)
|
||||
# reset the store used to display first image
|
||||
self.serviceItem.bg_image_bytes = None
|
||||
self.slidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||
self.updatePreview()
|
||||
self.selectedRow = row
|
||||
self.__checkUpdateSelectedSlide(row)
|
||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
|
||||
@ -977,8 +930,7 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
|
||||
QtCore.QTimer.singleShot(2.5, self.grabMainDisplay)
|
||||
else:
|
||||
self.slidePreview.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.display.preview()))
|
||||
self.slidePreview.setPixmap(self.display.preview())
|
||||
|
||||
def grabMainDisplay(self):
|
||||
"""
|
||||
@ -1041,21 +993,6 @@ class SlideController(QtGui.QWidget):
|
||||
self.previewListWidget.item(row + 1, 0))
|
||||
self.previewListWidget.selectRow(row)
|
||||
|
||||
def onSlideSelectedLast(self):
|
||||
"""
|
||||
Go to the last slide.
|
||||
"""
|
||||
if not self.serviceItem:
|
||||
return
|
||||
Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive])
|
||||
if self.serviceItem.is_command():
|
||||
self.updatePreview()
|
||||
else:
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
self.slideSelected()
|
||||
|
||||
def onToggleLoop(self):
|
||||
"""
|
||||
Toggles the loop state.
|
||||
|
@ -241,7 +241,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
if self.page(pageId) == self.previewPage:
|
||||
self.updateTheme()
|
||||
frame = self.thememanager.generateImage(self.theme)
|
||||
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||
self.previewBoxLabel.setPixmap(frame)
|
||||
self.displayAspectRatio = float(frame.width()) / frame.height()
|
||||
self.resizeEvent()
|
||||
|
||||
|
@ -36,7 +36,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \
|
||||
Receiver, SettingsManager, translate, check_item_selected, \
|
||||
check_directory_exists
|
||||
check_directory_exists, create_thumb, validate_thumb
|
||||
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
|
||||
BackgroundGradientType
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||
@ -359,7 +359,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
The theme to delete.
|
||||
"""
|
||||
self.themelist.remove(theme)
|
||||
thumb = theme + u'.png'
|
||||
thumb = u'%s.png' % theme
|
||||
delete_file(os.path.join(self.path, thumb))
|
||||
delete_file(os.path.join(self.thumbPath, thumb))
|
||||
try:
|
||||
@ -473,15 +473,12 @@ class ThemeManager(QtGui.QWidget):
|
||||
name = textName
|
||||
thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
|
||||
item_name = QtGui.QListWidgetItem(name)
|
||||
if os.path.exists(thumb):
|
||||
if validate_thumb(theme, thumb):
|
||||
icon = build_icon(thumb)
|
||||
else:
|
||||
icon = build_icon(theme)
|
||||
pixmap = icon.pixmap(QtCore.QSize(88, 50))
|
||||
pixmap.save(thumb, u'png')
|
||||
icon = create_thumb(theme, thumb)
|
||||
item_name.setIcon(icon)
|
||||
item_name.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(textName))
|
||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName))
|
||||
self.themeListWidget.addItem(item_name)
|
||||
self.themelist.append(textName)
|
||||
self._pushThemes()
|
||||
@ -658,9 +655,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
os.unlink(samplepathname)
|
||||
frame.save(samplepathname, u'png')
|
||||
thumb = os.path.join(self.thumbPath, u'%s.png' % name)
|
||||
icon = build_icon(frame)
|
||||
pixmap = icon.pixmap(QtCore.QSize(88, 50))
|
||||
pixmap.save(thumb, u'png')
|
||||
create_thumb(samplepathname, thumb, False)
|
||||
log.debug(u'Theme image written to %s', samplepathname)
|
||||
|
||||
def updatePreviewImages(self):
|
||||
|
@ -461,6 +461,11 @@ class BibleImportForm(OpenLPWizard):
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.OS)
|
||||
self.openSongFileEdit.setFocus()
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == \
|
||||
BibleFormat.WebDownload:
|
||||
self.versionNameEdit.setText(
|
||||
self.webTranslationComboBox.currentText())
|
||||
return True
|
||||
elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1:
|
||||
if not self.field(u'openlp1_location').toString():
|
||||
critical_error_message_box(UiStrings().NFSs,
|
||||
|
@ -28,7 +28,6 @@
|
||||
import logging
|
||||
import chardet
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
@ -82,13 +82,16 @@ class BGExtract(object):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
footnotes = soup.findAll(u'sup', u'footnote')
|
||||
if footnotes:
|
||||
[footnote.extract() for footnote in footnotes]
|
||||
for footnote in footnotes:
|
||||
footnote.extract()
|
||||
crossrefs = soup.findAll(u'sup', u'xref')
|
||||
if crossrefs:
|
||||
[crossref.extract() for crossref in crossrefs]
|
||||
for crossref in crossrefs:
|
||||
crossref.extract()
|
||||
headings = soup.findAll(u'h5')
|
||||
if headings:
|
||||
[heading.extract() for heading in headings]
|
||||
for heading in headings:
|
||||
heading.extract()
|
||||
cleanup = [(re.compile('\s+'), lambda match: ' ')]
|
||||
verses = BeautifulSoup(str(soup), markupMassage=cleanup)
|
||||
verse_list = {}
|
||||
|
@ -28,7 +28,6 @@
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, translate, Receiver
|
||||
from openlp.core.lib.ui import UiStrings, create_valign_combo
|
||||
|
||||
class ImageTab(SettingsTab):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
|
||||
SettingsManager, translate, check_item_selected, check_directory_exists, \
|
||||
Receiver
|
||||
Receiver, create_thumb, validate_thumb
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||
from openlp.core.utils import AppLocation, delete_file, get_images_filter
|
||||
|
||||
@ -127,13 +127,13 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.plugin.formparent.incrementProgressBar()
|
||||
filename = os.path.split(unicode(imageFile))[1]
|
||||
thumb = os.path.join(self.servicePath, filename)
|
||||
if os.path.exists(thumb):
|
||||
if self.validate(imageFile, thumb):
|
||||
icon = build_icon(thumb)
|
||||
else:
|
||||
if not os.path.exists(imageFile):
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
else:
|
||||
icon = self.iconFromFile(imageFile, thumb)
|
||||
if validate_thumb(imageFile, thumb):
|
||||
icon = build_icon(thumb)
|
||||
else:
|
||||
icon = create_thumb(imageFile, thumb)
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
item_name.setIcon(icon)
|
||||
item_name.setToolTip(imageFile)
|
||||
|
@ -32,7 +32,8 @@ import locale
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
|
||||
translate, check_item_selected, Receiver, ItemCapabilities
|
||||
translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \
|
||||
validate_thumb
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||
media_item_combo_box
|
||||
from openlp.plugins.presentations.lib import MessageListener
|
||||
@ -193,10 +194,13 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
doc.load_presentation()
|
||||
preview = doc.get_thumbnail_path(1, True)
|
||||
doc.close_presentation()
|
||||
if preview and self.validate(preview, thumb):
|
||||
if not (preview and os.path.exists(preview)):
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
else:
|
||||
if validate_thumb(preview, thumb):
|
||||
icon = build_icon(thumb)
|
||||
else:
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
icon = create_thumb(preview, thumb)
|
||||
else:
|
||||
if initialLoad:
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
|
@ -31,7 +31,8 @@ import shutil
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, resize_image
|
||||
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, \
|
||||
validate_thumb
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -97,8 +98,7 @@ class PresentationDocument(object):
|
||||
self.slidenumber = 0
|
||||
self.controller = controller
|
||||
self.filepath = name
|
||||
if not os.path.isdir(self.get_thumbnail_folder()):
|
||||
os.mkdir(self.get_thumbnail_folder())
|
||||
check_directory_exists(self.get_thumbnail_folder())
|
||||
|
||||
def load_presentation(self):
|
||||
"""
|
||||
@ -145,15 +145,13 @@ class PresentationDocument(object):
|
||||
|
||||
def check_thumbnails(self):
|
||||
"""
|
||||
Returns true if the thumbnail images look to exist and are more
|
||||
recent than the powerpoint
|
||||
Returns ``True`` if the thumbnail images exist and are more recent than
|
||||
the powerpoint file.
|
||||
"""
|
||||
lastimage = self.get_thumbnail_path(self.get_slide_count(), True)
|
||||
if not (lastimage and os.path.isfile(lastimage)):
|
||||
return False
|
||||
imgdate = os.stat(lastimage).st_mtime
|
||||
pptdate = os.stat(self.filepath).st_mtime
|
||||
return imgdate >= pptdate
|
||||
return validate_thumb(self.filepath, lastimage)
|
||||
|
||||
def close_presentation(self):
|
||||
"""
|
||||
@ -246,8 +244,8 @@ class PresentationDocument(object):
|
||||
if self.check_thumbnails():
|
||||
return
|
||||
if os.path.isfile(file):
|
||||
img = resize_image(file, 320, 240)
|
||||
img.save(self.get_thumbnail_path(idx, False))
|
||||
thumb_path = self.get_thumbnail_path(idx, False)
|
||||
create_thumb(file, thumb_path, False, QtCore.QSize(320, 240))
|
||||
|
||||
def get_thumbnail_path(self, slide_no, check_exists):
|
||||
"""
|
||||
@ -387,10 +385,8 @@ class PresentationController(object):
|
||||
AppLocation.get_section_data_path(self.settings_section),
|
||||
u'thumbnails')
|
||||
self.thumbnail_prefix = u'slide'
|
||||
if not os.path.isdir(self.thumbnail_folder):
|
||||
os.makedirs(self.thumbnail_folder)
|
||||
if not os.path.isdir(self.temp_folder):
|
||||
os.makedirs(self.temp_folder)
|
||||
check_directory_exists(self.thumbnail_folder)
|
||||
check_directory_exists(self.temp_folder)
|
||||
|
||||
def enabled(self):
|
||||
"""
|
||||
|
@ -87,7 +87,7 @@ class PresentationPlugin(Plugin):
|
||||
to close down their applications and release resources.
|
||||
"""
|
||||
log.info(u'Plugin Finalise')
|
||||
#Ask each controller to tidy up
|
||||
# Ask each controller to tidy up.
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
if controller.enabled():
|
||||
|
@ -333,5 +333,6 @@ class CCLIFileImport(SongImport):
|
||||
if len(author_list) < 2:
|
||||
author_list = song_author.split(u'|')
|
||||
# Clean spaces before and after author names.
|
||||
[self.addAuthor(author_name.strip()) for author_name in author_list]
|
||||
for author_name in author_list:
|
||||
self.addAuthor(author_name.strip())
|
||||
return self.finish()
|
||||
|
@ -397,7 +397,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
try:
|
||||
os.remove(media_file.file_name)
|
||||
except:
|
||||
log.exception('Could not remove file: %s', audio)
|
||||
log.exception('Could not remove file: %s',
|
||||
media_file.file_name)
|
||||
try:
|
||||
save_path = os.path.join(AppLocation.get_section_data_path(
|
||||
self.plugin.name), 'audio', str(item_id))
|
||||
|
@ -30,7 +30,6 @@ songs from the database to the OpenLyrics format.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
@ -29,7 +29,7 @@ The :mod:`upgrade` module provides a way for the database and schema that is the
|
||||
backend for the Songs plugin
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, ForeignKey, Table, types
|
||||
from sqlalchemy import Column, Table, types
|
||||
from sqlalchemy.sql.expression import func
|
||||
from migrate import changeset
|
||||
from migrate.changeset.constraint import ForeignKeyConstraint
|
||||
|
@ -28,7 +28,6 @@
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import create_accept_reject_button_box
|
||||
|
||||
class Ui_SongUsageDeleteDialog(object):
|
||||
def setupUi(self, songUsageDeleteDialog):
|
||||
|
@ -60,8 +60,6 @@
|
||||
</qresource>
|
||||
<qresource prefix="slides">
|
||||
<file>slide_close.png</file>
|
||||
<file>slide_first.png</file>
|
||||
<file>slide_last.png</file>
|
||||
<file>slide_next.png</file>
|
||||
<file>slide_blank.png</file>
|
||||
<file>slide_desktop.png</file>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 653 B |
Binary file not shown.
Before Width: | Height: | Size: 666 B |
@ -8,7 +8,7 @@
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
@ -5,11 +5,11 @@
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, #
|
||||
# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, #
|
||||
# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode #
|
||||
# Woldsund #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
|
@ -8,7 +8,7 @@
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
@ -8,7 +8,7 @@
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
Loading…
Reference in New Issue
Block a user