From 821911503e572b1b9ea6e3d7938d3b1d9c7dbfe7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 4 Aug 2010 05:59:41 +0100 Subject: [PATCH] Alerts now work --- openlp/core/lib/htmlbuilder.py | 32 ++++++++++++---------- openlp/core/ui/maindisplay.py | 8 ++++-- openlp/plugins/alerts/lib/alertsmanager.py | 11 -------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index c6a87ab70..79ff886ed 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -47,9 +47,9 @@ HTMLSRC = u""" var t = null; var transition = %s; - function displayAlert(alert){ + function displayAlert(alerttext){ var text1 = document.getElementById('alertmain'); - text1.innerHTML = alert; + text1.innerHTML = alerttext; } function startfade(newtext){ @@ -136,7 +136,9 @@ HTMLSRC = u""" - +
+
+
@@ -342,22 +344,24 @@ def build_alert(width, height, alertTab): """ style = """ .alerttable { position: absolute; z-index:8; left 0px; top 0px; %s } + .alertcell { %s } .alert { %s } - table {border=0; margin=0; padding=0; } """ - alertcommon = u'' - valign = u'' + alerttable = u'' + alertcell = u'' + alert = u'' if alertTab: - alertcommon = u'width: %spx; height: %spx; ' \ - u'font-family %s; font-size: %spx; color: %s; ' % \ - (width, height, alertTab.font_face, alertTab.font_size, - alertTab.bg_color) if alertTab.location == 2: - valign = u'vertical-align:bottom;' + alertcell = u'vertical-align:bottom;' elif alertTab.location == 1: - valign = u'vertical-align:middle;' + alertcell = u'vertical-align:middle;' else: - valign = u'vertical-align:top;' - alert_html = style % (alertcommon, valign) + alertcell = u'vertical-align:top;' + alerttable = u'width: %spx; height: %spx; ' % (width, height) + alert = u'font-family %s; font-size: %spx; color: %s; ' \ + u'background-color: %s' % \ + (alertTab.font_face, alertTab.font_size, alertTab.font_color, + alertTab.bg_color) + alert_html = style % (alerttable, alertcell, alert) print alert_html return alert_html diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e979d1180..816cf7087 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -146,7 +146,7 @@ class MainDisplay(DisplayWidget): splash_image) serviceItem = ServiceItem() serviceItem.bg_frame = initialFrame - self.webView.setHtml(build_html(serviceItem, self.screen, None)) + self.webView.setHtml(build_html(serviceItem, self.screen, self.parent.alertTab)) self.show() # To display or not to display? if not self.screen[u'primary']: @@ -175,8 +175,10 @@ class MainDisplay(DisplayWidget): The slide text to be displayed """ log.debug(u'alert') - self.frame.evaluateJavaScript("displayAlert('" + - text.replace("\\", "\\\\").replace("\'", "\\\'") + "')") + js = "displayAlert('" + \ + text.replace("\\", "\\\\").replace("\'", "\\\'") + "')" + print js + self.frame.evaluateJavaScript(js) def image(self, image): """ diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 12094b95d..94781d9db 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -32,15 +32,6 @@ from openlp.core.lib import Receiver, translate log = logging.getLogger(__name__) -HTMLCODE = u""" -

- %s -

-""" - class AlertsManager(QtCore.QObject): """ AlertsTab is the Alerts settings tab in the settings dialog. @@ -94,8 +85,6 @@ class AlertsManager(QtCore.QObject): return text = self.alertList.pop(0) alertTab = self.parent.alertsTab - text = HTMLCODE % (alertTab.font_color, alertTab.bg_color, - alertTab.font_face, alertTab.font_size, text) self.parent.liveController.display.alert(text) # check to see if we have a timer running if self.timer_id == 0: