forked from openlp/openlp
Fix up tags for renderer
This commit is contained in:
parent
06901951a6
commit
076215435b
@ -35,6 +35,67 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# TODO make external and configurable in alpha 4 via a settings dialog
|
||||||
|
html_expands = []
|
||||||
|
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}', \
|
||||||
|
u'start html':u'<font color=#CC33CC>', \
|
||||||
|
u'end tag':u'{/pk}', u'end html':u'</font>', \
|
||||||
|
u'protected':False})
|
||||||
|
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
|
||||||
|
u'start html':u'<font color=#CC0033>', \
|
||||||
|
u'end tag':u'{/o}', u'end html':u'</font>', \
|
||||||
|
u'protected':False})
|
||||||
|
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
|
||||||
|
u'start html':u'<font color=#9900FF>', \
|
||||||
|
u'end tag':u'{/pp}', u'end html':u'</font>', \
|
||||||
|
u'protected':False})
|
||||||
|
html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
|
||||||
|
u'start html':u'<font color=white>', \
|
||||||
|
u'end tag':u'{/w}', u'end html':u'</font>', \
|
||||||
|
u'protected':False})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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})
|
||||||
|
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 translate(context, text, comment=None):
|
def translate(context, text, comment=None):
|
||||||
"""
|
"""
|
||||||
A special shortcut method to wrap around the Qt4 translation functions.
|
A special shortcut method to wrap around the Qt4 translation functions.
|
||||||
@ -232,6 +293,25 @@ def check_item_selected(list_widget, message):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def clean_tags(text):
|
||||||
|
"""
|
||||||
|
Remove Tags from text for display
|
||||||
|
"""
|
||||||
|
text = text.replace(u'<br>', u'\n')
|
||||||
|
for tag in html_expands:
|
||||||
|
text = text.replace(tag[u'start tag'], u'')
|
||||||
|
text = text.replace(tag[u'end tag'], u'')
|
||||||
|
return text
|
||||||
|
|
||||||
|
def expand_tags(text):
|
||||||
|
"""
|
||||||
|
Expand tags HTML for display
|
||||||
|
"""
|
||||||
|
for tag in 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
|
||||||
|
|
||||||
from eventreceiver import Receiver
|
from eventreceiver import Receiver
|
||||||
from settingsmanager import SettingsManager
|
from settingsmanager import SettingsManager
|
||||||
from plugin import PluginStatus, Plugin
|
from plugin import PluginStatus, Plugin
|
||||||
|
@ -31,7 +31,7 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
from openlp.core.lib import resize_image
|
from openlp.core.lib import resize_image, expand_tags
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ class Renderer(object):
|
|||||||
for line in text:
|
for line in text:
|
||||||
# mark line ends
|
# mark line ends
|
||||||
temp_text = temp_text + line + line_end
|
temp_text = temp_text + line + line_end
|
||||||
html_text = shell % temp_text
|
html_text = shell % expand_tags(temp_text)
|
||||||
doc.setHtml(html_text)
|
doc.setHtml(html_text)
|
||||||
# Text too long so gone to next mage
|
# Text too long so gone to next mage
|
||||||
if layout.pageCount() != 1:
|
if layout.pageCount() != 1:
|
||||||
|
@ -68,67 +68,6 @@ class RenderManager(object):
|
|||||||
self.themedata = None
|
self.themedata = None
|
||||||
self.alertTab = None
|
self.alertTab = None
|
||||||
|
|
||||||
# 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'Pink', u'start tag':u'{pk}', \
|
|
||||||
u'start html':u'<font color=#CC33CC>', \
|
|
||||||
u'end tag':u'{/pk}', u'end html':u'</font>', \
|
|
||||||
u'protected':False})
|
|
||||||
self.html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
|
|
||||||
u'start html':u'<font color=#CC0033>', \
|
|
||||||
u'end tag':u'{/o}', u'end html':u'</font>', \
|
|
||||||
u'protected':False})
|
|
||||||
self.html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
|
|
||||||
u'start html':u'<font color=#9900FF>', \
|
|
||||||
u'end tag':u'{/pp}', u'end html':u'</font>', \
|
|
||||||
u'protected':False})
|
|
||||||
self.html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
|
|
||||||
u'start html':u'<font color=white>', \
|
|
||||||
u'end tag':u'{/w}', 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):
|
||||||
"""
|
"""
|
||||||
Updates the render manager's information about the current screen.
|
Updates the render manager's information about the current screen.
|
||||||
@ -294,22 +233,3 @@ class RenderManager(object):
|
|||||||
self.width, self.height, self.screen_ratio )
|
self.width, self.height, self.screen_ratio )
|
||||||
# 90% is start of footer
|
# 90% is start of footer
|
||||||
self.footer_start = int(self.height * 0.90)
|
self.footer_start = int(self.height * 0.90)
|
||||||
|
|
||||||
def clean(self, text):
|
|
||||||
"""
|
|
||||||
Remove Tags from text for display
|
|
||||||
"""
|
|
||||||
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 HTML for display
|
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
@ -35,7 +35,7 @@ import uuid
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import build_icon, resize_image
|
from openlp.core.lib import build_icon, resize_image, clean_tags, expand_tags
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ class ServiceItem(object):
|
|||||||
.format_slide(slide[u'raw_slide'], line_break)
|
.format_slide(slide[u'raw_slide'], line_break)
|
||||||
for page in formated:
|
for page in formated:
|
||||||
self._display_frames.append(
|
self._display_frames.append(
|
||||||
{u'title': self.render_manager.clean(page),
|
{u'title': clean_tags(page),
|
||||||
u'text': self.render_manager.clean(page.rstrip()),
|
u'text': clean_tags(page.rstrip()),
|
||||||
u'html': self.render_manager.expand(page.rstrip()),
|
u'html': expand_tags(page.rstrip()),
|
||||||
u'verseTag': slide[u'verseTag'] })
|
u'verseTag': slide[u'verseTag'] })
|
||||||
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
||||||
elif self.service_item_type == ServiceItemType.Image:
|
elif self.service_item_type == ServiceItemType.Image:
|
||||||
|
Loading…
Reference in New Issue
Block a user