2009-05-15 05:15:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2009 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
|
|
|
|
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2009-05-15 05:15:53 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
|
2009-09-25 00:43:42 +00:00
|
|
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, buildIcon
|
2009-07-04 05:52:30 +00:00
|
|
|
|
2009-06-25 21:09:52 +00:00
|
|
|
class MediaListView(BaseListWithDnD):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
self.PluginName = u'Media'
|
|
|
|
BaseListWithDnD.__init__(self, parent)
|
2009-05-15 05:15:53 +00:00
|
|
|
|
|
|
|
class MediaMediaItem(MediaManagerItem):
|
|
|
|
"""
|
2009-05-16 10:24:03 +00:00
|
|
|
This is the custom media manager item for Media Slides.
|
2009-05-15 05:15:53 +00:00
|
|
|
"""
|
|
|
|
global log
|
2009-05-22 18:30:25 +00:00
|
|
|
log = logging.getLogger(u'MediaMediaItem')
|
2009-05-15 05:15:53 +00:00
|
|
|
log.info(u'Media Media Item loaded')
|
|
|
|
|
|
|
|
def __init__(self, parent, icon, title):
|
2009-10-28 01:36:24 +00:00
|
|
|
self.PluginNameShort = u'Media'
|
2009-07-04 05:52:30 +00:00
|
|
|
self.IconPath = u'images/image'
|
2009-10-07 16:16:21 +00:00
|
|
|
self.ConfigSection = u'media'
|
2009-10-30 17:44:16 +00:00
|
|
|
self.ConfigSection = title
|
2009-06-25 21:09:52 +00:00
|
|
|
# this next is a class, not an instance of a class - it will
|
|
|
|
# be instanced by the base MediaManagerItem
|
|
|
|
self.ListViewWithDnD_class = MediaListView
|
2009-06-30 20:35:53 +00:00
|
|
|
self.PreviewFunction = self.video_get_preview
|
2009-05-15 05:15:53 +00:00
|
|
|
MediaManagerItem.__init__(self, parent, icon, title)
|
2009-11-03 01:38:15 +00:00
|
|
|
self.ServiceItemIconName = u':/media/media_video.png'
|
2009-10-19 17:51:21 +00:00
|
|
|
self.MainDisplay = self.parent.live_controller.parent.mainDisplay
|
2009-05-15 05:15:53 +00:00
|
|
|
|
2009-10-29 01:48:43 +00:00
|
|
|
def initPluginNameVisible(self):
|
2009-11-26 18:43:49 +00:00
|
|
|
self.PluginNameVisible = self.trUtf8('Media')
|
2009-05-15 05:15:53 +00:00
|
|
|
|
2009-10-31 16:17:26 +00:00
|
|
|
def retranslateUi(self):
|
2009-11-26 18:43:49 +00:00
|
|
|
self.OnNewPrompt = self.trUtf8('Select Media')
|
|
|
|
self.OnNewFileMasks = self.trUtf8('Videos (*.avi *.mpeg *.mpg'
|
2009-10-29 18:25:34 +00:00
|
|
|
'*.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)')
|
|
|
|
|
2009-09-26 09:11:39 +00:00
|
|
|
def requiredIcons(self):
|
|
|
|
MediaManagerItem.requiredIcons(self)
|
|
|
|
self.hasFileIcon = True
|
|
|
|
self.hasNewIcon = False
|
|
|
|
self.hasEditIcon = False
|
|
|
|
|
2009-10-29 18:25:34 +00:00
|
|
|
def video_get_preview(self):
|
2009-09-15 21:59:20 +00:00
|
|
|
# For now cross platform is an icon. Phonon does not support
|
|
|
|
# individual frame access (yet?) and GStreamer is not available
|
|
|
|
# on Windows
|
2009-10-30 17:44:16 +00:00
|
|
|
return QtGui.QPixmap(u':/media/media_video.png').toImage()
|
2009-05-15 05:15:53 +00:00
|
|
|
|
2009-06-25 21:09:52 +00:00
|
|
|
def generateSlideData(self, service_item):
|
2009-10-29 18:25:34 +00:00
|
|
|
items = self.ListView.selectedIndexes()
|
|
|
|
if len(items) > 1:
|
2009-08-31 21:53:35 +00:00
|
|
|
return False
|
2009-11-26 18:43:49 +00:00
|
|
|
service_item.title = unicode(self.trUtf8('Media'))
|
2009-10-29 18:25:34 +00:00
|
|
|
for item in items:
|
|
|
|
bitem = self.ListView.item(item.row())
|
|
|
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
|
|
|
frame = u':/media/media_video.png'
|
2009-06-25 21:09:52 +00:00
|
|
|
(path, name) = os.path.split(filename)
|
2009-11-01 16:06:59 +00:00
|
|
|
service_item.add_from_command(path, name, frame)
|
2009-08-31 21:53:35 +00:00
|
|
|
return True
|
2009-05-15 05:15:53 +00:00
|
|
|
|
2009-07-04 05:52:30 +00:00
|
|
|
def initialise(self):
|
2009-09-14 22:10:08 +00:00
|
|
|
self.ListView.setSelectionMode(
|
|
|
|
QtGui.QAbstractItemView.ExtendedSelection)
|
2009-07-04 05:52:30 +00:00
|
|
|
self.ListView.setIconSize(QtCore.QSize(88,50))
|
|
|
|
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
|
|
|
|
|
|
|
def onDeleteClick(self):
|
|
|
|
item = self.ListView.currentItem()
|
2009-11-03 19:01:53 +00:00
|
|
|
if item:
|
2009-07-04 05:52:30 +00:00
|
|
|
row = self.ListView.row(item)
|
|
|
|
self.ListView.takeItem(row)
|
2009-09-14 22:10:08 +00:00
|
|
|
self.parent.config.set_list(
|
2009-09-15 21:59:20 +00:00
|
|
|
self.ConfigSection, self.getFileList())
|
2009-07-04 05:52:30 +00:00
|
|
|
|
|
|
|
def loadList(self, list):
|
|
|
|
for file in list:
|
|
|
|
(path, filename) = os.path.split(unicode(file))
|
|
|
|
item_name = QtGui.QListWidgetItem(filename)
|
2009-10-29 18:25:34 +00:00
|
|
|
img = self.video_get_preview()
|
2009-09-14 22:10:08 +00:00
|
|
|
item_name.setIcon(buildIcon(img))
|
2009-07-04 05:52:30 +00:00
|
|
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
|
|
|
self.ListView.addItem(item_name)
|