From 9652a690b3adf4c3b55d868257e9f76fed080ad6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 15 Oct 2011 07:32:01 +0100 Subject: [PATCH] More cleanups and start of updates --- openlp/core/lib/htmlbuilder.py | 10 ++-------- openlp/core/lib/plugin.py | 6 ++++++ openlp/core/ui/maindisplay.py | 26 ++++++++++++++++---------- openlp/core/ui/slidecontroller.py | 2 -- openlp/plugins/alerts/alertsplugin.py | 17 ++++++++++++++++- openlp/plugins/alerts/lib/alertstab.py | 2 +- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index bc571d04d..7d91195a7 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -289,7 +289,7 @@ sup { """ -def build_html(item, screen, alert, islive, background, image=None, +def build_html(item, screen, islive, background, image=None, plugins=None): """ Build the full web paged structure for display @@ -300,9 +300,6 @@ def build_html(item, screen, alert, islive, background, image=None, ``screen`` Current display information - ``alert`` - Alert display display information - ``islive`` Item is going live, rather than preview/theme building @@ -335,16 +332,13 @@ def build_html(item, screen, alert, islive, background, image=None, html_additions = u'' if plugins: for plugin in plugins: - print plugin css_additions += plugin.getDisplayCss() js_additions += plugin.getDisplayJavaScript() html_additions += plugin.getDisplayHtml() - print js_additions html = HTMLSRC % (build_background_css(item, width, height), width, height, css_additions, - #build_alert_css(alert, width), - build_footer_css(item, height), + build_footer_css(item, height), build_lyrics_css(item, webkitvers), u'true' if theme and theme.display_slide_transition and islive \ else u'false', diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 358906d58..9a5d2d547 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -381,6 +381,12 @@ class Plugin(QtCore.QObject): """ return u'' + def refreshCss(self, frame): + """ + Allow plugins to refresh javascript of displayed screen + """ + return u'' + def getDisplayHtml(self): """ Add html code to htmlbuilder diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 129b5a827..8c4ba2eba 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -57,7 +57,6 @@ class MainDisplay(QtGui.QGraphicsView): self.imageManager = imageManager self.screens = ScreenList.get_instance() self.plugins = PluginManager.get_instance().plugins - self.alertTab = None self.rebuildCSS = False self.hideMode = None self.videoHide = False @@ -83,18 +82,24 @@ class MainDisplay(QtGui.QGraphicsView): QtCore.SIGNAL(u'openlp_phonon_creation'), self.createMediaObject) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'alertTab_updated'), self.alertTabChanged) + QtCore.SIGNAL(u'css_update'), self.cssChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) - def alertTabChanged(self): - print "alert" + def cssChanged(self): + """ + We may need to rebuild the CSS on the live display. + """ self.rebuildCSS = True def configChanged(self): - print "config" - if self.rebuildCSS: - print "Need to rebuild" + """ + Call the plugins to rebuild the Live display CSS as the screen has + not been rebuild on exit of config. + """ + if self.rebuildCSS and self.plugins: + for plugin in self.plugins: + plugin.refreshCss(self.frame) self.rebuildCSS = False def retranslateUi(self): @@ -127,6 +132,7 @@ class MainDisplay(QtGui.QGraphicsView): self.screen[u'size'].width(), self.screen[u'size'].height()) self.page = self.webView.page() self.frame = self.page.mainFrame() + self.webView.settings().setAttribute(7, True) QtCore.QObject.connect(self.webView, QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) @@ -169,7 +175,7 @@ class MainDisplay(QtGui.QGraphicsView): serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(self.initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, - self.alertTab, self.isLive, None)) + self.isLive, None)) self.__hideMouse() # To display or not to display? if not self.screen[u'primary']: @@ -507,8 +513,8 @@ class MainDisplay(QtGui.QGraphicsView): image_bytes = self.imageManager.get_image_bytes(image) else: image_bytes = None - html = build_html(self.serviceItem, self.screen, self.alertTab, - self.isLive, background, image_bytes, self.plugins) + html = build_html(self.serviceItem, self.screen, self.isLive, + background, image_bytes, self.plugins) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 354cfa168..7e6e0d54e 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -79,7 +79,6 @@ class SlideController(QtGui.QWidget): self.songEdit = False self.selectedRow = 0 self.serviceItem = None - self.alertTab = None self.panel = QtGui.QWidget(parent.controlSplitter) self.slideList = {} # Layout for holding panel @@ -423,7 +422,6 @@ class SlideController(QtGui.QWidget): if self.display: self.display.close() self.display = MainDisplay(self, self.imageManager, self.isLive) - self.display.alertTab = self.alertTab self.display.setup() if self.isLive: self.__addActionsToWidget(self.display) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index c9adabca2..057c1075f 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -68,6 +68,16 @@ JAVASCRIPT = """ text.style.visibility = 'visible'; return text.clientHeight; } + + function update_css(align, font, size, color, bgcolor){ + var text = document.getElementById('alert'); + alert("Hello"); + document.getElementById('alert').style.verticalalign = align; + text.style.fontfamily = font; + text.style.size = size; + text.style.color = color; + text.style.backgroundColor = bgcolor; + } """ CSS = """ #alert { @@ -128,7 +138,6 @@ class AlertsPlugin(Plugin): self.toolsAlertItem.setVisible(True) action_list = ActionList.get_instance() action_list.add_action(self.toolsAlertItem, UiStrings().Tools) - self.liveController.alertTab = self.settings_tab def finalise(self): """ @@ -182,3 +191,9 @@ class AlertsPlugin(Plugin): def getDisplayHtml(self): return HTML + + def refreshCss(self, frame): + align = VerticalType.Names[self.settings_tab.location] + frame.evaluateJavaScript(u'update_css("%s,%s,%s,%s,%s")' % (align, + self.settings_tab.font_face, self.settings_tab.font_size, + self.settings_tab.font_color, self.settings_tab.bg_color)) diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index a6ed18fd1..8d709a3b8 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -191,7 +191,7 @@ class AlertsTab(SettingsTab): settings.setValue(u'location', QtCore.QVariant(self.location)) settings.endGroup() if self.changed: - Receiver.send_message(u'alertTab_updated') + Receiver.send_message(u'css_update') self.changed = False def updateDisplay(self):