forked from openlp/openlp
[merge] Merge with trunk r1754
This commit is contained in:
commit
c47f936fd5
@ -144,7 +144,7 @@ def image_to_byte(image):
|
|||||||
# convert to base64 encoding so does not get missed!
|
# convert to base64 encoding so does not get missed!
|
||||||
return byte_array.toBase64()
|
return byte_array.toBase64()
|
||||||
|
|
||||||
def resize_image(image_path, width, height, background):
|
def resize_image(image_path, width, height, background=u'#000000'):
|
||||||
"""
|
"""
|
||||||
Resize an image to fit on the current screen.
|
Resize an image to fit on the current screen.
|
||||||
|
|
||||||
@ -159,6 +159,8 @@ def resize_image(image_path, width, height, background):
|
|||||||
|
|
||||||
``background``
|
``background``
|
||||||
The background colour defaults to black.
|
The background colour defaults to black.
|
||||||
|
|
||||||
|
DO NOT REMOVE THE DEFAULT BACKGROUND VALUE!
|
||||||
"""
|
"""
|
||||||
log.debug(u'resize_image - start')
|
log.debug(u'resize_image - start')
|
||||||
reader = QtGui.QImageReader(image_path)
|
reader = QtGui.QImageReader(image_path)
|
||||||
@ -185,7 +187,7 @@ def resize_image(image_path, width, height, background):
|
|||||||
new_image = QtGui.QImage(width, height,
|
new_image = QtGui.QImage(width, height,
|
||||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||||
painter = QtGui.QPainter(new_image)
|
painter = QtGui.QPainter(new_image)
|
||||||
painter.fillRect(new_image.rect(), background)
|
painter.fillRect(new_image.rect(), QtGui.QColor(background))
|
||||||
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
|
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
|
||||||
return new_image
|
return new_image
|
||||||
|
|
||||||
|
@ -215,6 +215,8 @@ class ImageManager(QtCore.QObject):
|
|||||||
image = self._cache[name]
|
image = self._cache[name]
|
||||||
if image.image is None:
|
if image.image is None:
|
||||||
self._conversion_queue.modify_priority(image, Priority.High)
|
self._conversion_queue.modify_priority(image, Priority.High)
|
||||||
|
# make sure we are running and if not give it a kick
|
||||||
|
self.process_updates()
|
||||||
while image.image is None:
|
while image.image is None:
|
||||||
log.debug(u'get_image - waiting')
|
log.debug(u'get_image - waiting')
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@ -235,6 +237,8 @@ class ImageManager(QtCore.QObject):
|
|||||||
image = self._cache[name]
|
image = self._cache[name]
|
||||||
if image.image_bytes is None:
|
if image.image_bytes is None:
|
||||||
self._conversion_queue.modify_priority(image, Priority.Urgent)
|
self._conversion_queue.modify_priority(image, Priority.Urgent)
|
||||||
|
# make sure we are running and if not give it a kick
|
||||||
|
self.process_updates()
|
||||||
while image.image_bytes is None:
|
while image.image_bytes is None:
|
||||||
log.debug(u'get_image_bytes - waiting')
|
log.debug(u'get_image_bytes - waiting')
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtGui, QtCore, QtWebKit
|
|||||||
|
|
||||||
from openlp.core.lib import ServiceItem, expand_tags, \
|
from openlp.core.lib import ServiceItem, expand_tags, \
|
||||||
build_lyrics_format_css, build_lyrics_outline_css, Receiver, \
|
build_lyrics_format_css, build_lyrics_outline_css, Receiver, \
|
||||||
ItemCapabilities
|
ItemCapabilities, FormattingTags
|
||||||
from openlp.core.lib.theme import ThemeLevel
|
from openlp.core.lib.theme import ThemeLevel
|
||||||
from openlp.core.ui import MainDisplay, ScreenList
|
from openlp.core.ui import MainDisplay, ScreenList
|
||||||
|
|
||||||
@ -439,6 +439,50 @@ class Renderer(object):
|
|||||||
log.debug(u'_paginate_slide_words - End')
|
log.debug(u'_paginate_slide_words - End')
|
||||||
return formatted
|
return formatted
|
||||||
|
|
||||||
|
def _get_start_tags(self, raw_text):
|
||||||
|
"""
|
||||||
|
Tests the given text for not closed formatting tags and returns a tuple
|
||||||
|
consisting of three unicode strings::
|
||||||
|
|
||||||
|
(u'{st}{r}Text text text{/r}{/st}', u'{st}{r}', u'<strong>
|
||||||
|
<span style="-webkit-text-fill-color:red">')
|
||||||
|
|
||||||
|
The first unicode string is the text, with correct closing tags. The
|
||||||
|
second unicode string are OpenLP's opening formatting tags and the third
|
||||||
|
unicode string the html opening formatting tags.
|
||||||
|
|
||||||
|
``raw_text``
|
||||||
|
The text to test. The text must **not** contain html tags, only
|
||||||
|
OpenLP formatting tags are allowed::
|
||||||
|
|
||||||
|
{st}{r}Text text text
|
||||||
|
"""
|
||||||
|
raw_tags = []
|
||||||
|
html_tags = []
|
||||||
|
for tag in FormattingTags.get_html_tags():
|
||||||
|
if tag[u'start tag'] == u'{br}':
|
||||||
|
continue
|
||||||
|
if raw_text.count(tag[u'start tag']) != \
|
||||||
|
raw_text.count(tag[u'end tag']):
|
||||||
|
raw_tags.append(
|
||||||
|
(raw_text.find(tag[u'start tag']), tag[u'start tag'],
|
||||||
|
tag[u'end tag']))
|
||||||
|
html_tags.append(
|
||||||
|
(raw_text.find(tag[u'start tag']), tag[u'start html']))
|
||||||
|
# Sort the lists, so that the tags which were opened first on the first
|
||||||
|
# slide (the text we are checking) will be opened first on the next
|
||||||
|
# slide as well.
|
||||||
|
raw_tags.sort(key=lambda tag: tag[0])
|
||||||
|
html_tags.sort(key=lambda tag: tag[0])
|
||||||
|
# Create a list with closing tags for the raw_text.
|
||||||
|
end_tags = [tag[2] for tag in raw_tags]
|
||||||
|
end_tags.reverse()
|
||||||
|
# Remove the indexes.
|
||||||
|
raw_tags = [tag[1] for tag in raw_tags]
|
||||||
|
html_tags = [tag[1] for tag in html_tags]
|
||||||
|
return raw_text + u''.join(end_tags), u''.join(raw_tags), \
|
||||||
|
u''.join(html_tags)
|
||||||
|
|
||||||
def _binary_chop(self, formatted, previous_html, previous_raw, html_list,
|
def _binary_chop(self, formatted, previous_html, previous_raw, html_list,
|
||||||
raw_list, separator, line_end):
|
raw_list, separator, line_end):
|
||||||
"""
|
"""
|
||||||
@ -490,8 +534,10 @@ class Renderer(object):
|
|||||||
# We found the number of words which will fit.
|
# We found the number of words which will fit.
|
||||||
if smallest_index == index or highest_index == index:
|
if smallest_index == index or highest_index == index:
|
||||||
index = smallest_index
|
index = smallest_index
|
||||||
formatted.append(previous_raw.rstrip(u'<br>') +
|
text = previous_raw.rstrip(u'<br>') + \
|
||||||
separator.join(raw_list[:index + 1]))
|
separator.join(raw_list[:index + 1])
|
||||||
|
text, raw_tags, html_tags = self._get_start_tags(text)
|
||||||
|
formatted.append(text)
|
||||||
previous_html = u''
|
previous_html = u''
|
||||||
previous_raw = u''
|
previous_raw = u''
|
||||||
# Stop here as the theme line count was requested.
|
# Stop here as the theme line count was requested.
|
||||||
@ -502,17 +548,19 @@ class Renderer(object):
|
|||||||
continue
|
continue
|
||||||
# Check if the remaining elements fit on the slide.
|
# Check if the remaining elements fit on the slide.
|
||||||
if self._text_fits_on_slide(
|
if self._text_fits_on_slide(
|
||||||
separator.join(html_list[index + 1:]).strip()):
|
html_tags + separator.join(html_list[index + 1:]).strip()):
|
||||||
previous_html = separator.join(
|
previous_html = html_tags + separator.join(
|
||||||
html_list[index + 1:]).strip() + line_end
|
html_list[index + 1:]).strip() + line_end
|
||||||
previous_raw = separator.join(
|
previous_raw = raw_tags + separator.join(
|
||||||
raw_list[index + 1:]).strip() + line_end
|
raw_list[index + 1:]).strip() + line_end
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# The remaining elements do not fit, thus reset the indexes,
|
# The remaining elements do not fit, thus reset the indexes,
|
||||||
# create a new list and continue.
|
# create a new list and continue.
|
||||||
raw_list = raw_list[index + 1:]
|
raw_list = raw_list[index + 1:]
|
||||||
|
raw_list[0] = raw_tags + raw_list[0]
|
||||||
html_list = html_list[index + 1:]
|
html_list = html_list[index + 1:]
|
||||||
|
html_list[0] = html_tags + html_list[0]
|
||||||
smallest_index = 0
|
smallest_index = 0
|
||||||
highest_index = len(html_list) - 1
|
highest_index = len(html_list) - 1
|
||||||
index = int(highest_index / 2)
|
index = int(highest_index / 2)
|
||||||
|
@ -606,7 +606,6 @@ class AudioPlayer(QtCore.QObject):
|
|||||||
self.stop()
|
self.stop()
|
||||||
for path in self.mediaObject.outputPaths():
|
for path in self.mediaObject.outputPaths():
|
||||||
path.disconnect()
|
path.disconnect()
|
||||||
QtCore.QObject.__del__(self)
|
|
||||||
|
|
||||||
def onAboutToFinish(self):
|
def onAboutToFinish(self):
|
||||||
"""
|
"""
|
||||||
|
@ -56,6 +56,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
MediaManagerItem.__init__(self, parent, plugin, icon)
|
MediaManagerItem.__init__(self, parent, plugin, icon)
|
||||||
self.message_listener = MessageListener(self)
|
self.message_listener = MessageListener(self)
|
||||||
self.hasSearch = True
|
self.hasSearch = True
|
||||||
|
self.singleServiceItem = False
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild)
|
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild)
|
||||||
# Allow DnD from the desktop
|
# Allow DnD from the desktop
|
||||||
|
Loading…
Reference in New Issue
Block a user