From c7ab79f9870e7813046347fb514cf252a612b7fb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 6 Sep 2011 13:56:52 +0200 Subject: [PATCH 01/13] fixed bug 805088 --- openlp/core/lib/renderer.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8353ddc19..3c1bb9be8 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -31,7 +31,7 @@ from PyQt4 import QtGui, QtCore, QtWebKit from openlp.core.lib import ServiceItem, expand_tags, \ build_lyrics_format_css, build_lyrics_outline_css, Receiver, \ - ItemCapabilities + ItemCapabilities, FormattingTags from openlp.core.lib.theme import ThemeLevel from openlp.core.ui import MainDisplay, ScreenList @@ -377,7 +377,8 @@ class Renderer(object): separator = u'
' html_lines = map(expand_tags, lines) # Text too long so go to next page. - if not self._text_fits_on_slide(separator.join(html_lines)): + text = separator.join(html_lines) + if not self._text_fits_on_slide(text): html_text, previous_raw = self._binary_chop(formatted, previous_html, previous_raw, html_lines, lines, separator, u'') else: @@ -439,6 +440,22 @@ class Renderer(object): log.debug(u'_paginate_slide_words - End') return formatted + def _get_start_tags(self, text): + missing_raw_tags = [] + missing_html_tags = [] + for tag in FormattingTags.get_html_tags(): + if tag[u'start html'] == u'
': + continue + if tag[u'start html'] in text: + missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start html']))) + missing_html_tags.append((tag[u'start html'], text.find(tag[u'start html']))) + elif tag[u'start tag'] in text: + missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start tag']))) + missing_html_tags.append((tag[u'start html'], text.find(tag[u'start tag']))) + missing_raw_tags.sort(key=lambda tag: tag[1]) + missing_html_tags.sort(key=lambda tag: tag[1]) + return u''.join(missing_raw_tags), u''.join(missing_html_tags) + def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): """ @@ -490,8 +507,10 @@ class Renderer(object): # We found the number of words which will fit. if smallest_index == index or highest_index == index: index = smallest_index - formatted.append(previous_raw.rstrip(u'
') + - separator.join(raw_list[:index + 1])) + text = previous_raw.rstrip(u'
') + \ + separator.join(raw_list[:index + 1]) + formatted.append(text) + raw_tags, html_tags = self._get_start_tags(text) previous_html = u'' previous_raw = u'' # Stop here as the theme line count was requested. @@ -502,17 +521,19 @@ class Renderer(object): continue # Check if the remaining elements fit on the slide. if self._text_fits_on_slide( - separator.join(html_list[index + 1:]).strip()): - previous_html = separator.join( + html_tags + separator.join(html_list[index + 1:]).strip()): + previous_html = html_tags + separator.join( html_list[index + 1:]).strip() + line_end - previous_raw = separator.join( + previous_raw = raw_tags + separator.join( raw_list[index + 1:]).strip() + line_end break else: # The remaining elements do not fit, thus reset the indexes, # create a new list and continue. raw_list = raw_list[index + 1:] + raw_list[0] = raw_tags + raw_list[0] html_list = html_list[index + 1:] + html_list[0] = html_tags + html_list[0] smallest_index = 0 highest_index = len(html_list) - 1 index = int(highest_index / 2) From 4c869fa1f54619d6a8782d197b2d74504666a655 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 6 Sep 2011 13:57:31 +0200 Subject: [PATCH 02/13] fixed bug 805088 Fixes: https://launchpad.net/bugs/805088 From 3c3339f114643e1a06d8b2a2c1a93d09d454f014 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 18 Sep 2011 12:26:47 +0200 Subject: [PATCH 03/13] final fixes and clean ups --- openlp/core/lib/renderer.py | 46 ++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 3c1bb9be8..bf7319da0 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -440,21 +440,41 @@ class Renderer(object): log.debug(u'_paginate_slide_words - End') return formatted - def _get_start_tags(self, text): - missing_raw_tags = [] - missing_html_tags = [] + def _get_start_tags(self, raw_text): + """ + Tests the given text for not closed formatting tags and returns a tuple + consisting of two unicode strings:: + + (u'{st}{r}', u'') + + The returned strings can be prepended to the next slide. The first + unicode string are OpenLP's formatting tags and the second unicode + string the html formatting tags. + + ``raw_text`` + The text to test. The text must **not** contain html tags, only + OpenLP formatting tags are allowed. + """ + raw_tags = [] + html_tags = [] for tag in FormattingTags.get_html_tags(): - if tag[u'start html'] == u'
': + if tag[u'start tag'] == u'{br}': continue - if tag[u'start html'] in text: - missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start html']))) - missing_html_tags.append((tag[u'start html'], text.find(tag[u'start html']))) - elif tag[u'start tag'] in text: - missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start tag']))) - missing_html_tags.append((tag[u'start html'], text.find(tag[u'start tag']))) - missing_raw_tags.sort(key=lambda tag: tag[1]) - missing_html_tags.sort(key=lambda tag: tag[1]) - return u''.join(missing_raw_tags), u''.join(missing_html_tags) + if tag[u'start tag'] in raw_text and not \ + tag[u'end tag'] in raw_text: + raw_tags.append( + (tag[u'start tag'], raw_text.find(tag[u'start tag']))) + html_tags.append( + (tag[u'start html'], raw_text.find(tag[u'start tag']))) + # 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[1]) + html_tags.sort(key=lambda tag: tag[1]) + # Remove the indexes. + raw_tags = [tag[0] for tag in raw_tags] + html_tags = [tag[0] for tag in html_tags] + return u''.join(raw_tags), u''.join(html_tags) def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): From ceec3d6f3a52b3c752d71ee74f3d35d16c478093 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 18 Sep 2011 12:32:27 +0200 Subject: [PATCH 04/13] reverted not necessary change --- openlp/core/lib/renderer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bf7319da0..37443a76c 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -377,8 +377,7 @@ class Renderer(object): separator = u'
' html_lines = map(expand_tags, lines) # Text too long so go to next page. - text = separator.join(html_lines) - if not self._text_fits_on_slide(text): + if not self._text_fits_on_slide(separator.join(html_lines)): html_text, previous_raw = self._binary_chop(formatted, previous_html, previous_raw, html_lines, lines, separator, u'') else: From 724e2be04faecf2b8af5504bb54447ef046b6eb6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 19 Sep 2011 18:00:27 +0200 Subject: [PATCH 05/13] close tags --- openlp/core/lib/renderer.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 37443a76c..f08ca38fa 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -442,17 +442,20 @@ class Renderer(object): def _get_start_tags(self, raw_text): """ Tests the given text for not closed formatting tags and returns a tuple - consisting of two unicode strings:: + consisting of three unicode strings:: - (u'{st}{r}', u'') + (u'{st}{r}Text text text{/st}{/r}', u'{st}{r}', u' + ') - The returned strings can be prepended to the next slide. The first - unicode string are OpenLP's formatting tags and the second unicode - string the html formatting tags. + 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. + OpenLP formatting tags are allowed:: + + {st}{r}Text text text """ raw_tags = [] html_tags = [] @@ -462,18 +465,23 @@ class Renderer(object): if tag[u'start tag'] in raw_text and not \ tag[u'end tag'] in raw_text: raw_tags.append( - (tag[u'start tag'], raw_text.find(tag[u'start tag']))) + (raw_text.find(tag[u'start tag']), tag[u'start tag'], + tag[u'end tag'])) html_tags.append( - (tag[u'start html'], raw_text.find(tag[u'start tag']))) + (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[1]) - html_tags.sort(key=lambda tag: tag[1]) + 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[0] for tag in raw_tags] - html_tags = [tag[0] for tag in html_tags] - return u''.join(raw_tags), u''.join(html_tags) + 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, raw_list, separator, line_end): @@ -528,8 +536,8 @@ class Renderer(object): index = smallest_index text = previous_raw.rstrip(u'
') + \ separator.join(raw_list[:index + 1]) + text, raw_tags, html_tags = self._get_start_tags(text) formatted.append(text) - raw_tags, html_tags = self._get_start_tags(text) previous_html = u'' previous_raw = u'' # Stop here as the theme line count was requested. From 240d612948e2aefc5a26a6eaf49b6dfa41fa9acb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 19 Sep 2011 18:13:38 +0200 Subject: [PATCH 06/13] fixed doc --- openlp/core/lib/renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f08ca38fa..68ca7f1a9 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -444,7 +444,7 @@ class Renderer(object): Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: - (u'{st}{r}Text text text{/st}{/r}', u'{st}{r}', u' + (u'{st}{r}Text text text{/r}{/st}', u'{st}{r}', u' ') The first unicode string is the text, with correct closing tags. The From 429a1a4541da8f63d6b41857ed3a1d16bc2d8d54 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 19 Sep 2011 20:55:34 +0200 Subject: [PATCH 07/13] Remove reference to the non-existent __del__ method. Fixes: https://launchpad.net/bugs/854125 --- openlp/core/ui/maindisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 297f5430b..06afb0313 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -606,7 +606,6 @@ class AudioPlayer(QtCore.QObject): self.stop() for path in self.mediaObject.outputPaths(): path.disconnect() - QtCore.QObject.__del__(self) def onAboutToFinish(self): """ From 834ed570cee03b32beb16110a90f2da86bec353c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 20 Sep 2011 16:23:29 +0100 Subject: [PATCH 08/13] Fix bug where string is added to image instead of QColor. Fix issue where queue has records to process but it is not running. Fixes: https://launchpad.net/bugs/854171 --- openlp/core/lib/__init__.py | 2 +- openlp/core/lib/imagemanager.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 2c0b53a95..1454f877e 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -185,7 +185,7 @@ def resize_image(image_path, width, height, background): new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) 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) return new_image diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 4d6c90078..14444a8a8 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -215,6 +215,8 @@ class ImageManager(QtCore.QObject): image = self._cache[name] if image.image is None: self._conversion_queue.modify_priority(image, Priority.High) + # make sure we are runnning and if not give it a kick + self.process_updates() while image.image is None: log.debug(u'get_image - waiting') time.sleep(0.1) @@ -235,6 +237,8 @@ class ImageManager(QtCore.QObject): image = self._cache[name] if image.image_bytes is None: self._conversion_queue.modify_priority(image, Priority.Urgent) + # make sure we are runnning and if not give it a kick + self.process_updates() while image.image_bytes is None: log.debug(u'get_image_bytes - waiting') time.sleep(0.1) @@ -279,6 +283,7 @@ class ImageManager(QtCore.QObject): """ log.debug(u'_process_cache') image = self._conversion_queue.get()[1] + print image # Generate the QImage for the image. if image.image is None: image.image = resize_image(image.path, self.width, self.height, From 47b7379967a1bb10e83cc93ab3fd63d377dfe42f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 20 Sep 2011 16:41:04 +0100 Subject: [PATCH 09/13] Fix spelling and remove print statement --- openlp/core/lib/imagemanager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 14444a8a8..0dcc2246b 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -215,7 +215,7 @@ class ImageManager(QtCore.QObject): image = self._cache[name] if image.image is None: self._conversion_queue.modify_priority(image, Priority.High) - # make sure we are runnning and if not give it a kick + # make sure we are running and if not give it a kick self.process_updates() while image.image is None: log.debug(u'get_image - waiting') @@ -237,7 +237,7 @@ class ImageManager(QtCore.QObject): image = self._cache[name] if image.image_bytes is None: self._conversion_queue.modify_priority(image, Priority.Urgent) - # make sure we are runnning and if not give it a kick + # make sure we are running and if not give it a kick self.process_updates() while image.image_bytes is None: log.debug(u'get_image_bytes - waiting') @@ -283,7 +283,6 @@ class ImageManager(QtCore.QObject): """ log.debug(u'_process_cache') image = self._conversion_queue.get()[1] - print image # Generate the QImage for the image. if image.image is None: image.image = resize_image(image.path, self.width, self.height, From 920a65b4e1ee899595df7e953e99a5dcf53f0cb2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 20 Sep 2011 17:50:43 +0200 Subject: [PATCH 10/13] fix detection when tag exists more than once --- openlp/core/lib/renderer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 68ca7f1a9..abfd658ba 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -462,8 +462,8 @@ class Renderer(object): for tag in FormattingTags.get_html_tags(): if tag[u'start tag'] == u'{br}': continue - if tag[u'start tag'] in raw_text and not \ - tag[u'end tag'] in raw_text: + 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'])) From 54a1e25cb7e90a809977e937033b71bf13c02497 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 20 Sep 2011 18:24:07 +0200 Subject: [PATCH 11/13] Trying to fix bug #803342 --- openlp/core/utils/__init__.py | 6 +++--- openlp/plugins/presentations/lib/mediaitem.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 3612bb002..2d800d1b0 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -475,11 +475,11 @@ def get_uno_command(): Returns the UNO command to launch an openoffice.org instance. """ COMMAND = u'soffice' - OPTIONS = u'-nologo -norestore -minimized -nodefault -nofirststartwizard' + OPTIONS = u'--nologo --norestore --minimized --nodefault --nofirststartwizard' if UNO_CONNECTION_TYPE == u'pipe': - CONNECTION = u'"-accept=pipe,name=openlp_pipe;urp;"' + CONNECTION = u'"--accept=pipe,name=openlp_pipe;urp;"' else: - CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"' + CONNECTION = u'"--accept=socket,host=localhost,port=2002;urp;"' return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION) def get_uno_instance(resolver): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 6c997a6b6..c6455a03a 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -56,6 +56,7 @@ class PresentationMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, plugin, icon) self.message_listener = MessageListener(self) self.hasSearch = True + self.singleServiceItem = False QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild) # Allow DnD from the desktop From bd3961eb5013adf04c2bcd8b9b18acd60bf5d01d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 20 Sep 2011 18:26:04 +0200 Subject: [PATCH 12/13] Reverted a change for deprecated options (for now). --- openlp/core/utils/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 2d800d1b0..3612bb002 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -475,11 +475,11 @@ def get_uno_command(): Returns the UNO command to launch an openoffice.org instance. """ COMMAND = u'soffice' - OPTIONS = u'--nologo --norestore --minimized --nodefault --nofirststartwizard' + OPTIONS = u'-nologo -norestore -minimized -nodefault -nofirststartwizard' if UNO_CONNECTION_TYPE == u'pipe': - CONNECTION = u'"--accept=pipe,name=openlp_pipe;urp;"' + CONNECTION = u'"-accept=pipe,name=openlp_pipe;urp;"' else: - CONNECTION = u'"--accept=socket,host=localhost,port=2002;urp;"' + CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"' return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION) def get_uno_instance(resolver): From b0dc146043361df166dc616dc3d6840b5594789b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 20 Sep 2011 19:53:09 +0200 Subject: [PATCH 13/13] Added the default background colour back in so that the rest of the app that is not expecting to have to supply a background colour doesn't have to be changed. Fixes: https://launchpad.net/bugs/803342 --- openlp/core/lib/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 1454f877e..e24045883 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -144,7 +144,7 @@ def image_to_byte(image): # convert to base64 encoding so does not get missed! 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. @@ -159,6 +159,8 @@ def resize_image(image_path, width, height, background): ``background`` The background colour defaults to black. + + DO NOT REMOVE THE DEFAULT BACKGROUND VALUE! """ log.debug(u'resize_image - start') reader = QtGui.QImageReader(image_path)