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;
}
.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

View File

@ -169,7 +169,16 @@ class Renderer(object):
doc.setDefaultFont(df)
layout = doc.documentLayout()
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''
old_html_text = u''
for line in text:

View File

@ -68,15 +68,49 @@ class RenderManager(object):
self.themedata = None
self.alertTab = None
# TODO make external and configurable
self.html_expands = {
u'{r}': u'<font color=red>',
u'{b}': u'<font color=black>',
u'{u}': u'<font color=blue>',
u'{y}': u'<font color=yellow>',
u'{g}': u'<font color=green>',
u'{/}': u'</font>'
}
# 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'<font color=red>', \
u'end tag':u'{/r}', u'end html':u'</font>', \
u'protected':False})
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):
"""
@ -262,18 +296,18 @@ class RenderManager(object):
"""
Remove Tags from text for display
"""
text = text.replace(u'<br>', u'\n').replace(u'<p>', u'')\
.replace(u'</p>', u'').replace(u'<sup>', u'')\
.replace(u'</sup>', u'')
for key, value in self.html_expands.iteritems():
text = text.replace(key, u'')
text = text.replace(u'<br>', 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

View File

@ -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'<sup>(', u')</sup>')
u'{su}(', u'){/su}')
elif self.parent.settings_tab.display_style == 2:
verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>{', u'}</sup>')
u'{su}{', u'}{/su}')
elif self.parent.settings_tab.display_style == 3:
verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>[', u']</sup>')
u'{su}[', u']{/su}')
else:
verse_text = self.formatVerse(old_chapter, chapter, verse,
u'<sup>', u'</sup>')
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: