← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Temporarily fixes size issue with manager bars - this needs looking at properly so what Tim has started in saving user UI dimensions is finished.

Cleaned up print items - if devs want to use print lines can they either comment them out or remove them before they are commited to trunk please?

Started cleaning up media before an attempt on working video (on Windows) is made.

Other whitespace fixes on files touched in the above.
-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/11746
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2009-09-08 20:03:39 +0000
+++ openlp/core/lib/__init__.py	2009-09-14 22:10:08 +0000
@@ -43,7 +43,8 @@
     ``text``
         The text to put into the translation tables for translation.
     """
-    return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8)
+    return QtGui.QApplication.translate(context, text, None,
+        QtGui.QApplication.UnicodeUTF8)
 
 def file_to_xml(xmlfile):
     """
@@ -87,6 +88,10 @@
         else:
             ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
                 QtGui.QIcon.Normal, QtGui.QIcon.Off)
+    elif type(icon) is QtGui.QImage:
+        ButtonIcon = QtGui.QIcon()
+        ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(icon),
+            QtGui.QIcon.Normal, QtGui.QIcon.Off)
     return ButtonIcon
 
 def contextMenuAction(base, icon, text, slot):

=== modified file 'openlp/core/lib/settingsmanager.py'
--- openlp/core/lib/settingsmanager.py	2009-09-11 19:51:06 +0000
+++ openlp/core/lib/settingsmanager.py	2009-09-14 22:10:08 +0000
@@ -40,16 +40,18 @@
         if mainwindow_docbars > 300:
             self.mainwindow_left = 300
             self.mainwindow_right = 300
-
-        self.mainwindow_left = int( ConfigHelper.get_config(
-            u'user interface', u'mediamanager left', self.mainwindow_left))
-        self.mainwindow_right = int( ConfigHelper.get_config(
-            u'user interface', u'mediamanager right', self.mainwindow_right))
-        print self.mainwindow_left, self.mainwindow_right
-
-        self.slidecontroller = (self.width - (self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
+        else:
+            self.mainwindow_left = mainwindow_docbars
+            self.mainwindow_right = mainwindow_docbars
+
+        #self.mainwindow_left = int( ConfigHelper.get_config(
+        #    u'user interface', u'mediamanager left', self.mainwindow_left))
+        #self.mainwindow_right = int( ConfigHelper.get_config(
+        #    u'user interface', u'mediamanager right', self.mainwindow_right))
+
+        self.slidecontroller = (self.width - (
+            self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
         self.slidecontroller_image = self.slidecontroller - 50
-        print self.width, mainwindow_docbars, self.slidecontroller, self.slidecontroller_image
 
         self.showMediaManager = str_to_bool( ConfigHelper.get_config(
             u'user interface', u'display mediamanager', True))

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2009-09-08 19:58:05 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2009-09-14 22:10:08 +0000
@@ -28,16 +28,16 @@
 try:
     import gst
 except:
+    NOGST = True
     log = logging.getLogger(u'MediaMediaItemSetup')
     log.warning(u'Can\'t generate Videos previews - import gst failed');
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import MediaManagerItem, translate
+from openlp.core.lib import MediaManagerItem, ServiceItem, translate, \
+    BaseListWithDnD, buildIcon
 
-from openlp.plugins.media.lib import MediaTab
-from openlp.plugins.media.lib import FileListData
-from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon
+from openlp.plugins.media.lib import MediaTab, FileListData
 
 class MediaListView(BaseListWithDnD):
     def __init__(self, parent=None):
@@ -70,38 +70,50 @@
         MediaManagerItem.__init__(self, parent, icon, title)
 
     def video_get_preview(self, filename):
-        """Gets a preview of the first frame of a video file using
-        GSTREAMER (non-portable??? - Can't figure out how to do with
-        Phonon - returns a QImage"""
-        try:
-            # Define your pipeline, just as you would at the command prompt.
-            # This is much easier than trying to create and link each gstreamer element in Python.
-            # This is great for pipelines that end with a filesink (i.e. there is no audible or visual output)
-            log.info ("Video preview %s"%( filename))
-            outfile=tempfile.NamedTemporaryFile(suffix='.png')
-            cmd=u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name)
-            pipe = gst.parse_launch(cmd)
-            # Get a reference to the pipeline's bus
-            bus = pipe.get_bus()
-
-            # Set the pipeline's state to PLAYING
-            pipe.set_state(gst.STATE_PLAYING)
-
-            # Listen to the pipeline's bus indefinitely until we receive a EOS (end of stream) message.
-            # This is a super important step, or the pipeline might not work as expected.  For example,
-            # in my example pipeline above, the pngenc will not export an actual image unless you have
-            # this line of code.  It just exports a 0 byte png file.  So... don't forget this step.
-            bus.poll(gst.MESSAGE_EOS, -1)
-            img = QtGui.QImage(outfile.name)
-            outfile.close()
+        if NOGST:
+            #
+            # For now cross platform is an icon.  Phonon does not support
+            # individual frame access  (yet?) and GStreamer is not available
+            # on Windows
+            #
+            image = QtGui.QPixmap(u':/media/media_video.png').toImage()
+            return image
+        else:
+            """
+            Gets a preview of the first frame of a video file using GSTREAMER
+            (non-portable) - returns a QImage
+            """
+            try:
+                # Define your pipeline, just as you would at the command
+                # prompt.  This is much easier than trying to create and link
+                # each gstreamer element in Python.  This is great for
+                # pipelines that end with a filesink (i.e. there is no audible
+                # or visual output)
+                log.info ("Video preview %s"%( filename))
+                outfile = tempfile.NamedTemporaryFile(suffix='.png')
+                cmd = u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name)
+                pipe = gst.parse_launch(cmd)
+                # Get a reference to the pipeline's bus
+                bus = pipe.get_bus()
+
+                # Set the pipeline's state to PLAYING
+                pipe.set_state(gst.STATE_PLAYING)
+
+                # Listen to the pipeline's bus indefinitely until we receive a
+                # EOS (end of stream) message.  This is a super important step,
+                # or the pipeline might not work as expected.  For example, in
+                # my example pipeline above, the pngenc will not export an
+                # actual image unless you have this line of code.  It just
+                # exports a 0 byte png file.  So... don't forget this step.
+                bus.poll(gst.MESSAGE_EOS, -1)
+                img = QtGui.QImage(outfile.name)
+                outfile.close()
 #             os.unlink(outfile.name)
-            pipe.set_state(gst.STATE_NULL)
-            return img
-        except:
-            log.info("Can't generate video preview for some reason");
-            import sys
-            print sys.exc_info()
-            return None
+                pipe.set_state(gst.STATE_NULL)
+                return img
+            except:
+                log.info("Can't generate video preview for some reason");
+                return None
 
     def generateSlideData(self, service_item):
         indexes = self.ListView.selectedIndexes()
@@ -127,7 +139,8 @@
         pass
 
     def initialise(self):
-        self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
+        self.ListView.setSelectionMode(
+            QtGui.QAbstractItemView.ExtendedSelection)
         self.ListView.setIconSize(QtCore.QSize(88,50))
         self.loadList(self.parent.config.load_list(self.ConfigSection))
 
@@ -137,14 +150,15 @@
             item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
             row = self.ListView.row(item)
             self.ListView.takeItem(row)
-            self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
+            self.parent.config.set_list(
+                self.ConfigSection, self.ListData.getFileList())
 
     def loadList(self, list):
         for file in list:
             (path, filename) = os.path.split(unicode(file))
             item_name = QtGui.QListWidgetItem(filename)
             img = self.video_get_preview(file)
-            #item_name.setIcon(buildIcon(file))
+            item_name.setIcon(buildIcon(img))
             item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
             self.ListView.addItem(item_name)
 


Follow ups