From a2ebf30b6831abc5f6bf12da902517c0a244f1cc Mon Sep 17 00:00:00 2001 From: rimach Date: Mon, 24 Oct 2011 22:04:29 +0200 Subject: [PATCH] bugfixing --- openlp/core/lib/htmlbuilder.py | 22 +++++----------------- openlp/core/lib/pluginmanager.py | 8 ++++++++ openlp/core/lib/renderer.py | 9 ++++----- openlp/core/ui/maindisplay.py | 16 ++++++++-------- openlp/core/ui/mainwindow.py | 3 +-- openlp/core/ui/media/__init__.py | 1 + openlp/core/ui/media/mediacontroller.py | 8 +++++++- openlp/core/ui/media/webkitapi.py | 18 +++++++++--------- openlp/core/ui/slidecontroller.py | 5 ++--- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index f21c60376..6a495e670 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -106,18 +106,14 @@ sup { function show_blank(state){ var black = 'none'; var lyrics = ''; - var pause = false; switch(state){ case 'theme': lyrics = 'hidden'; - pause = true; break; case 'black': black = 'block'; - pause = true; break; case 'desktop': - pause = true; break; } document.getElementById('black').style.display = black; @@ -130,13 +126,6 @@ sup { if(shadow!=null) shadow.style.visibility = lyrics; document.getElementById('footer').style.visibility = lyrics; - var vid = document.getElementById('video'); - if(vid.src != ''){ - if(pause) - vid.pause(); - else - vid.play(); - } } function show_alert(alerttext, position){ @@ -220,7 +209,6 @@ sup { function show_text_complete(){ return (text_opacity()==1); } - @@ -235,8 +223,8 @@ sup { """ -def build_html(item, screen, alert, islive, background, plugins=None, - image=None): +def build_html(item, screen, alert, islive, background, image=None, + plugins=None): """ Build the full web paged structure for display @@ -255,11 +243,11 @@ def build_html(item, screen, alert, islive, background, plugins=None, ``background`` Theme background image - bytes - ``plugins`` - access to the plugins - ``image`` Image media item - bytes + + ``plugins`` + The List of available plugins """ width = screen[u'size'].width() height = screen[u'size'].height() diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 2248d0ddd..277842167 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -42,6 +42,13 @@ class PluginManager(object): """ log.info(u'Plugin manager loaded') + @staticmethod + def get_instance(): + """ + Obtain a single instance of class. + """ + return PluginManager.instance + def __init__(self, plugin_dir): """ The constructor for the plugin manager. Passes the controllers on to @@ -51,6 +58,7 @@ class PluginManager(object): The directory to search for plugins. """ log.info(u'Plugin manager Initialising') + PluginManager.instance = self if not plugin_dir in sys.path: log.debug(u'Inserting %s into sys.path', plugin_dir) sys.path.insert(0, plugin_dir) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 3d72f51a3..b157d7fe1 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -31,7 +31,7 @@ from PyQt4 import QtGui, QtCore, QtWebKit from openlp.core.lib import ServiceItem, expand_tags, \ build_lyrics_format_css, build_lyrics_outline_css, Receiver, \ - ItemCapabilities, FormattingTags + ItemCapabilities, FormattingTags, PluginManager from openlp.core.lib.theme import ThemeLevel from openlp.core.ui import MainDisplay, ScreenList @@ -55,7 +55,7 @@ class Renderer(object): """ log.info(u'Renderer Loaded') - def __init__(self, imageManager, themeManager, plugins): + def __init__(self, imageManager, themeManager): """ Initialise the renderer. @@ -69,7 +69,7 @@ class Renderer(object): log.debug(u'Initialisation started') self.themeManager = themeManager self.imageManager = imageManager - self.plugins = plugins + self.plugins = PluginManager.get_instance().plugins self.screens = ScreenList.get_instance() self.service_theme = u'' self.theme_level = u'' @@ -77,8 +77,7 @@ class Renderer(object): self.theme_data = None self.bg_frame = None self.force_page = False - self.display = MainDisplay(None, self.imageManager, False, self, - self.plugins) + self.display = MainDisplay(None, self.imageManager, False, self) self.display.setup() def update_display(self): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index fa8721d09..e41baf83d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ - translate + translate, PluginManager from openlp.core.ui import HideMode, ScreenList @@ -48,14 +48,14 @@ class Display(QtGui.QGraphicsView): """ This is a general display screen class. """ - def __init__(self, parent, live, controller, plugins): + def __init__(self, parent, live, controller): if live: QtGui.QGraphicsView.__init__(self) else: QtGui.QGraphicsView.__init__(self, parent) self.isLive = live self.controller = controller - self.plugins = plugins + self.plugins = PluginManager.get_instance().plugins self.setViewport(QtOpenGL.QGLWidget()) def setup(self): @@ -77,7 +77,7 @@ class Display(QtGui.QGraphicsView): screen[u'size'] = self.size() serviceItem = ServiceItem() self.webView.setHtml(build_html(serviceItem, screen, - None, None, None, self.plugins)) + None, self.isLive, None)) self.webView.hide() def resizeEvent(self, ev): @@ -88,8 +88,8 @@ class MainDisplay(Display): """ This is the display screen. """ - def __init__(self, parent, imageManager, live, controller, plugins): - Display.__init__(self, parent, live, controller, plugins) + def __init__(self, parent, imageManager, live, controller): + Display.__init__(self, parent, live, controller) self.imageManager = imageManager self.screens = ScreenList.get_instance() self.alertTab = None @@ -177,7 +177,7 @@ class MainDisplay(Display): 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.plugins)) + self.alertTab, self.isLive, None, None, self.plugins)) self.__hideMouse() # To display or not to display? if not self.screen[u'primary']: @@ -367,7 +367,7 @@ class MainDisplay(Display): else: image_bytes = None html = build_html(self.serviceItem, self.screen, self.alertTab, - self.isLive, background, self.plugins, image_bytes) + 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/mainwindow.py b/openlp/core/ui/mainwindow.py index 8aa76e08b..004d6f17e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -633,8 +633,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # warning cyclic dependency # renderer needs to call ThemeManager and # ThemeManager needs to call Renderer - self.renderer = Renderer(self.imageManager, self.themeManagerContents, - self.pluginManager.plugins) + self.renderer = Renderer(self.imageManager, self.themeManagerContents) # Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.mediaToolBox) log.info(u'Load Plugins') diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 9a23a9960..18b384848 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -39,6 +39,7 @@ class MediaState(object): class MediaType(object): """ + An enumeration of possibible Media Types """ Unused = 0 Audio = 1 diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b3b95fff5..9907377df 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -143,7 +143,7 @@ class MediaController(object): """ Add css style sheets to htmlbuilder """ - css = u''; + css = u'' for api in self.APIs.values(): css += api.get_media_display_css() return css @@ -263,6 +263,7 @@ class MediaController(object): controller.media_info.volume = controller.volumeSlider.value() controller.media_info.file_info = QtCore.QFileInfo(file) controller.media_info.is_background = isBackground + display = None if controller.isLive: if self.withLivePreview and controller.previewDisplay: display = controller.previewDisplay @@ -284,6 +285,7 @@ class MediaController(object): 'Unsupported File'))) return False # now start playing + display.frame.evaluateJavaScript(u'show_blank("black");') if self.video_play([controller], False): self.video_pause([controller]) self.video_seek([controller, [0]]) @@ -358,6 +360,7 @@ class MediaController(object): if not self.curDisplayMediaAPI[display].play(display): return False if status: + display.frame.evaluateJavaScript(u'show_blank("desktop");') self.curDisplayMediaAPI[display].set_visible(display, True) # Start Timer for ui updates if not self.timer.isActive(): @@ -382,6 +385,7 @@ class MediaController(object): controller = msg[0] for display in self.curDisplayMediaAPI.keys(): if display.controller == controller: + display.frame.evaluateJavaScript(u'show_blank("black");') self.curDisplayMediaAPI[display].stop(display) self.curDisplayMediaAPI[display].set_visible(display, False) @@ -440,7 +444,9 @@ class MediaController(object): Blank the related video Widget """ isLive = msg[1] + hide_mode = msg[2] if isLive: + Receiver.send_message(u'maindisplay_hide', hide_mode) controller = self.parent.liveController for display in self.curDisplayMediaAPI.keys(): if display.controller == controller: diff --git a/openlp/core/ui/media/webkitapi.py b/openlp/core/ui/media/webkitapi.py index 40b443f78..9467a2a55 100644 --- a/openlp/core/ui/media/webkitapi.py +++ b/openlp/core/ui/media/webkitapi.py @@ -34,7 +34,7 @@ from openlp.core.ui.media import MediaAPI, MediaState log = logging.getLogger(__name__) -video_css = u""" +VIDEO_CSS = u""" #video1 { z-index:3; } @@ -43,7 +43,7 @@ video_css = u""" } """ -video_js = u""" +VIDEO_JS = u""" var video_timer = null; var current_video = '1'; @@ -139,20 +139,20 @@ video_js = u""" } """ -video_html = u""" +VIDEO_HTML = u""" """ -flash_css = u""" +FLASH_CSS = u""" #flash { z-index:4; } """ -flash_js = u""" +FLASH_JS = u""" function getFlashMovieObject(movieName) { if (window.document[movieName]) @@ -211,7 +211,7 @@ flash_js = u""" } """ -flash_html = u""" +FLASH_HTML = u""" """ @@ -261,21 +261,21 @@ class WebkitAPI(MediaAPI): """ Add css style sheets to htmlbuilder """ - return video_css + flash_css + return VIDEO_CSS + FLASH_CSS def get_media_display_javascript(self): """ Add javascript functions to htmlbuilder """ - return video_js + flash_js + return VIDEO_JS + FLASH_JS def get_media_display_html(self): """ Add html code to htmlbuilder """ - return video_html + flash_html + return VIDEO_HTML + FLASH_HTML def setup(self, display): display.webView.resize(display.size()) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ebb1b630f..289cbdc8a 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -286,7 +286,7 @@ class SlideController(Controller): self.slideLayout.setSpacing(0) self.slideLayout.setMargin(0) self.slideLayout.setObjectName(u'SlideLayout') - self.previewDisplay = Display(self, self.isLive, self, self.parent().pluginManager.plugins) + self.previewDisplay = Display(self, self.isLive, self) self.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300)) self.slideLayout.insertWidget(0, self.previewDisplay) self.previewDisplay.hide() @@ -404,7 +404,7 @@ class SlideController(Controller): if self.display: self.display.close() self.display = MainDisplay(self, self.imageManager, self.isLive, - self, self.parent().pluginManager.plugins) + self) self.display.alertTab = self.alertTab self.display.setup() if self.isLive: @@ -528,7 +528,6 @@ class SlideController(Controller): if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin: self.toolbar.makeWidgetsVisible(self.songEditList) elif item.is_media(): - #self.toolbar.setVisible(False) self.mediabar.setVisible(True) self.previousItem.setVisible(False) self.nextItem.setVisible(False)