From 1e86aa98bab3d267b2d454e5236e42d55bcdaae3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 21 Aug 2010 07:00:46 +0100 Subject: [PATCH] Fix theme text weight and html tag cleanups --- openlp/core/lib/htmlbuilder.py | 63 ++++++++++++------------ openlp/core/lib/renderer.py | 11 ++++- openlp/core/lib/rendermanager.py | 66 +++++++++++++++++++------- openlp/plugins/bibles/lib/mediaitem.py | 9 ++-- 4 files changed, 96 insertions(+), 53 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index a182edaf6..9b9160f3e 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -40,30 +40,30 @@ body { background-color: black; } .dim { - position: absolute; - left: 0px; + position: absolute; + left: 0px; top: 0px; - width: %spx; - height: %spx; + width: %spx; + height: %spx; } -#black { +#black { z-index:8; - background-color: black; + background-color: black; display: none; } -#video { - z-index:2; +#video { + z-index:2; } #alert { - position: absolute; - left: 0px; + position: absolute; + left: 0px; top: 0px; - z-index:10; + z-index:10; %s } #footer { - position: absolute; - z-index:5; + position: absolute; + z-index:5; %s } /* lyric css */ @@ -116,6 +116,7 @@ body { else img.style.display = 'block'; } + function show_blank(state){ var black = 'none'; var lyrics = ''; @@ -163,11 +164,11 @@ body { text.style.top = '0px'; break; case 'middle': - text.style.top = ((window.innerHeight - text.clientHeight) / 2) + text.style.top = ((window.innerHeight - text.clientHeight) / 2) + 'px'; break; case 'bottom': - text.style.top = (window.innerHeight - text.clientHeight) + text.style.top = (window.innerHeight - text.clientHeight) + 'px'; break; } @@ -178,7 +179,7 @@ body { function show_footer(text){ document.getElementById('footer').innerHTML(text); } - + function show_text(newtext){ var text1 = document.getElementById('lyricsmain'); var texto1 = document.getElementById('lyricsoutline'); @@ -389,14 +390,14 @@ def build_footer(item): Service Item to be processed. """ style = """ - left: %spx; - top: %spx; - width: %spx; + left: %spx; + top: %spx; + width: %spx; height: %spx; - font-family: %s; - font-size: %spx; - color: %s; - align: %s; + font-family: %s; + font-size: %spx; + color: %s; + align: %s; """ theme = item.themedata if not theme: @@ -407,8 +408,8 @@ def build_footer(item): align = u'right' else: align = u'left' - lyrics_html = style % (item.footer.x(), item.footer.y(), - item.footer.width(), item.footer.height(), theme.font_footer_name, + lyrics_html = style % (item.footer.x(), item.footer.y(), + item.footer.width(), item.footer.height(), theme.font_footer_name, theme.font_footer_proportion, theme.font_footer_color, align) return lyrics_html @@ -420,11 +421,11 @@ def build_alert(alertTab, width): Details from the Alert tab for fonts etc """ style = """ - width: %s; - vertical-align: %s; - font-family %s; - font-size: %spx; - color: %s; + width: %s; + vertical-align: %s; + font-family %s; + font-size: %spx; + color: %s; background-color: %s; """ if not alertTab: @@ -436,6 +437,6 @@ def build_alert(alertTab, width): align = u'middle' else: align = u'top' - alert = style % (width, align, alertTab.font_face, alertTab.font_size, + alert = style % (width, align, alertTab.font_face, alertTab.font_size, alertTab.font_color, alertTab.bg_color) return alert diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8300bfe6f..369934f03 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -169,7 +169,16 @@ class Renderer(object): doc.setDefaultFont(df) layout = doc.documentLayout() formatted = [] - shell = u'

%s

' + if self._theme.font_main_weight == u'Bold' and \ + self._theme.font_main_italics: + shell = u'{p}{st}{it}%s{/it}{/st}{/p}' + elif self._theme.font_main_weight == u'Bold' and \ + not self._theme.font_main_italics: + shell = u'{p}{st}%s{/st}{/p}' + elif self._theme.font_main_italics: + shell = u'{p}{it}%s{/it}{/p}' + else: + shell = u'{p}%s{/p}' temp_text = u'' old_html_text = u'' for line in text: diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index ead9971e2..60e8c639b 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -68,15 +68,49 @@ class RenderManager(object): self.themedata = None self.alertTab = None - # TODO make external and configurable - self.html_expands = { - u'{r}': u'', - u'{b}': u'', - u'{u}': u'', - u'{y}': u'', - u'{g}': u'', - u'{/}': u'' - } + # TODO make external and configurable in alpha 4 + self.html_expands = [] + + self.html_expands.append({u'desc':u'Red',u'start tag':u'{r}', \ + u'start html':u'', \ + u'end tag':u'{/r}', u'end html':u'', \ + u'protected':False}) + self.html_expands.append({u'desc':u'Black',u'start tag':u'{b}', \ + u'start html':u'', \ + u'end tag':u'{/b}', u'end html':u'', \ + u'protected':False}) + self.html_expands.append({u'desc':u'Blue',u'start tag':u'{bl}', \ + u'start html':u'', \ + u'end tag':u'{/bl}', u'end html':u'', \ + u'protected':False}) + self.html_expands.append({u'desc':u'Yellow',u'start tag':u'{y}', \ + u'start html':u'', \ + u'end tag':u'{/y}', u'end html':u'', \ + u'protected':False}) + self.html_expands.append({u'desc':u'Green',u'start tag':u'{g}', \ + u'start html':u'', \ + u'end tag':u'{/g}', u'end html':u'', \ + u'protected':False}) + self.html_expands.append({u'desc':u'Superscript',u'start tag':u'{su}', \ + u'start html':u'', \ + u'end tag':u'{/su}', u'end html':u'', \ + u'protected':True}) + self.html_expands.append({u'desc':u'Subscript',u'start tag':u'{sb}', \ + u'start html':u'', \ + u'end tag':u'{/sb}', u'end html':u'', \ + u'protected':True}) + self.html_expands.append({u'desc':u'Paragraph',u'start tag':u'{p}', \ + u'start html':u'

', \ + u'end tag':u'{/p}', u'end html':u'

', \ + u'protected':True}) + self.html_expands.append({u'desc':u'Bold',u'start tag':u'{st}', \ + u'start html':u'', \ + u'end tag':u'{/st}', u'end html':u'', \ + u'protected':True}) + self.html_expands.append({u'desc':u'Italics',u'start tag':u'{it}', \ + u'start html':u'', \ + u'end tag':u'{/it}', u'end html':u'', \ + u'protected':True}) def update_display(self): """ @@ -262,18 +296,18 @@ class RenderManager(object): """ Remove Tags from text for display """ - text = text.replace(u'
', u'\n').replace(u'

', u'')\ - .replace(u'

', u'').replace(u'', u'')\ - .replace(u'', u'') - for key, value in self.html_expands.iteritems(): - text = text.replace(key, u'') + text = text.replace(u'
', u'\n') + for tag in self.html_expands: + text = text.replace(tag[u'start tag'], u'') + text = text.replace(tag[u'end tag'], u'') return text def expand(self, text): """ Expand tags fto HTML for display """ - for key, value in self.html_expands.iteritems(): - text = text.replace(key, value) + for tag in self.html_expands: + text = text.replace(tag[u'start tag'], tag[u'start html']) + text = text.replace(tag[u'end tag'], tag[u'end html']) return text diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 53e8c6b77..a645b2c87 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -503,16 +503,16 @@ class BibleMediaItem(MediaManagerItem): dual_text = self._decodeQtObject(reference, 'dual_text') if self.parent.settings_tab.display_style == 1: verse_text = self.formatVerse(old_chapter, chapter, verse, - u'(', u')') + u'{su}(', u'){/su}') elif self.parent.settings_tab.display_style == 2: verse_text = self.formatVerse(old_chapter, chapter, verse, - u'{', u'}') + u'{su}{', u'}{/su}') elif self.parent.settings_tab.display_style == 3: verse_text = self.formatVerse(old_chapter, chapter, verse, - u'[', u']') + u'{su}[', u']{/su}') else: verse_text = self.formatVerse(old_chapter, chapter, verse, - u'', u'') + u'{su}', u'{/su}') old_chapter = chapter footer = u'%s (%s %s)' % (book, version, copyright) # If not found add to footer @@ -572,7 +572,6 @@ class BibleMediaItem(MediaManagerItem): service_item.title = u'%s, %s' % (service_item.title, translate('BiblesPlugin.MediaItem', 'etc')) # item theme ->>>>>>> MERGE-SOURCE if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None else: