From 50b820af4e74bde630fcc18efc3745ed5f52a529 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 24 Aug 2011 10:34:15 +0200 Subject: [PATCH 01/13] try to fix gradient when using html5 doctype --- openlp/core/lib/htmlbuilder.py | 18 ++++++++++-------- openlp/core/ui/maindisplay.py | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 6f56cf8b2..e1a76ac43 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -36,6 +36,7 @@ log = logging.getLogger(__name__) # FIXME: Add html5 doctype. However, do not break theme gradients. HTMLSRC = u""" + OpenLP Display @@ -393,18 +394,18 @@ def build_background_css(item, width, height): """ width = int(width) / 2 theme = item.themedata - background = u'background-color: black' + background = u'background-color: black;' if theme: if theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): - background = u'background-color: %s' % theme.background_color + background = u'background-color: %s;' % theme.background_color else: if theme.background_direction == BackgroundGradientType.to_string \ (BackgroundGradientType.Horizontal): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, left bottom, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed;' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string( \ @@ -412,7 +413,7 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, right bottom, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed;' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ @@ -420,20 +421,21 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left bottom, right top, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed;' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ (BackgroundGradientType.Vertical): background = \ u'background: -webkit-gradient(linear, left top, ' \ - u'right top, from(%s), to(%s))' % \ + u'right top, from(%s), to(%s)) fixed;' % \ (theme.background_start_color, theme.background_end_color) else: background = \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ - u'50%%, %s, from(%s), to(%s))' % (width, width, width, - theme.background_start_color, theme.background_end_color) + u'50%%, %s, from(%s), to(%s)) fixed;' % (width, width, + width, theme.background_start_color, + theme.background_end_color) return background def build_lyrics_css(item, webkitvers): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9904868ce..b96fe9985 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -103,6 +103,7 @@ class MainDisplay(QtGui.QGraphicsView): self.createMediaObject() log.debug(u'Setup webView') self.webView = QtWebKit.QWebView(self) + self.webView.settings().setAttribute(7, True) self.webView.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height()) self.page = self.webView.page() From cd33d807fcf9d4cbc7c429e944ed40ec088e9d2a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 18 Sep 2011 12:28:10 +0200 Subject: [PATCH 02/13] removed test code --- 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 b96fe9985..9904868ce 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -103,7 +103,6 @@ class MainDisplay(QtGui.QGraphicsView): self.createMediaObject() log.debug(u'Setup webView') self.webView = QtWebKit.QWebView(self) - self.webView.settings().setAttribute(7, True) self.webView.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height()) self.page = self.webView.page() From d856e957b4624b89f6cf6ed2fb80974e49fd1dbe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 18 Sep 2011 12:30:14 +0200 Subject: [PATCH 03/13] removed FIXME --- openlp/core/lib/htmlbuilder.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index e1a76ac43..1a879017b 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -34,7 +34,6 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \ log = logging.getLogger(__name__) -# FIXME: Add html5 doctype. However, do not break theme gradients. HTMLSRC = u""" From 734c868223b9c2fdc8b337e875faca118bca6e68 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 18 Sep 2011 17:39:12 +0200 Subject: [PATCH 04/13] removed semicolon --- openlp/core/lib/htmlbuilder.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 1a879017b..c67700a29 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -393,18 +393,18 @@ def build_background_css(item, width, height): """ width = int(width) / 2 theme = item.themedata - background = u'background-color: black;' + background = u'background-color: black' if theme: if theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): - background = u'background-color: %s;' % theme.background_color + background = u'background-color: %s' % theme.background_color else: if theme.background_direction == BackgroundGradientType.to_string \ (BackgroundGradientType.Horizontal): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, left bottom, ' \ - 'from(%s), to(%s)) fixed;' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string( \ @@ -412,7 +412,7 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, right bottom, ' \ - 'from(%s), to(%s)) fixed;' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ @@ -420,19 +420,19 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left bottom, right top, ' \ - 'from(%s), to(%s)) fixed;' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ (BackgroundGradientType.Vertical): background = \ u'background: -webkit-gradient(linear, left top, ' \ - u'right top, from(%s), to(%s)) fixed;' % \ + u'right top, from(%s), to(%s)) fixed' % \ (theme.background_start_color, theme.background_end_color) else: background = \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ - u'50%%, %s, from(%s), to(%s)) fixed;' % (width, width, + u'50%%, %s, from(%s), to(%s)) fixed' % (width, width, width, theme.background_start_color, theme.background_end_color) return background From 9841406071d0ee78c1631df8a4b3c33f122f6fd5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 24 Sep 2011 14:54:27 +0200 Subject: [PATCH 05/13] minor improvement for such cases where [---] was used --- openlp/core/lib/renderer.py | 99 +++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 55 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index abfd658ba..b5646bc5d 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -224,54 +224,52 @@ class Renderer(object): # Bibles if item.is_capable(ItemCapabilities.CanWordSplit): pages = self._paginate_slide_words(text.split(u'\n'), line_end) - else: - # Clean up line endings. - lines = self._lines_split(text) - pages = self._paginate_slide(lines, line_end) - # Songs and Custom - if item.is_capable(ItemCapabilities.CanSoftBreak) and \ - len(pages) > 1 and u'[---]' in text: - pages = [] - while True: - slides = text.split(u'\n[---]\n', 2) - # If there are (at least) two occurrences of [---] we use - # the first two slides (and neglect the last for now). - if len(slides) == 3: - html_text = expand_tags(u'\n'.join(slides[:2])) - # We check both slides to determine if the virtual break is - # needed (there is only one virtual break). + # Songs and Custom + elif item.is_capable(ItemCapabilities.CanSoftBreak): + pages = [] + while True: + slides = text.split(u'\n[---]\n', 2) + # If there are (at least) two occurrences of [---] we use + # the first two slides (and neglect the last for now). + if len(slides) == 3: + html_text = expand_tags(u'\n'.join(slides[:2])) + # We check both slides to determine if the virtual break is + # needed (there is only one virtual break). + else: + html_text = expand_tags(u'\n'.join(slides)) + html_text = html_text.replace(u'\n', u'
') + if self._text_fits_on_slide(html_text): + # The first two virtual slides fit (as a whole) on one + # slide. Replace the first occurrence of [---]. + text = text.replace(u'\n[---]', u'', 1) + else: + # The first virtual slide fits, which means we have to + # render the first virtual slide. + text_contains_break = u'[---]' in text + if text_contains_break: + text_to_render, text = text.split(u'\n[---]\n', 1) else: - html_text = expand_tags(u'\n'.join(slides)) - html_text = html_text.replace(u'\n', u'
') - if self._text_fits_on_slide(html_text): - # The first two virtual slides fit (as a whole) on one - # slide. Replace the first occurrence of [---]. - text = text.replace(u'\n[---]', u'', 1) + text_to_render = text + text = u'' + lines = text_to_render.strip(u'\n').split(u'\n') + slides = self._paginate_slide(lines, line_end) + if len(slides) > 1 and text: + # Add all slides apart from the last one the list. + pages.extend(slides[:-1]) + if text_contains_break: + text = slides[-1] + u'\n[---]\n' + text + else: + text = slides[-1] + u'\n'+ text + text = text.replace(u'
', u'\n') else: - # The first virtual slide fits, which means we have to - # render the first virtual slide. - text_contains_break = u'[---]' in text - if text_contains_break: - text_to_render, text = text.split(u'\n[---]\n', 1) - else: - text_to_render = text - text = u'' - lines = text_to_render.strip(u'\n').split(u'\n') - slides = self._paginate_slide(lines, line_end) - if len(slides) > 1 and text: - # Add all slides apart from the last one the list. - pages.extend(slides[:-1]) - if text_contains_break: - text = slides[-1] + u'\n[---]\n' + text - else: - text = slides[-1] + u'\n'+ text - text = text.replace(u'
', u'\n') - else: - pages.extend(slides) - if u'[---]' not in text: - lines = text.strip(u'\n').split(u'\n') - pages.extend(self._paginate_slide(lines, line_end)) - break + pages.extend(slides) + if u'[---]' not in text: + lines = text.strip(u'\n').split(u'\n') + pages.extend(self._paginate_slide(lines, line_end)) + break + else: + # Clean up line endings. + pages = self._paginate_slide(text.split(u'\n'), line_end) new_pages = [] for page in pages: while page.endswith(u'
'): @@ -585,12 +583,3 @@ class Renderer(object): # this parse we are to be wordy line = line.replace(u'\n', u' ') return line.split(u' ') - - def _lines_split(self, text): - """ - Split the slide up by physical line - """ - # this parse we do not want to use this so remove it - text = text.replace(u'\n[---]', u'') - text = text.replace(u'[---]', u'') - return text.split(u'\n') From 682e822d2196acdcb7f7a23843e29c9767f1567c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 25 Sep 2011 08:27:09 +0100 Subject: [PATCH 06/13] Clean up --- openlp/core/ui/servicemanager.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9f8073618..4b1049d49 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -663,6 +663,7 @@ class ServiceManager(QtGui.QWidget): serviceItem.renderer = self.mainwindow.renderer serviceItem.set_from_service(item, self.servicePath) self.validateItem(serviceItem) + self.loadItem_uuid = 0 if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate): Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem) @@ -1124,14 +1125,9 @@ class ServiceManager(QtGui.QWidget): def serviceItemUpdate(self, message): """ Triggered from plugins to update service items. + Save the values as they will be used as part of the service load """ - editId, uuid = message.split(u':') - self.loadItem_uuid = uuid - self.loadItem_editId = editId - for item in self.serviceItems: - if item[u'service_item']._uuid == uuid: - item[u'service_item'].edit_id = int(editId) - self.setModified() + self.loadItem_editId, self.loadItem_uuid = message.split(u':') def replaceServiceItem(self, newItem): """ From 8c6fcfcd4a7bd21a98b91cd434b503c2bc984e5a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Sep 2011 17:12:40 +0100 Subject: [PATCH 07/13] Fix typing error --- openlp/core/lib/serviceitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index d8808503f..3170e0a93 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -87,7 +87,6 @@ class ServiceItem(object): if plugin: self.renderer = plugin.renderer self.name = plugin.name - self.from_service = False if plugin else False self.title = u'' self.shortname = u'' self.audit = u'' @@ -116,6 +115,7 @@ class ServiceItem(object): self.start_time = 0 self.end_time = 0 self.media_length = 0 + self.from_service = False self.image_border = u'#000000' self.background_audio = [] self._new_item() From 3a2be026f5c47ec194522e7dad55c3386cf3664a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 26 Sep 2011 18:25:22 +0200 Subject: [PATCH 08/13] reverted some changes --- openlp/core/lib/renderer.py | 78 +++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index b5646bc5d..2b799d62c 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -227,46 +227,50 @@ class Renderer(object): # Songs and Custom elif item.is_capable(ItemCapabilities.CanSoftBreak): pages = [] - while True: - slides = text.split(u'\n[---]\n', 2) - # If there are (at least) two occurrences of [---] we use - # the first two slides (and neglect the last for now). - if len(slides) == 3: - html_text = expand_tags(u'\n'.join(slides[:2])) - # We check both slides to determine if the virtual break is - # needed (there is only one virtual break). - else: - html_text = expand_tags(u'\n'.join(slides)) - html_text = html_text.replace(u'\n', u'
') - if self._text_fits_on_slide(html_text): - # The first two virtual slides fit (as a whole) on one - # slide. Replace the first occurrence of [---]. - text = text.replace(u'\n[---]', u'', 1) - else: - # The first virtual slide fits, which means we have to - # render the first virtual slide. - text_contains_break = u'[---]' in text - if text_contains_break: - text_to_render, text = text.split(u'\n[---]\n', 1) + if u'[---]' in text: + while True: + slides = text.split(u'\n[---]\n', 2) + # If there are (at least) two occurrences of [---] we use + # the first two slides (and neglect the last for now). + if len(slides) == 3: + html_text = expand_tags(u'\n'.join(slides[:2])) + # We check both slides to determine if the virtual break is + # needed (there is only one virtual break). else: - text_to_render = text - text = u'' - lines = text_to_render.strip(u'\n').split(u'\n') - slides = self._paginate_slide(lines, line_end) - if len(slides) > 1 and text: - # Add all slides apart from the last one the list. - pages.extend(slides[:-1]) - if text_contains_break: - text = slides[-1] + u'\n[---]\n' + text + html_text = expand_tags(u'\n'.join(slides)) + html_text = html_text.replace(u'\n', u'
') + if self._text_fits_on_slide(html_text): + # The first two virtual slides fit (as a whole) on one + # slide. Replace the first occurrence of [---]. + text = text.replace(u'\n[---]', u'', 1) + else: + # The first virtual slide fits, which means we have to + # render the first virtual slide. + text_contains_break = u'[---]' in text + if text_contains_break: + text_to_render, text = text.split(u'\n[---]\n', 1) else: - text = slides[-1] + u'\n'+ text - text = text.replace(u'
', u'\n') + text_to_render = text + text = u'' + lines = text_to_render.strip(u'\n').split(u'\n') + slides = self._paginate_slide(lines, line_end) + if len(slides) > 1 and text: + # Add all slides apart from the last one the list. + pages.extend(slides[:-1]) + if text_contains_break: + text = slides[-1] + u'\n[---]\n' + text + else: + text = slides[-1] + u'\n'+ text + text = text.replace(u'
', u'\n') + else: + pages.extend(slides) + if u'[---]' not in text: + lines = text.strip(u'\n').split(u'\n') + pages.extend(self._paginate_slide(lines, line_end)) + break else: - pages.extend(slides) - if u'[---]' not in text: - lines = text.strip(u'\n').split(u'\n') - pages.extend(self._paginate_slide(lines, line_end)) - break + pages = self._paginate_slide( + text.split(u'\n'), line_end) else: # Clean up line endings. pages = self._paginate_slide(text.split(u'\n'), line_end) From c9b7b55a8796ae81ccc178a2d0f775eae4f2bd86 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 26 Sep 2011 18:46:11 +0200 Subject: [PATCH 09/13] reverted some changes --- openlp/core/lib/renderer.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 2b799d62c..e64c80f55 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -268,9 +268,6 @@ class Renderer(object): lines = text.strip(u'\n').split(u'\n') pages.extend(self._paginate_slide(lines, line_end)) break - else: - pages = self._paginate_slide( - text.split(u'\n'), line_end) else: # Clean up line endings. pages = self._paginate_slide(text.split(u'\n'), line_end) From 9a40b27672487589c60ae1bd684f6f2f745d7507 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 26 Sep 2011 18:57:32 +0200 Subject: [PATCH 10/13] fix for theme editing --- openlp/core/lib/renderer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index e64c80f55..9dd359769 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -271,6 +271,8 @@ class Renderer(object): else: # Clean up line endings. pages = self._paginate_slide(text.split(u'\n'), line_end) + else: + pages = self._paginate_slide(text.split(u'\n'), line_end) new_pages = [] for page in pages: while page.endswith(u'
'): From 7fe57a9a5d896d12aeab691783eb30dbc2ca64bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Sep 2011 19:12:27 +0100 Subject: [PATCH 11/13] Make Int --- openlp/core/ui/servicemanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4b1049d49..7d9073ca7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1127,7 +1127,8 @@ class ServiceManager(QtGui.QWidget): Triggered from plugins to update service items. Save the values as they will be used as part of the service load """ - self.loadItem_editId, self.loadItem_uuid = message.split(u':') + self.loadItem_editId, uuid = message.split(u':') + self.loadItem_uuid = int(uuid) def replaceServiceItem(self, newItem): """ From 947a58dbbe962f4135936adbb0035092b8b404d7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 26 Sep 2011 20:26:13 +0200 Subject: [PATCH 12/13] improved line counting --- openlp/core/lib/renderer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 9dd359769..1eb6896e9 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -44,6 +44,8 @@ VERSE = u'The Lord said to {r}Noah{/r}: \n' \ 'Get those children out of the muddy, muddy \n' \ '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \ 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' +VERSE_FOR_LINE_COUNT = u'1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15' \ + '\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33' FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456'] class Renderer(object): @@ -190,7 +192,7 @@ class Renderer(object): serviceItem.theme = theme_data if self.force_page: # make big page for theme edit dialog to get line count - serviceItem.add_from_text(u'', VERSE + VERSE + VERSE) + serviceItem.add_from_text(u'', VERSE_FOR_LINE_COUNT) else: self.imageManager.del_image(theme_data.theme_name) serviceItem.add_from_text(u'', VERSE) From 695e08a63a1af53b4c0a218099e45be3d26a3ca7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Sep 2011 19:56:52 +0100 Subject: [PATCH 13/13] get the right field --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7d9073ca7..c9f058351 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1127,8 +1127,8 @@ class ServiceManager(QtGui.QWidget): Triggered from plugins to update service items. Save the values as they will be used as part of the service load """ - self.loadItem_editId, uuid = message.split(u':') - self.loadItem_uuid = int(uuid) + editId, self.loadItem_uuid = message.split(u':') + self.loadItem_editId = int(editId) def replaceServiceItem(self, newItem): """