forked from openlp/openlp
Latest trunk merged
This commit is contained in:
commit
2b13e84c73
@ -74,5 +74,10 @@ from songxmlhandler import SongXMLParser
|
||||
from themexmlhandler import ThemeXML
|
||||
from renderer import Renderer
|
||||
from rendermanager import RenderManager
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from baselistwithdnd import BaseListWithDnD
|
||||
from listwithpreviews import ListWithPreviews
|
||||
|
||||
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool', 'contextMenuAction', 'contextMenuSeparator']
|
||||
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool',
|
||||
'contextMenuAction', 'contextMenuSeparator','ServiceItem'
|
||||
]
|
||||
|
47
openlp/core/lib/baselistwithdnd.py
Normal file
47
openlp/core/lib/baselistwithdnd.py
Normal file
@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008-2009 Raoul Snyman
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
||||
|
||||
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
|
||||
"""
|
||||
import types
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib.toolbar import *
|
||||
from openlp.core.lib import translate
|
||||
|
||||
class BaseListWithDnD(QtGui.QListView):
|
||||
|
||||
def __init__(self,parent = None):
|
||||
QtGui.QListView.__init__(self,parent)
|
||||
assert (self.PluginName) # this must be set by the class which is inheriting
|
||||
def mouseMoveEvent(self, event):
|
||||
"""
|
||||
Drag and drop event does not care what data is selected
|
||||
as the recipient will use events to request the data move
|
||||
just tell it what plugin to call
|
||||
"""
|
||||
if event.buttons() != QtCore.Qt.LeftButton:
|
||||
return
|
||||
drag = QtGui.QDrag(self)
|
||||
mimeData = QtCore.QMimeData()
|
||||
drag.setMimeData(mimeData)
|
||||
mimeData.setText(self.PluginName)
|
||||
dropAction = drag.start(QtCore.Qt.CopyAction)
|
||||
if dropAction == QtCore.Qt.CopyAction:
|
||||
self.close()
|
||||
|
||||
|
@ -29,24 +29,18 @@ class ListWithPreviews(QtCore.QAbstractListModel):
|
||||
log = logging.getLogger(u'ListWithPreviews')
|
||||
log.info(u'started')
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, new_preview_function=None):
|
||||
QtCore.QAbstractListModel.__init__(self)
|
||||
# will be a list of (full filename, QPixmap, shortname) tuples
|
||||
self.items = []
|
||||
self.rowheight = 50
|
||||
self.maximagewidth = self.rowheight * 16 / 9.0;
|
||||
if new_preview_function is not None:
|
||||
self.make_preview=new_preview_function
|
||||
else:
|
||||
self.make_preview=self.preview_function
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self.items)
|
||||
|
||||
def insertRow(self, row, filename):
|
||||
self.beginInsertRows(QtCore.QModelIndex(), row, row)
|
||||
#log.info(u'insert row %d:%s' % (row,filename))
|
||||
# get short filename to display next to image
|
||||
filename = unicode(filename)
|
||||
(prefix, shortfilename) = os.path.split(filename)
|
||||
#log.info(u'shortfilename=%s' % (shortfilename))
|
||||
# create a preview image
|
||||
def preview_function(self, filename):
|
||||
if os.path.exists(filename):
|
||||
preview = QtGui.QImage(filename)
|
||||
w = self.maximagewidth;
|
||||
@ -64,6 +58,20 @@ class ListWithPreviews(QtCore.QAbstractListModel):
|
||||
h = self.rowheight
|
||||
p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
p.fill(QtCore.Qt.transparent)
|
||||
return p
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self.items)
|
||||
|
||||
def insertRow(self, row, filename):
|
||||
self.beginInsertRows(QtCore.QModelIndex(), row, row)
|
||||
#log.info(u'insert row %d:%s' % (row,filename))
|
||||
# get short filename to display next to image
|
||||
filename = unicode(filename)
|
||||
(prefix, shortfilename) = os.path.split(filename)
|
||||
#log.info(u'shortfilename=%s' % (shortfilename))
|
||||
# create a preview image
|
||||
p=self.make_preview(filename)
|
||||
# finally create the row
|
||||
self.items.insert(row, (filename, p, shortfilename))
|
||||
self.endInsertRows()
|
@ -21,11 +21,17 @@ import types
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib.toolbar import *
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from listwithpreviews import ListWithPreviews
|
||||
from serviceitem import ServiceItem
|
||||
class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
MediaManagerItem is a helper widget for plugins.
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'MediaManagerItem')
|
||||
log.info(u'Media Item loaded')
|
||||
|
||||
def __init__(self, parent=None, icon=None, title=None):
|
||||
"""
|
||||
Constructor to create the media manager item.
|
||||
@ -49,15 +55,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.retranslateUi()
|
||||
self.initialise()
|
||||
|
||||
def setupUi(self):
|
||||
pass
|
||||
|
||||
def retranslateUi(self):
|
||||
pass
|
||||
|
||||
def initialise(self):
|
||||
pass
|
||||
|
||||
def addToolbar(self):
|
||||
"""
|
||||
A method to help developers easily add a toolbar to the media manager
|
||||
@ -106,3 +106,138 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
||||
####################################################################################################
|
||||
### None of the following *need* to be used, feel free to override
|
||||
### them cmopletely in your plugin's implementation. Alternatively, call them from your
|
||||
### plugin before or after you've done etra things that you need to.
|
||||
### in order for them to work, you need to have setup
|
||||
# self.TranslationContext
|
||||
# self.PluginTextShort # eg "Image" for the image plugin
|
||||
# self.ConfigSection - where the items in the media manager are stored
|
||||
# this could potentially be self.PluginTextShort.lower()
|
||||
#
|
||||
# self.OnNewPrompt=u'Select Image(s)'
|
||||
# self.OnNewFileMasks=u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
|
||||
# assumes that the new action is to load a file. If not, override onnew
|
||||
# self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD())
|
||||
# each plugin needs to inherit a class from this and pass that *class* (not an instance) to here
|
||||
# via the ListViewWithDnD_class member
|
||||
# The assumption is that given that at least two plugins are of the form
|
||||
# "text with an icon" then all this will help
|
||||
# even for plugins of another sort, the setup of the right-click menu, common toolbar
|
||||
# will help to keep things consistent and ease the creation of new plugins
|
||||
|
||||
# also a set of completely consistent action anesm then exist
|
||||
# (onPreviewClick() is always called that, rather than having the
|
||||
# name of the plugin added in as well... I regard that as a
|
||||
# feature, I guess others might differ!)
|
||||
|
||||
def setupUi(self):
|
||||
# Add a toolbar
|
||||
self.addToolbar()
|
||||
# Create buttons for the toolbar
|
||||
## New Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(self.TranslationContext, u'Load '+self.PluginTextShort),
|
||||
translate(self.TranslationContext, u'Load item into openlp.org'),
|
||||
u':/images/image_load.png', self.onNewClick, u'ImageNewItem')
|
||||
## Delete Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(self.TranslationContext, u'Delete '+self.PluginTextShort),
|
||||
translate(self.TranslationContext, u'Delete the selected item'),
|
||||
u':/images/image_delete.png', self.onDeleteClick, u'DeleteItem')
|
||||
## Separator Line ##
|
||||
self.addToolbarSeparator()
|
||||
## Preview Button ##
|
||||
self.addToolbarButton(
|
||||
translate(self.TranslationContext, u'Preview '+self.PluginTextShort),
|
||||
translate(self.TranslationContext, u'Preview the selected item'),
|
||||
u':/system/system_preview.png', self.onPreviewClick, u'PreviewItem')
|
||||
## Live Button ##
|
||||
self.addToolbarButton(
|
||||
translate(self.TranslationContext, u'Go Live'),
|
||||
translate(self.TranslationContext, u'Send the selected item live'),
|
||||
u':/system/system_live.png', self.onLiveClick, u'LiveItem')
|
||||
## Add Button ##
|
||||
self.addToolbarButton(
|
||||
translate(self.TranslationContext, u'Add '+self.PluginTextShort+u' To Service'),
|
||||
translate(self.TranslationContext, u'Add the selected item(s) to the service'),
|
||||
u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem')
|
||||
#Add the List widget
|
||||
self.ListView = self.ListViewWithDnD_class()
|
||||
self.ListView.uniformItemSizes = True
|
||||
self.ListData = ListWithPreviews()
|
||||
self.ListView.setModel(self.ListData)
|
||||
self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
||||
self.ListView.setSpacing(1)
|
||||
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.ListView.setAlternatingRowColors(True)
|
||||
self.ListView.setDragEnabled(True)
|
||||
self.ListView.setObjectName(self.PluginTextShort+u'ListView')
|
||||
self.PageLayout.addWidget(self.ListView)
|
||||
#define and add the context menu
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.ListView.addAction(self.contextMenuAction(
|
||||
self.ListView, ':/system/system_preview.png',
|
||||
translate(self.TranslationContext, u'&Preview '+self.PluginTextShort),
|
||||
self.onPreviewClick))
|
||||
self.ListView.addAction(self.contextMenuAction(
|
||||
self.ListView, ':/system/system_live.png',
|
||||
translate(self.TranslationContext, u'&Show Live'),
|
||||
self.onLiveClick))
|
||||
self.ListView.addAction(self.contextMenuAction(
|
||||
self.ListView, ':/system/system_add.png',
|
||||
translate(self.TranslationContext, u'&Add to Service'),
|
||||
self.onAddClick))
|
||||
QtCore.QObject.connect(self.ListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
||||
|
||||
def initialise(self):
|
||||
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
||||
|
||||
def onNewClick(self):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||
translate(self.TranslationContext, self.OnNewPrompt),
|
||||
self.parent.config.get_last_dir(),
|
||||
self.OnNewFileMasks)
|
||||
log.info(u'New files(s)', unicode(files))
|
||||
if len(files) > 0:
|
||||
self.loadList(files)
|
||||
dir, filename = os.path.split(unicode(files[0]))
|
||||
self.parent.config.set_last_dir(dir)
|
||||
self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
|
||||
|
||||
def loadList(self, list):
|
||||
for file in list:
|
||||
self.ListData.addRow(file)
|
||||
|
||||
def onDeleteClick(self):
|
||||
indexes = self.ListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
current_row = int(index.row())
|
||||
self.ListData.removeRow(current_row)
|
||||
self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
|
||||
|
||||
def generateSlideData(self):
|
||||
assert (0, 'This fn needs to be defined by the plugin');
|
||||
|
||||
def onPreviewClick(self):
|
||||
log.debug(self.PluginTextShort+u'Preview Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
def onLiveClick(self):
|
||||
log.debug(self.PluginTextShort+u' Live Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
|
||||
def onAddClick(self):
|
||||
log.debug(self.PluginTextShort+u' Add Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
|
@ -21,6 +21,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import PluginConfig
|
||||
# why does this not work???
|
||||
# from openlp.core.lib import Event, EventType
|
||||
# so I have to do this???
|
||||
from event import Event, EventType
|
||||
|
||||
class Plugin(object):
|
||||
"""
|
||||
@ -66,6 +70,9 @@ class Plugin(object):
|
||||
A method used to render something to the screen, given the current theme
|
||||
and screen number.
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'Plugin')
|
||||
log.info(u'loaded')
|
||||
|
||||
def __init__(self, name=None, version=None, plugin_helpers=None):
|
||||
"""
|
||||
@ -95,6 +102,7 @@ class Plugin(object):
|
||||
self.render_manager = plugin_helpers[u'render']
|
||||
self.service_manager = plugin_helpers[u'service']
|
||||
self.settings= plugin_helpers[u'settings']
|
||||
self.dnd_id=None
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
@ -138,7 +146,23 @@ class Plugin(object):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
pass
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object. If you want
|
||||
to use this default behaviour, you must set self.dnd_id equal
|
||||
to that sent by the dnd source - eg the MediaItem
|
||||
"""
|
||||
# default behaviour - can be overridden if desired
|
||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Service Item received')
|
||||
self.media_item.onAddClick()
|
||||
if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Preview Item received')
|
||||
self.media_item.onPreviewClick()
|
||||
if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Live Show Item received')
|
||||
self.media_item.onLiveClick()
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
|
@ -37,6 +37,7 @@ class ImagePlugin(Plugin):
|
||||
self.icon = QtGui.QIcon()
|
||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.dnd_id = u'Image' # passed with drag and drop messages
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the MediaManagerItem object
|
||||
@ -46,17 +47,3 @@ class ImagePlugin(Plugin):
|
||||
def initialise(self):
|
||||
log.info(u'Plugin Initialising')
|
||||
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.LoadServiceItem and event.payload == 'Image':
|
||||
log.debug(u'Load Service Item received')
|
||||
self.media_item.onImageAddClick()
|
||||
if event.event_type == EventType.PreviewShow and event.payload == 'Image':
|
||||
log.debug(u'Load Preview Item received')
|
||||
self.media_item.onImagePreviewClick()
|
||||
if event.event_type == EventType.LiveShow and event.payload == 'Image':
|
||||
log.debug(u'Load Live Show Item received')
|
||||
self.media_item.onImageLiveClick()
|
||||
|
@ -17,5 +17,6 @@ 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
|
||||
"""
|
||||
|
||||
from listwithpreviews import ListWithPreviews
|
||||
from mediaitem import ImageMediaItem
|
||||
|
@ -22,29 +22,16 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, ServiceItem, translate
|
||||
from openlp.plugins.images.lib import ListWithPreviews
|
||||
# from openlp.plugins.images.lib import ListWithPreviews
|
||||
from listwithpreviews import ListWithPreviews
|
||||
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
|
||||
|
||||
class ImageList(QtGui.QListView):
|
||||
|
||||
def __init__(self,parent=None,name=None):
|
||||
QtGui.QListView.__init__(self,parent)
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
"""
|
||||
Drag and drop event does not care what data is selected
|
||||
as the recepient will use events to request the data move
|
||||
just tell it what plugin to call
|
||||
"""
|
||||
if event.buttons() != QtCore.Qt.LeftButton:
|
||||
return
|
||||
drag = QtGui.QDrag(self)
|
||||
mimeData = QtCore.QMimeData()
|
||||
drag.setMimeData(mimeData)
|
||||
mimeData.setText(u'Image')
|
||||
dropAction = drag.start(QtCore.Qt.CopyAction)
|
||||
if dropAction == QtCore.Qt.CopyAction:
|
||||
self.close()
|
||||
# We have to explicitly create separate classes for each plugin
|
||||
# in order for DnD to the Service manager to work correctly.
|
||||
class ImageListView(BaseListWithDnD):
|
||||
def __init__(self, parent=None):
|
||||
self.PluginName = u'Image'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
class ImageMediaItem(MediaManagerItem):
|
||||
"""
|
||||
@ -55,120 +42,23 @@ class ImageMediaItem(MediaManagerItem):
|
||||
log.info(u'Image Media Item loaded')
|
||||
|
||||
def __init__(self, parent, icon, title):
|
||||
self.TranslationContext = u'ImagePlugin'
|
||||
self.PluginTextShort = u'Image'
|
||||
self.ConfigSection = u'images'
|
||||
self.OnNewPrompt = u'Select Image(s)'
|
||||
self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
|
||||
# this next is a class, not an instance of a class - it will
|
||||
# be instanced by the base MediaManagerItem
|
||||
self.ListViewWithDnD_class = ImageListView
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
|
||||
def setupUi(self):
|
||||
# Add a toolbar
|
||||
self.addToolbar()
|
||||
# Create buttons for the toolbar
|
||||
## New Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'ImageMediaItem', u'Load Image'),
|
||||
translate(u'ImageMediaItem', u'Load images into openlp.org'),
|
||||
u':/images/image_load.png', self.onImagesNewClick, u'ImageNewItem')
|
||||
## Delete Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'ImageMediaItem', u'Delete Image'),
|
||||
translate(u'ImageMediaItem', u'Delete the selected image'),
|
||||
u':/images/image_delete.png', self.onImageDeleteClick, u'ImageDeleteItem')
|
||||
## Separator Line ##
|
||||
self.addToolbarSeparator()
|
||||
## Preview Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'ImageMediaItem', u'Preview Song'),
|
||||
translate(u'ImageMediaItem', u'Preview the selected image'),
|
||||
u':/system/system_preview.png', self.onImagePreviewClick, u'ImagePreviewItem')
|
||||
## Live Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'ImageMediaItem', u'Go Live'),
|
||||
translate(u'ImageMediaItem', u'Send the selected image live'),
|
||||
u':/system/system_live.png', self.onImageLiveClick, u'ImageLiveItem')
|
||||
## Add Song Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'ImageMediaItem', u'Add Image To Service'),
|
||||
translate(u'ImageMediaItem', u'Add the selected image(s) to the service'),
|
||||
u':/system/system_add.png', self.onImageAddClick, u'ImageAddItem')
|
||||
#Add the Image List widget
|
||||
self.ImageListView = ImageList()
|
||||
self.ImageListView.uniformItemSizes = True
|
||||
self.ImageListData = ListWithPreviews()
|
||||
self.ImageListView.setModel(self.ImageListData)
|
||||
self.ImageListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
||||
self.ImageListView.setSpacing(1)
|
||||
self.ImageListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.ImageListView.setAlternatingRowColors(True)
|
||||
self.ImageListView.setDragEnabled(True)
|
||||
self.ImageListView.setObjectName(u'ImageListView')
|
||||
self.PageLayout.addWidget(self.ImageListView)
|
||||
#define and add the context menu
|
||||
self.ImageListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.ImageListView.addAction(self.contextMenuAction(
|
||||
self.ImageListView, ':/system/system_preview.png',
|
||||
translate(u'ImageMediaItem', u'&Preview Image'),
|
||||
self.onImagePreviewClick))
|
||||
self.ImageListView.addAction(self.contextMenuAction(
|
||||
self.ImageListView, ':/system/system_live.png',
|
||||
translate(u'ImageMediaItem', u'&Show Live'),
|
||||
self.onImageLiveClick))
|
||||
self.ImageListView.addAction(self.contextMenuAction(
|
||||
self.ImageListView, ':/system/system_add.png',
|
||||
translate(u'ImageMediaItem', u'&Add to Service'),
|
||||
self.onImageAddClick))
|
||||
QtCore.QObject.connect(self.ImageListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onImagePreviewClick)
|
||||
|
||||
def initialise(self):
|
||||
self.loadImageList(self.parent.config.load_list(u'images'))
|
||||
|
||||
def onImagesNewClick(self):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||
translate(u'ImageMediaItem', u'Select Image(s)'),
|
||||
self.parent.config.get_last_dir(),
|
||||
u'Images (*.jpg *jpeg *.gif *.png *.bmp)')
|
||||
log.info(u'New image(s)', unicode(files))
|
||||
if len(files) > 0:
|
||||
self.loadImageList(files)
|
||||
dir, filename = os.path.split(unicode(files[0]))
|
||||
self.parent.config.set_last_dir(dir)
|
||||
self.parent.config.set_list(u'images', self.ImageListData.getFileList())
|
||||
|
||||
def loadImageList(self, list):
|
||||
for image in list:
|
||||
self.ImageListData.addRow(image)
|
||||
|
||||
def onImageDeleteClick(self):
|
||||
indexes = self.ImageListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
current_row = int(index.row())
|
||||
self.ImageListData.removeRow(current_row)
|
||||
self.parent.config.set_list(u'images', self.ImageListData.getFileList())
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
indexes = self.ImageListView.selectedIndexes()
|
||||
indexes = self.ListView.selectedIndexes()
|
||||
service_item.title = u'Image(s)'
|
||||
for index in indexes:
|
||||
filename = self.ImageListData.getFilename(index)
|
||||
filename = self.ListData.getFilename(index)
|
||||
frame = QtGui.QImage(unicode(filename))
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_image(path, name, frame)
|
||||
|
||||
def onImagePreviewClick(self):
|
||||
log.debug(u'Image Preview Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
def onImageLiveClick(self):
|
||||
log.debug(u'Image Live Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
|
||||
def onImageAddClick(self):
|
||||
log.debug(u'Image Add Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
|
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
# xxx this needs a try, except once we've decided what to do if it fails
|
||||
# xxx this needs a try..except once we've decided what to do if it fails
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
# from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
||||
@ -69,3 +69,73 @@ if __name__==u'__main__':
|
||||
media.play()
|
||||
app.exec_()
|
||||
|
||||
=======
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
||||
|
||||
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
|
||||
"""
|
||||
import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
# xxx this needs a try, except once we've decided what to do if it fails
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
# from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
||||
# from openlp.plugins.media.lib import MediaTab,MediaMediaItem
|
||||
|
||||
"""Renders a video to some surface or other """
|
||||
|
||||
class w(QtGui.QMainWindow):
|
||||
def __init__(self, parent=None):
|
||||
super(QtGui.QMainWindow, self).__init__(parent)
|
||||
self.resize(640,480)
|
||||
self.setWindowTitle(u'simple media player')
|
||||
self.show()
|
||||
|
||||
if __name__==u'__main__':
|
||||
app = QtGui.QApplication([])
|
||||
# widget = QtGui.QWidget()
|
||||
# widget.resize(320, 240)
|
||||
# widget.setWindowTitle(u'simple')
|
||||
# widget.show()
|
||||
# QCore.QCoreApplication.setApplicationName(u'OpenLP')
|
||||
mainwindow=w()
|
||||
widget=QtGui.QWidget(mainwindow)
|
||||
mainwindow.setCentralWidget(widget)
|
||||
widget.setLayout(QtGui.QVBoxLayout(widget))
|
||||
# videofile=u'r-128.rm'
|
||||
videofile=u'/extra_space/Download/coa360download56Kbps240x160.mpg'
|
||||
source=Phonon.MediaSource(videofile)
|
||||
|
||||
media=Phonon.MediaObject(widget)
|
||||
media.setCurrentSource(source)
|
||||
|
||||
video=Phonon.VideoWidget(widget)
|
||||
audio=Phonon.AudioOutput(Phonon.MusicCategory)
|
||||
# controller=Phonon.MediaController(media)
|
||||
Phonon.createPath(media, video);
|
||||
Phonon.createPath(media, audio);
|
||||
# player=Phonon.VideoPlayer(Phonon.VideoCategory, widget)
|
||||
slider=Phonon.SeekSlider(media, mainwindow)
|
||||
widget.layout().addWidget(slider)
|
||||
widget.layout().addWidget(video)
|
||||
slider.show()
|
||||
|
||||
video.show()
|
||||
media.play()
|
||||
app.exec_()
|
||||
|
Loading…
Reference in New Issue
Block a user