From 6883427cbd2efa3a448cfcc71ff6038a9e1ad8f0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 10 Oct 2011 18:22:41 +0200 Subject: [PATCH 1/6] fixed bug 871441 Fixes: https://launchpad.net/bugs/871441 --- openlp/core/ui/maindisplay.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index d6eff912c..631c29f22 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -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 = parent else: QtGui.QGraphicsView.__init__(self, parent) self.isLive = live @@ -240,6 +242,9 @@ class MainDisplay(QtGui.QGraphicsView): 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 @@ -248,8 +253,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) @@ -272,8 +277,8 @@ class MainDisplay(QtGui.QGraphicsView): 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'): @@ -284,6 +289,7 @@ class MainDisplay(QtGui.QGraphicsView): self.override = {} # Update the preview frame. if self.isLive: + self._parent.updatePreview() Receiver.send_message(u'maindisplay_active') def resetVideo(self): From 658e8f234bbbd36dff54bd2c5cd4801824d32951 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 10 Oct 2011 18:37:46 +0200 Subject: [PATCH 2/6] clean ups --- openlp/core/ui/maindisplay.py | 13 ------------- openlp/plugins/alerts/lib/alertsmanager.py | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 631c29f22..f4b1383ba 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -271,9 +271,6 @@ 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): """ @@ -287,10 +284,6 @@ class MainDisplay(QtGui.QGraphicsView): self.displayImage(None) # clear the cache self.override = {} - # Update the preview frame. - if self.isLive: - self._parent.updatePreview() - Receiver.send_message(u'maindisplay_active') def resetVideo(self): """ @@ -306,9 +299,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): """ @@ -388,9 +378,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') def videoState(self, newState, oldState): """ diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index f2cb1eb4b..dcf3acafe 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -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 From 76f47a4f6282da127dac7fd37fbaadcea274c497 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 10 Oct 2011 18:54:01 +0200 Subject: [PATCH 3/6] - clean ups - only display alert when the screen is not hidden --- openlp/core/ui/maindisplay.py | 26 +++++++++++++--------- openlp/plugins/alerts/lib/alertsmanager.py | 3 ++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f4b1383ba..e383a2631 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -186,7 +186,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') @@ -199,20 +199,25 @@ class MainDisplay(QtGui.QGraphicsView): def alert(self, text): """ - Add the alert text + Add the alert text. If the alert was not displayed, because the screen + is not visible ``False`` is returned, otherwise ``True``. - `slide` - The slide text to be displayed + ``slide`` + The slide 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(): + if not self.isVisible(): + return False + if self.height() != self.screen[u'size'].height() or \ + self.videoWidget.isVisible(): shrink = True + js = u'show_alert("%s", "%s")' % ( + text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'), + u'top') else: shrink = False - js = u'show_alert("%s", "%s")' % ( - text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'), - u'top' if shrink else u'') + js = u'show_alert("%s", "")' % ( + text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) height = self.frame.evaluateJavaScript(js) if shrink: if self.phononActive: @@ -232,10 +237,11 @@ class MainDisplay(QtGui.QGraphicsView): else: shrinkItem.setVisible(False) self.setGeometry(self.screen[u'size']) + return True 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'): diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index dcf3acafe..b38415158 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -85,7 +85,8 @@ class AlertsManager(QtCore.QObject): return text = self.alertList.pop(0) alertTab = self.parent().settings_tab - self.parent().liveController.display.alert(text) + if not self.parent().liveController.display.alert(text): + self.alertList.insert(0, text) # Check to see if we have a timer running. if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) From ec5991a1976bd6d92ee952bc6c1099bc7facfbbe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 15 Oct 2011 09:36:51 +0200 Subject: [PATCH 4/6] =?UTF-8?q?removed=20dead=20code=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openlp/core/ui/maindisplay.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e383a2631..102bd7b8c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -122,14 +122,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'))\ From a1a79c98d1c8fa55c77ac2a70ad2015fa2c30d9e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 15 Oct 2011 09:52:25 +0200 Subject: [PATCH 5/6] overwrite parent method --- openlp/core/ui/maindisplay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 102bd7b8c..3edab4a6e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -52,7 +52,7 @@ class MainDisplay(QtGui.QGraphicsView): if live: QtGui.QGraphicsView.__init__(self) # Do not overwrite the parent() method. - self._parent = parent + self.parent = lambda: parent else: QtGui.QGraphicsView.__init__(self, parent) self.isLive = live @@ -242,7 +242,7 @@ class MainDisplay(QtGui.QGraphicsView): self.image(name) # Update the preview frame. if self.isLive: - self._parent.updatePreview() + self.parent().updatePreview() return True return False From 004472baa8a0848382b253522f9162b29ec68bcd Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 16 Oct 2011 16:53:39 +0200 Subject: [PATCH 6/6] reverted alert change --- openlp/core/ui/maindisplay.py | 14 +++++--------- openlp/plugins/alerts/lib/alertsmanager.py | 3 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3edab4a6e..d57b7ec5a 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -191,17 +191,14 @@ class MainDisplay(QtGui.QGraphicsView): def alert(self, text): """ - Add the alert text. If the alert was not displayed, because the screen - is not visible ``False`` is returned, otherwise ``True``. + Display an alert. - ``slide`` - The slide text to be displayed. + ``text`` + The text to be displayed. """ log.debug(u'alert to display') - if not self.isVisible(): - return False - if self.height() != self.screen[u'size'].height() or \ - self.videoWidget.isVisible(): + if self.height() != self.screen[u'size'].height() or not \ + self.isVisible() or self.videoWidget.isVisible(): shrink = True js = u'show_alert("%s", "%s")' % ( text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'), @@ -229,7 +226,6 @@ class MainDisplay(QtGui.QGraphicsView): else: shrinkItem.setVisible(False) self.setGeometry(self.screen[u'size']) - return True def directImage(self, name, path, background): """ diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index b38415158..dcf3acafe 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -85,8 +85,7 @@ class AlertsManager(QtCore.QObject): return text = self.alertList.pop(0) alertTab = self.parent().settings_tab - if not self.parent().liveController.display.alert(text): - self.alertList.insert(0, text) + self.parent().liveController.display.alert(text) # Check to see if we have a timer running. if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)