← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/alpha3 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/alpha3 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Move video and Image clean ups.
Transitions work again after last merge!
-- 
https://code.launchpad.net/~trb143/openlp/alpha3/+merge/29109
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/alpha3 into lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2010-06-30 04:52:52 +0000
+++ openlp/core/lib/serviceitem.py	2010-07-02 16:59:25 +0000
@@ -35,7 +35,6 @@
 from PyQt4 import QtGui
 
 from openlp.core.lib import build_icon, resize_image
-from openlp.core.utils import AppLocation
 
 log = logging.getLogger(__name__)
 
@@ -93,7 +92,6 @@
         self.is_valid = True
         self.cache = {}
         self.icon = None
-        self.serviceItemPath = AppLocation.get_section_data_path(u'serviceItems')
 
     def add_capability(self, capability):
         """
@@ -155,12 +153,9 @@
                         del self.cache[len(self._display_frames)]
                 log.log(15, u'Formatting took %4s' % (time.time() - before))
         elif self.service_item_type == ServiceItemType.Image:
-            for count, slide in enumerate(self._raw_frames):
+            for slide in self._raw_frames:
                 slide[u'image'] = resize_image(slide[u'image'],
                     self.render_manager.width, self.render_manager.height)
-                path = os.path.join(self.serviceItemPath, self._uuid + unicode(count) + u'.png')
-                slide[u'image'].save(path)
-                slide[u'display'] = path
         elif self.service_item_type == ServiceItemType.Command:
             pass
         else:
@@ -376,8 +371,7 @@
         if self.service_item_type == ServiceItemType.Text:
             return self.render_individual(row)
         else:
-            return {u'main':self._raw_frames[row][u'image'],
-                    u'trans':None, u'display':self._raw_frames[row][u'display']}
+            return {u'main':self._raw_frames[row][u'image'], u'trans':None}
 
     def get_frame_title(self, row=0):
         """

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2010-06-30 16:30:25 +0000
+++ openlp/core/ui/maindisplay.py	2010-07-02 16:59:25 +0000
@@ -25,13 +25,13 @@
 
 import logging
 import os
+import time
 
 from PyQt4 import QtCore, QtGui, QtWebKit
 from PyQt4.phonon import Phonon
 
 from openlp.core.lib import Receiver, resize_image
 from openlp.core.ui import HideMode
-from openlp.core.utils import AppLocation
 
 log = logging.getLogger(__name__)
 
@@ -104,11 +104,17 @@
         """
         self.mainDisplay.addAlert(alertMessage, location)
 
-    def displayImage(self, path):
-        """
-        Handles the addition of a background Image to the displays
-        """
-        self.mainDisplay.displayImage(path)
+    def displayImageWithText(self, frame):
+        """
+        Handles the addition of a background Image to the displays
+        """
+        self.mainDisplay.addImageWithText(frame)
+
+    def displayImage(self, frame):
+        """
+        Handles the addition of a background Image to the displays
+        """
+        self.mainDisplay.displayImage(frame)
 
     def displayVideo(self, path):
         """
@@ -212,6 +218,7 @@
             pass
         self.screens = screens
         self.setupScene()
+        self.setupVideo()
         self.setupImage()
         self.setupText()
         self.setupAlert()
@@ -248,7 +255,7 @@
             (self.screen[u'size'].width() - splash_image.width()) / 2,
             (self.screen[u'size'].height() - splash_image.height()) / 2,
             splash_image)
-        #self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.InitialFrame))
+        self.displayImage(self.InitialFrame)
         self.repaint()
         #Build a Black screen
         painter = QtGui.QPainter()
@@ -262,7 +269,7 @@
         self.transparent = QtGui.QPixmap(
             self.screen[u'size'].width(), self.screen[u'size'].height())
         self.transparent.fill(QtCore.Qt.transparent)
-#        self.display_text.setPixmap(self.transparent)
+#        self.displayText.setPixmap(self.transparent)
         #self.frameView(self.transparent)
         # To display or not to display?
         if not self.screen[u'primary']:
@@ -277,25 +284,30 @@
         self.scene.setSceneRect(0,0,self.size().width(), self.size().height())
         self.setScene(self.scene)
 
-    def setupImage(self):
+    def setupVideo(self):
         self.webView = QtWebKit.QWebView()
         self.page = self.webView.page()
-        self.imageDisplay = self.page.mainFrame()
-        self.imageDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff)
-        self.imageDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff)
+        self.videoDisplay = self.page.mainFrame()
+        self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff)
+        self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff)
         self.proxy = QtGui.QGraphicsProxyWidget()
         self.proxy.setWidget(self.webView)
         self.proxy.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
-        self.proxy.setZValue(2)
+        self.proxy.setZValue(1)
         self.scene.addItem(self.proxy)
 
+    def setupImage(self):
+        self.imageDisplay = QtGui.QGraphicsPixmapItem()
+        self.imageDisplay.setZValue(2)
+        self.scene.addItem(self.imageDisplay)
+
     def setupText(self):
-        #self.display_text = QtGui.QGraphicsTextItem()
-        self.display_text = QtGui.QGraphicsPixmapItem()
-        #self.display_text.setPos(0,0)
-        #self.display_text.setTextWidth(self.size().width())
-        self.display_text.setZValue(4)
-        self.scene.addItem(self.display_text)
+        #self.displayText = QtGui.QGraphicsTextItem()
+        self.displayText = QtGui.QGraphicsPixmapItem()
+        #self.displayText.setPos(0,0)
+        #self.displayText.setTextWidth(self.size().width())
+        self.displayText.setZValue(4)
+        self.scene.addItem(self.displayText)
 
     def setupAlert(self):
         self.alertText = QtGui.QGraphicsTextItem()
@@ -304,9 +316,9 @@
         self.scene.addItem(self.alertText)
 
     def setupBlank(self):
-        self.display_blank = QtGui.QGraphicsPixmapItem()
-        self.display_blank.setZValue(10)
-        self.scene.addItem(self.display_blank)
+        self.displayBlank = QtGui.QGraphicsPixmapItem()
+        self.displayBlank.setZValue(10)
+        self.scene.addItem(self.displayBlank)
 
     def resetDisplay(self):
         log.debug(u'resetDisplay')
@@ -328,19 +340,19 @@
         Store the images so they can be replaced when required
         """
         log.debug(u'hideDisplay mode = %d', mode)
-        #self.display_text.setPixmap(self.transparent)
+        #self.displayText.setPixmap(self.transparent)
         if mode == HideMode.Screen:
             #self.display_image.setPixmap(self.transparent)
             self.setVisible(False)
         elif mode == HideMode.Blank:
-            self.display_blank.setPixmap(
+            self.displayBlank.setPixmap(
                 QtGui.QPixmap.fromImage(self.blankFrame))
         else:
             if self.parent.renderManager.renderer.bg_frame:
-                self.display_blank.setPixmap(QtGui.QPixmap.fromImage(
+                self.displayBlank.setPixmap(QtGui.QPixmap.fromImage(
                     self.parent.renderManager.renderer.bg_frame))
             else:
-                self.display_blank.setPixmap(
+                self.displayBlank.setPixmap(
                     QtGui.QPixmap.fromImage(self.blankFrame))
 
     def showDisplay(self, message=u''):
@@ -350,7 +362,7 @@
         Make the stored images None to release memory.
         """
         log.debug(u'showDisplay')
-        self.display_blank.setPixmap(self.transparent)
+        self.displayBlank.setPixmap(self.transparent)
         #Trigger actions when display is active again
         Receiver.send_message(u'maindisplay_active')
 
@@ -358,7 +370,8 @@
         log.debug(u'addImageWithText')
         frame = resize_image(
             frame, self.screen[u'size'].width(), self.screen[u'size'].height())
-        self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
+        self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(frame))
+        self.videoDisplay.setHtml(u'<html></html>')
 
     def addAlert(self, message, location):
         """
@@ -378,14 +391,18 @@
             self.alertText.setPos(0,self.size().height() - 76)
         self.alertText.setHtml(message)
 
-    def displayImage(self, path):
+    def displayImage(self, frame):
         """
         Places the Image passed on the display screen
-        ``path``
-            The path to the image to be displayed
+        ``frame``
+            The image to be displayed
         """
         log.debug(u'adddisplayImage')
-        self.imageDisplay.setHtml(HTMLIMAGE % path)
+        if isinstance(frame, QtGui.QImage):
+            self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(frame))
+        else:
+            self.imageDisplay.setPixmap(frame)
+        self.videoDisplay.setHtml(u'<html></html>')
 
     def displayVideo(self, path):
         """
@@ -394,7 +411,8 @@
             The path to the image to be displayed
         """
         log.debug(u'adddisplayVideo')
-        self.imageDisplay.setHtml(HTMLVIDEO %
+        self.displayImage(self.transparent)
+        self.videoDisplay.setHtml(HTMLVIDEO %
             (path, self.screen[u'size'].width(), self.screen[u'size'].height()))
 
     def frameView(self, frame, transition=False):
@@ -409,42 +427,29 @@
         log.debug(u'frameView')
         if transition:
             if self.frame is not None:
-                self.display_text.setPixmap(
+                self.displayText.setPixmap(
                     QtGui.QPixmap.fromImage(self.frame))
-                self.update()
+                self.repaint()
+                Receiver.send_message(u'openlp_process_events')
+                time.sleep(0.1)
             self.frame = None
             if frame[u'trans'] is not None:
-                self.display_text.setPixmap(
+                self.displayText.setPixmap(
                     QtGui.QPixmap.fromImage(frame[u'trans']))
                 self.repaint()
+                Receiver.send_message(u'openlp_process_events')
+                time.sleep(0.1)
                 self.frame = frame[u'trans']
-            self.display_text.setPixmap(
+            self.displayText.setPixmap(
                 QtGui.QPixmap.fromImage(frame[u'main']))
-            self.display_frame = frame[u'main']
-            self.repaint()
         else:
             if isinstance(frame, QtGui.QPixmap):
-                self.display_text.setPixmap(frame)
+                self.displayText.setPixmap(frame)
             else:
-                self.display_text.setPixmap(QtGui.QPixmap.fromImage(frame))
-            self.display_frame = frame
+                self.displayText.setPixmap(QtGui.QPixmap.fromImage(frame))
         if not self.isVisible() and self.screens.display:
             self.setVisible(True)
 
-    def closeEvent(self, event):
-        """
-        Shutting down cleans up background files
-        """
-        serviceItemPath = AppLocation.get_section_data_path(u'serviceItems')
-        for file in os.listdir(serviceItemPath):
-            file_path = os.path.join(serviceItemPath, file)
-            try:
-                if os.path.isfile(file_path):
-                    os.remove(file_path)
-            except OSError:
-                log.exception(u'Failed to clean up servicePath')
-
-
 class VideoDisplay(Phonon.VideoWidget):
     """
     This is the form that is used to display videos on the projector.

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2010-06-30 04:52:52 +0000
+++ openlp/core/ui/slidecontroller.py	2010-07-02 16:59:25 +0000
@@ -785,7 +785,7 @@
                     if self.serviceItem.is_text():
                         self.mainDisplay.frameView(frame, True)
                     else:
-                        self.displayManager.displayImage(frame[u'display'])
+                        self.displayManager.displayImage(frame[u'main'])
             self.selectedRow = row
         Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
             row)

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2010-06-30 17:05:12 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2010-07-02 16:59:25 +0000
@@ -173,11 +173,12 @@
         if check_item_selected(self.ListView,
             translate('ImagePlugin.MediaItem',
             'You must select an item to process.')):
-            item = self.buildServiceItem()
-            item.render()
-            self.parent.live_controller.displayManager. \
-                displayImage(item.get_rendered_frame(0)[u'display'])
-
+            items = self.ListView.selectedIndexes()
+            for item in items:
+                bitem = self.ListView.item(item.row())
+                filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
+                frame = QtGui.QImage(unicode(filename))
+                self.parent.live_controller.displayManager.displayImageWithText(frame)
 
     def onPreviewClick(self):
         MediaManagerItem.onPreviewClick(self)


Follow ups