Apply formatting tags to alerts.

This commit is contained in:
Mattias Põldaru 2012-01-03 01:43:59 +02:00
parent 185cc5487a
commit 85a92455d1

View File

@ -37,7 +37,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
translate, PluginManager translate, PluginManager, expand_tags
from openlp.core.ui import HideMode, ScreenList, AlertLocation from openlp.core.ui import HideMode, ScreenList, AlertLocation
@ -237,16 +237,17 @@ class MainDisplay(Display):
The text to be displayed. The text to be displayed.
""" """
log.debug(u'alert to display') log.debug(u'alert to display')
# First we convert <>& marks to html variants, then apply
# formattingtags, finally we double all backslashes for JavaScript.
text_prepared = expand_tags(cgi.escape(text)) \
.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')
if self.height() != self.screen[u'size'].height() or \ if self.height() != self.screen[u'size'].height() or \
not self.isVisible(): not self.isVisible():
shrink = True shrink = True
js = u'show_alert("%s", "%s")' % (cgi.escape( js = u'show_alert("%s", "%s")' % (text_prepared, u'top')
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')),
u'top')
else: else:
shrink = False shrink = False
js = u'show_alert("%s", "")' % (cgi.escape( js = u'show_alert("%s", "")' % text_prepared
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')))
height = self.frame.evaluateJavaScript(js) height = self.frame.evaluateJavaScript(js)
if shrink: if shrink:
if text: if text: