This commit is contained in:
Tim Bentley 2009-09-16 20:00:17 +01:00
commit 8b969449e7
4 changed files with 66 additions and 45 deletions

View File

@ -43,7 +43,8 @@ def translate(context, text):
``text`` ``text``
The text to put into the translation tables for translation. 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): def file_to_xml(xmlfile):
""" """
@ -87,6 +88,10 @@ def buildIcon(icon):
else: else:
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off) 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 return ButtonIcon
def contextMenuAction(base, icon, text, slot): def contextMenuAction(base, icon, text, slot):

View File

@ -63,7 +63,7 @@ class RenderManager(object):
else: else:
self.current_display = screen_number self.current_display = screen_number
self.renderer = Renderer() self.renderer = Renderer()
#self.calculate_default(self.screen_list[self.current_display][u'size']) self.calculate_default(self.screen_list[self.current_display][u'size'])
self.theme = u'' self.theme = u''
self.service_theme = u'' self.service_theme = u''
self.global_style = u'' self.global_style = u''

View File

@ -40,16 +40,18 @@ class SettingsManager(object):
if mainwindow_docbars > 300: if mainwindow_docbars > 300:
self.mainwindow_left = 300 self.mainwindow_left = 300
self.mainwindow_right = 300 self.mainwindow_right = 300
else:
self.mainwindow_left = mainwindow_docbars
self.mainwindow_right = mainwindow_docbars
self.mainwindow_left = int( ConfigHelper.get_config( #self.mainwindow_left = int( ConfigHelper.get_config(
u'user interface', u'mediamanager left', self.mainwindow_left)) # u'user interface', u'mediamanager left', self.mainwindow_left))
self.mainwindow_right = int( ConfigHelper.get_config( #self.mainwindow_right = int( ConfigHelper.get_config(
u'user interface', u'mediamanager right', self.mainwindow_right)) # 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 self.slidecontroller = (self.width - (
self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
self.slidecontroller_image = self.slidecontroller - 50 self.slidecontroller_image = self.slidecontroller - 50
print self.width, mainwindow_docbars, self.slidecontroller, self.slidecontroller_image
self.showMediaManager = str_to_bool( ConfigHelper.get_config( self.showMediaManager = str_to_bool( ConfigHelper.get_config(
u'user interface', u'display mediamanager', True)) u'user interface', u'display mediamanager', True))

View File

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