- fixed bug 871441 (Live Preview image is not updated when you "Replace live background")

- removed dead code
- fixed docstrings
- removed 'maindisplay_active' signal in same places

bzr-revno: 1781
This commit is contained in:
Andreas Preikschat 2011-10-19 19:30:32 +01:00 committed by Tim Bentley
commit e5401c7eac
2 changed files with 20 additions and 33 deletions

View File

@ -51,6 +51,8 @@ class MainDisplay(QtGui.QGraphicsView):
def __init__(self, parent, imageManager, live):
if live:
QtGui.QGraphicsView.__init__(self)
# Do not overwrite the parent() method.
self.parent = lambda: parent
else:
QtGui.QGraphicsView.__init__(self, parent)
self.isLive = live
@ -144,14 +146,6 @@ class MainDisplay(QtGui.QGraphicsView):
self.frame.setScrollBarPolicy(QtCore.Qt.Horizontal,
QtCore.Qt.ScrollBarAlwaysOff)
if self.isLive:
# Build the initial frame.
self.black = QtGui.QImage(
self.screen[u'size'].width(),
self.screen[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
painter_image = QtGui.QPainter()
painter_image.begin(self.black)
painter_image.fillRect(self.black.rect(), QtCore.Qt.black)
# Build the initial frame.
image_file = QtCore.QSettings().value(u'advanced/default image',
QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\
@ -208,7 +202,7 @@ class MainDisplay(QtGui.QGraphicsView):
"""
Add the slide text from slideController
`slide`
``slide``
The slide text to be displayed
"""
log.debug(u'text to display')
@ -221,20 +215,22 @@ class MainDisplay(QtGui.QGraphicsView):
def alert(self, text):
"""
Add the alert text
Display an alert.
`slide`
The slide text to be displayed
``text``
The text to be displayed.
"""
log.debug(u'alert to display')
if self.height() != self.screen[u'size'].height() or not \
self.isVisible() or self.videoWidget.isVisible():
shrink = True
else:
shrink = False
js = u'show_alert("%s", "%s")' % (
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'),
u'top' if shrink else u'')
u'top')
else:
shrink = False
js = u'show_alert("%s", "")' % (
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
height = self.frame.evaluateJavaScript(js)
if shrink:
if self.phononActive:
@ -257,13 +253,16 @@ class MainDisplay(QtGui.QGraphicsView):
def directImage(self, name, path, background):
"""
API for replacement backgrounds so Images are added directly to cache
API for replacement backgrounds so Images are added directly to cache.
"""
self.imageManager.add_image(name, path, u'image', background)
if hasattr(self, u'serviceItem'):
self.override[u'image'] = name
self.override[u'theme'] = self.serviceItem.themedata.theme_name
self.image(name)
# Update the preview frame.
if self.isLive:
self.parent().updatePreview()
return True
return False
@ -272,8 +271,8 @@ class MainDisplay(QtGui.QGraphicsView):
Add an image as the background. The image has already been added
to the cache.
`Image`
The name of the image to be displayed
``Image``
The name of the image to be displayed.
"""
log.debug(u'image to display')
image = self.imageManager.get_image_bytes(name)
@ -290,14 +289,11 @@ class MainDisplay(QtGui.QGraphicsView):
else:
js = u'show_image("");'
self.frame.evaluateJavaScript(js)
# Update the preview frame.
if self.isLive:
Receiver.send_message(u'maindisplay_active')
def resetImage(self):
"""
Reset the backgound image to the service item image.
Used after Image plugin has changed the background
Reset the backgound image to the service item image. Used after the
image plugin has changed the background.
"""
log.debug(u'resetImage')
if hasattr(self, u'serviceItem'):
@ -306,9 +302,6 @@ class MainDisplay(QtGui.QGraphicsView):
self.displayImage(None)
# clear the cache
self.override = {}
# Update the preview frame.
if self.isLive:
Receiver.send_message(u'maindisplay_active')
def resetVideo(self):
"""
@ -324,9 +317,6 @@ class MainDisplay(QtGui.QGraphicsView):
else:
self.frame.evaluateJavaScript(u'show_video("close");')
self.override = {}
# Update the preview frame.
if self.isLive:
Receiver.send_message(u'maindisplay_active')
def videoPlay(self):
"""
@ -406,9 +396,6 @@ class MainDisplay(QtGui.QGraphicsView):
self.webView.setVisible(False)
self.videoWidget.setVisible(True)
self.audio.setVolume(vol)
# Update the preview frame.
if self.isLive:
Receiver.send_message(u'maindisplay_active')
return True
def videoState(self, newState, oldState):

View File

@ -81,7 +81,7 @@ class AlertsManager(QtCore.QObject):
Format and request the Alert and start the timer
"""
log.debug(u'Generate Alert called')
if len(self.alertList) == 0:
if not self.alertList:
return
text = self.alertList.pop(0)
alertTab = self.parent().settings_tab