Fix theme text weight and html tag cleanups

This commit is contained in:
Tim Bentley 2010-08-21 07:00:46 +01:00
parent 1e0d68016f
commit 1e86aa98ba
4 changed files with 96 additions and 53 deletions

View File

@ -40,30 +40,30 @@ body {
background-color: black; background-color: black;
} }
.dim { .dim {
position: absolute; position: absolute;
left: 0px; left: 0px;
top: 0px; top: 0px;
width: %spx; width: %spx;
height: %spx; height: %spx;
} }
#black { #black {
z-index:8; z-index:8;
background-color: black; background-color: black;
display: none; display: none;
} }
#video { #video {
z-index:2; z-index:2;
} }
#alert { #alert {
position: absolute; position: absolute;
left: 0px; left: 0px;
top: 0px; top: 0px;
z-index:10; z-index:10;
%s %s
} }
#footer { #footer {
position: absolute; position: absolute;
z-index:5; z-index:5;
%s %s
} }
/* lyric css */ /* lyric css */
@ -116,6 +116,7 @@ body {
else else
img.style.display = 'block'; img.style.display = 'block';
} }
function show_blank(state){ function show_blank(state){
var black = 'none'; var black = 'none';
var lyrics = ''; var lyrics = '';
@ -163,11 +164,11 @@ body {
text.style.top = '0px'; text.style.top = '0px';
break; break;
case 'middle': case 'middle':
text.style.top = ((window.innerHeight - text.clientHeight) / 2) text.style.top = ((window.innerHeight - text.clientHeight) / 2)
+ 'px'; + 'px';
break; break;
case 'bottom': case 'bottom':
text.style.top = (window.innerHeight - text.clientHeight) text.style.top = (window.innerHeight - text.clientHeight)
+ 'px'; + 'px';
break; break;
} }
@ -178,7 +179,7 @@ body {
function show_footer(text){ function show_footer(text){
document.getElementById('footer').innerHTML(text); document.getElementById('footer').innerHTML(text);
} }
function show_text(newtext){ function show_text(newtext){
var text1 = document.getElementById('lyricsmain'); var text1 = document.getElementById('lyricsmain');
var texto1 = document.getElementById('lyricsoutline'); var texto1 = document.getElementById('lyricsoutline');
@ -389,14 +390,14 @@ def build_footer(item):
Service Item to be processed. Service Item to be processed.
""" """
style = """ style = """
left: %spx; left: %spx;
top: %spx; top: %spx;
width: %spx; width: %spx;
height: %spx; height: %spx;
font-family: %s; font-family: %s;
font-size: %spx; font-size: %spx;
color: %s; color: %s;
align: %s; align: %s;
""" """
theme = item.themedata theme = item.themedata
if not theme: if not theme:
@ -407,8 +408,8 @@ def build_footer(item):
align = u'right' align = u'right'
else: else:
align = u'left' align = u'left'
lyrics_html = style % (item.footer.x(), item.footer.y(), lyrics_html = style % (item.footer.x(), item.footer.y(),
item.footer.width(), item.footer.height(), theme.font_footer_name, item.footer.width(), item.footer.height(), theme.font_footer_name,
theme.font_footer_proportion, theme.font_footer_color, align) theme.font_footer_proportion, theme.font_footer_color, align)
return lyrics_html return lyrics_html
@ -420,11 +421,11 @@ def build_alert(alertTab, width):
Details from the Alert tab for fonts etc Details from the Alert tab for fonts etc
""" """
style = """ style = """
width: %s; width: %s;
vertical-align: %s; vertical-align: %s;
font-family %s; font-family %s;
font-size: %spx; font-size: %spx;
color: %s; color: %s;
background-color: %s; background-color: %s;
""" """
if not alertTab: if not alertTab:
@ -436,6 +437,6 @@ def build_alert(alertTab, width):
align = u'middle' align = u'middle'
else: else:
align = u'top' 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) alertTab.font_color, alertTab.bg_color)
return alert return alert

View File

@ -169,7 +169,16 @@ class Renderer(object):
doc.setDefaultFont(df) doc.setDefaultFont(df)
layout = doc.documentLayout() layout = doc.documentLayout()
formatted = [] formatted = []
shell = u'<p>%s</p>' 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'' temp_text = u''
old_html_text = u'' old_html_text = u''
for line in text: for line in text:

View File

@ -68,15 +68,49 @@ class RenderManager(object):
self.themedata = None self.themedata = None
self.alertTab = None self.alertTab = None
# TODO make external and configurable # TODO make external and configurable in alpha 4
self.html_expands = { self.html_expands = []
u'{r}': u'<font color=red>',
u'{b}': u'<font color=black>', self.html_expands.append({u'desc':u'Red',u'start tag':u'{r}', \
u'{u}': u'<font color=blue>', u'start html':u'<font color=red>', \
u'{y}': u'<font color=yellow>', u'end tag':u'{/r}', u'end html':u'</font>', \
u'{g}': u'<font color=green>', u'protected':False})
u'{/}': u'</font>' self.html_expands.append({u'desc':u'Black',u'start tag':u'{b}', \
} u'start html':u'<font color=black>', \
u'end tag':u'{/b}', u'end html':u'</font>', \
u'protected':False})
self.html_expands.append({u'desc':u'Blue',u'start tag':u'{bl}', \
u'start html':u'<font color=blue>', \
u'end tag':u'{/bl}', u'end html':u'</font>', \
u'protected':False})
self.html_expands.append({u'desc':u'Yellow',u'start tag':u'{y}', \
u'start html':u'<font color=yellow>', \
u'end tag':u'{/y}', u'end html':u'</font>', \
u'protected':False})
self.html_expands.append({u'desc':u'Green',u'start tag':u'{g}', \
u'start html':u'<font color=green>', \
u'end tag':u'{/g}', u'end html':u'</font>', \
u'protected':False})
self.html_expands.append({u'desc':u'Superscript',u'start tag':u'{su}', \
u'start html':u'<sup>', \
u'end tag':u'{/su}', u'end html':u'</sup>', \
u'protected':True})
self.html_expands.append({u'desc':u'Subscript',u'start tag':u'{sb}', \
u'start html':u'<sub>', \
u'end tag':u'{/sb}', u'end html':u'</sub>', \
u'protected':True})
self.html_expands.append({u'desc':u'Paragraph',u'start tag':u'{p}', \
u'start html':u'<p>', \
u'end tag':u'{/p}', u'end html':u'</p>', \
u'protected':True})
self.html_expands.append({u'desc':u'Bold',u'start tag':u'{st}', \
u'start html':u'<strong>', \
u'end tag':u'{/st}', u'end html':u'</strong>', \
u'protected':True})
self.html_expands.append({u'desc':u'Italics',u'start tag':u'{it}', \
u'start html':u'<em>', \
u'end tag':u'{/it}', u'end html':u'</em>', \
u'protected':True})
def update_display(self): def update_display(self):
""" """
@ -262,18 +296,18 @@ class RenderManager(object):
""" """
Remove Tags from text for display Remove Tags from text for display
""" """
text = text.replace(u'<br>', u'\n').replace(u'<p>', u'')\ text = text.replace(u'<br>', u'\n')
.replace(u'</p>', u'').replace(u'<sup>', u'')\ for tag in self.html_expands:
.replace(u'</sup>', u'') text = text.replace(tag[u'start tag'], u'')
for key, value in self.html_expands.iteritems(): text = text.replace(tag[u'end tag'], u'')
text = text.replace(key, u'')
return text return text
def expand(self, text): def expand(self, text):
""" """
Expand tags fto HTML for display Expand tags fto HTML for display
""" """
for key, value in self.html_expands.iteritems(): for tag in self.html_expands:
text = text.replace(key, value) text = text.replace(tag[u'start tag'], tag[u'start html'])
text = text.replace(tag[u'end tag'], tag[u'end html'])
return text return text

View File

@ -503,16 +503,16 @@ class BibleMediaItem(MediaManagerItem):
dual_text = self._decodeQtObject(reference, 'dual_text') dual_text = self._decodeQtObject(reference, 'dual_text')
if self.parent.settings_tab.display_style == 1: if self.parent.settings_tab.display_style == 1:
verse_text = self.formatVerse(old_chapter, chapter, verse, verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>(', u')</sup>') u'{su}(', u'){/su}')
elif self.parent.settings_tab.display_style == 2: elif self.parent.settings_tab.display_style == 2:
verse_text = self.formatVerse(old_chapter, chapter, verse, verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>{', u'}</sup>') u'{su}{', u'}{/su}')
elif self.parent.settings_tab.display_style == 3: elif self.parent.settings_tab.display_style == 3:
verse_text = self.formatVerse(old_chapter, chapter, verse, verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>[', u']</sup>') u'{su}[', u']{/su}')
else: else:
verse_text = self.formatVerse(old_chapter, chapter, verse, verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>', u'</sup>') u'{su}', u'{/su}')
old_chapter = chapter old_chapter = chapter
footer = u'%s (%s %s)' % (book, version, copyright) footer = u'%s (%s %s)' % (book, version, copyright)
# If not found add to footer # If not found add to footer
@ -572,7 +572,6 @@ class BibleMediaItem(MediaManagerItem):
service_item.title = u'%s, %s' % (service_item.title, service_item.title = u'%s, %s' % (service_item.title,
translate('BiblesPlugin.MediaItem', 'etc')) translate('BiblesPlugin.MediaItem', 'etc'))
# item theme # item theme
>>>>>>> MERGE-SOURCE
if len(self.parent.settings_tab.bible_theme) == 0: if len(self.parent.settings_tab.bible_theme) == 0:
service_item.theme = None service_item.theme = None
else: else: