forked from openlp/openlp
Martins mediaItem Changes
SlideController rewrite Plugable SlideControllerBars Bug fixes Better Rendering size bzr-revno: 482
This commit is contained in:
commit
1872f57840
2
cnvdb.py
2
cnvdb.py
@ -30,6 +30,8 @@ class Convert():
|
|||||||
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
|
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
|
||||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
||||||
for line in infile:
|
for line in infile:
|
||||||
|
#replace the quotes with quotes
|
||||||
|
line, replace("''", "'")
|
||||||
writefile.write(line)
|
writefile.write(line)
|
||||||
infile.close()
|
infile.close()
|
||||||
writefile.close()
|
writefile.close()
|
||||||
|
@ -35,14 +35,18 @@ class ListWithPreviews(QtCore.QAbstractListModel):
|
|||||||
self.items = []
|
self.items = []
|
||||||
self.rowheight = 50
|
self.rowheight = 50
|
||||||
self.maximagewidth = self.rowheight * 16 / 9.0;
|
self.maximagewidth = self.rowheight * 16 / 9.0;
|
||||||
if new_preview_function is not None:
|
self.preview_function = new_preview_function
|
||||||
self.make_preview=new_preview_function
|
|
||||||
else:
|
|
||||||
self.make_preview=self.preview_function
|
|
||||||
|
|
||||||
def preview_function(self, filename):
|
def make_preview(self, filename):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
|
if self.preview_function is not None:
|
||||||
|
preview=self.preview_function(filename)
|
||||||
|
else:
|
||||||
preview = QtGui.QImage(filename)
|
preview = QtGui.QImage(filename)
|
||||||
|
else:
|
||||||
|
preview = None
|
||||||
|
|
||||||
|
if preview is not None:
|
||||||
w = self.maximagewidth;
|
w = self.maximagewidth;
|
||||||
h = self.rowheight
|
h = self.rowheight
|
||||||
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
||||||
|
@ -23,14 +23,38 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib.toolbar import *
|
from openlp.core.lib.toolbar import *
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import translate, contextMenuAction, contextMenuSeparator
|
||||||
from listwithpreviews import ListWithPreviews
|
|
||||||
from serviceitem import ServiceItem
|
from serviceitem import ServiceItem
|
||||||
|
|
||||||
class MediaManagerItem(QtGui.QWidget):
|
class MediaManagerItem(QtGui.QWidget):
|
||||||
"""
|
"""
|
||||||
MediaManagerItem is a helper widget for plugins.
|
MediaManagerItem is a helper widget for plugins.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
The plugin will be assigned an icon called u':/media/media_' + 'self.ShortPluginName + u'image.png'
|
||||||
|
which needs to be available in the main resources 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
|
||||||
|
|
||||||
|
self.PreviewFunction - a function which returns a QImage to represent the item (a preview usually)
|
||||||
|
- no scaling required - that's done later
|
||||||
|
If this fn is not defined, a default will be used (treat the filename as an image)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'MediaManagerItem')
|
log = logging.getLogger(u'MediaManagerItem')
|
||||||
log.info(u'Media Item loaded')
|
log.info(u'Media Item loaded')
|
||||||
@ -84,61 +108,6 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
self.Toolbar.addSeparator()
|
self.Toolbar.addSeparator()
|
||||||
|
|
||||||
def contextMenuSeparator(self, base):
|
|
||||||
action = QtGui.QAction(u'', base)
|
|
||||||
action.setSeparator(True)
|
|
||||||
return action
|
|
||||||
|
|
||||||
def contextMenuAction(self, base, icon, text, slot):
|
|
||||||
"""
|
|
||||||
Utility method to help build context menus for plugins
|
|
||||||
"""
|
|
||||||
if type(icon) is QtGui.QIcon:
|
|
||||||
ButtonIcon = icon
|
|
||||||
elif type(icon) is types.StringType or type(icon) is types.UnicodeType:
|
|
||||||
ButtonIcon = QtGui.QIcon()
|
|
||||||
if icon.startswith(u':/'):
|
|
||||||
ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
|
||||||
QtGui.QIcon.Off)
|
|
||||||
else:
|
|
||||||
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
||||||
|
|
||||||
action = QtGui.QAction(text, base)
|
|
||||||
action .setIcon(ButtonIcon)
|
|
||||||
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.IconPath=u'images/images' - allows specific icons to be used
|
|
||||||
# self.hasFileIcon - Is the file Icon required
|
|
||||||
# self.hasEditIcon - Is the edit Icon required
|
|
||||||
# self.hasNewIcon - Is the new Icon required
|
|
||||||
#
|
|
||||||
# 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):
|
def setupUi(self):
|
||||||
# Add a toolbar
|
# Add a toolbar
|
||||||
self.addToolbar()
|
self.addToolbar()
|
||||||
@ -168,7 +137,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
u':'+self.IconPath+ u'_delete.png', self.onDeleteClick, self.PluginTextShort+u'DeleteItem')
|
u':'+self.IconPath+ u'_delete.png', self.onDeleteClick, self.PluginTextShort+u'DeleteItem')
|
||||||
## Separator Line ##
|
## Separator Line ##
|
||||||
self.addToolbarSeparator()
|
self.addToolbarSeparator()
|
||||||
## Preview Button ##
|
## Preview ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate(self.TranslationContext, u'Preview '+self.PluginTextShort),
|
translate(self.TranslationContext, u'Preview '+self.PluginTextShort),
|
||||||
translate(self.TranslationContext, u'Preview the selected item'),
|
translate(self.TranslationContext, u'Preview the selected item'),
|
||||||
@ -178,7 +147,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
translate(self.TranslationContext, u'Go Live'),
|
translate(self.TranslationContext, u'Go Live'),
|
||||||
translate(self.TranslationContext, u'Send the selected item live'),
|
translate(self.TranslationContext, u'Send the selected item live'),
|
||||||
u':/system/system_live.png', self.onLiveClick, u'LiveItem')
|
u':/system/system_live.png', self.onLiveClick, u'LiveItem')
|
||||||
## Add Button ##
|
## Add to service Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate(self.TranslationContext, u'Add '+self.PluginTextShort+u' To Service'),
|
translate(self.TranslationContext, u'Add '+self.PluginTextShort+u' To Service'),
|
||||||
translate(self.TranslationContext, u'Add the selected item(s) to the service'),
|
translate(self.TranslationContext, u'Add the selected item(s) to the service'),
|
||||||
@ -199,26 +168,29 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
#define and add the context menu
|
#define and add the context menu
|
||||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
if self.hasEditIcon:
|
if self.hasEditIcon:
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':' +self.IconPath+u'_new.png',
|
':' +self.IconPath+u'_new.png',
|
||||||
translate(self.TranslationContext, u'&Edit '+self.PluginTextShort),
|
translate(self.TranslationContext, u'&Edit '+self.PluginTextShort),
|
||||||
self.onEditClick))
|
self.onEditClick))
|
||||||
self.ListView.addAction(self.contextMenuSeparator(self.SongListWidget))
|
self.ListView.addAction(self.contextMenuSeparator(self.SongListWidget))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_preview.png',
|
self.ListView, ':/system/system_preview.png',
|
||||||
translate(self.TranslationContext, u'&Preview '+self.PluginTextShort),
|
translate(self.TranslationContext, u'&Preview '+self.PluginTextShort),
|
||||||
self.onPreviewClick))
|
self.onPreviewClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_live.png',
|
self.ListView, ':/system/system_live.png',
|
||||||
translate(self.TranslationContext, u'&Show Live'),
|
translate(self.TranslationContext, u'&Show Live'),
|
||||||
self.onLiveClick))
|
self.onLiveClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_add.png',
|
self.ListView, ':/system/system_add.png',
|
||||||
translate(self.TranslationContext, u'&Add to Service'),
|
translate(self.TranslationContext, u'&Add to Service'),
|
||||||
self.onAddClick))
|
self.onAddClick))
|
||||||
QtCore.QObject.connect(self.ListView,
|
QtCore.QObject.connect(self.ListView,
|
||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
||||||
|
|
||||||
|
def initialise(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def addHeaderBar(self):
|
def addHeaderBar(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -232,12 +204,15 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.loadList(files)
|
self.loadList(files)
|
||||||
dir, filename = os.path.split(unicode(files[0]))
|
dir, filename = os.path.split(unicode(files[0]))
|
||||||
self.parent.config.set_last_dir(dir)
|
self.parent.config.set_last_dir(dir)
|
||||||
#self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
|
self.parent.config.set_list(self.ConfigSection, self.getFileList())
|
||||||
|
|
||||||
def getFileList(self):
|
def getFileList(self):
|
||||||
count = 0
|
count = 0
|
||||||
while count < len(self.ListView):
|
filelist = []
|
||||||
filelist = [set.ListView.item(count).text()]
|
while count < self.ListView.count():
|
||||||
|
bitem = self.ListView.item(count)
|
||||||
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||||
|
filelist.append(filename)
|
||||||
count += 1
|
count += 1
|
||||||
return filelist
|
return filelist
|
||||||
|
|
||||||
@ -257,7 +232,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin')
|
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin')
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
log.debug(self.PluginTextShort+u'Preview Requested')
|
log.debug(self.PluginTextShort+u' Preview Requested')
|
||||||
service_item = ServiceItem(self.parent)
|
service_item = ServiceItem(self.parent)
|
||||||
service_item.addIcon(u':/media/media_'+self.PluginTextShort.lower()+u'.png')
|
service_item.addIcon(u':/media/media_'+self.PluginTextShort.lower()+u'.png')
|
||||||
self.generateSlideData(service_item)
|
self.generateSlideData(service_item)
|
||||||
|
@ -155,6 +155,10 @@ class RenderManager:
|
|||||||
|
|
||||||
def calculate_default(self, screen):
|
def calculate_default(self, screen):
|
||||||
log.debug(u'calculate default %s' , screen)
|
log.debug(u'calculate default %s' , screen)
|
||||||
|
if self.current_display == 0:
|
||||||
|
self.width = 1024
|
||||||
|
self.height = 768
|
||||||
|
else:
|
||||||
self.width = screen.width()
|
self.width = screen.width()
|
||||||
self.height = screen.height()
|
self.height = screen.height()
|
||||||
log.debug(u'calculate default %d,%d' , self.width, self.height)
|
log.debug(u'calculate default %d,%d' , self.width, self.height)
|
||||||
|
@ -17,7 +17,7 @@ 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
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
from slidecontroller import BaseToolbar
|
from slidecontroller import MasterToolbar
|
||||||
from slidecontrollermanager import SlideControllerManager
|
from slidecontrollermanager import SlideControllerManager
|
||||||
from maindisplay import MainDisplay
|
from maindisplay import MainDisplay
|
||||||
from amendthemeform import AmendThemeForm
|
from amendthemeform import AmendThemeForm
|
||||||
@ -33,5 +33,5 @@ from servicemanager import ServiceManager
|
|||||||
from thememanager import ThemeManager
|
from thememanager import ThemeManager
|
||||||
from mainwindow import MainWindow
|
from mainwindow import MainWindow
|
||||||
|
|
||||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'BaseToolbar'
|
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MasterToolbar'
|
||||||
'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'AmendThemeForm']
|
'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'AmendThemeForm']
|
||||||
|
@ -78,7 +78,7 @@ class MainDisplay(QtGui.QWidget):
|
|||||||
def blankDisplay(self):
|
def blankDisplay(self):
|
||||||
if not self.displayBlank:
|
if not self.displayBlank:
|
||||||
self.displayBlank = True
|
self.displayBlank = True
|
||||||
self.display.setPixmap(self.blankFrame)
|
self.display.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame))
|
||||||
else:
|
else:
|
||||||
self.displayBlank = False
|
self.displayBlank = False
|
||||||
self.frameView(self.frame)
|
self.frameView(self.frame)
|
||||||
|
@ -205,7 +205,7 @@ class MainWindow(object):
|
|||||||
self.MediaManagerDock.setWindowIcon(icon)
|
self.MediaManagerDock.setWindowIcon(icon)
|
||||||
self.MediaManagerDock.setFloating(False)
|
self.MediaManagerDock.setFloating(False)
|
||||||
self.MediaManagerDock.setObjectName(u'MediaManagerDock')
|
self.MediaManagerDock.setObjectName(u'MediaManagerDock')
|
||||||
self.MediaManagerDock.setMinimumWidth(250)
|
self.MediaManagerDock.setMinimumWidth(300)
|
||||||
self.MediaManagerContents = QtGui.QWidget()
|
self.MediaManagerContents = QtGui.QWidget()
|
||||||
self.MediaManagerContents.setObjectName(u'MediaManagerContents')
|
self.MediaManagerContents.setObjectName(u'MediaManagerContents')
|
||||||
self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents)
|
self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents)
|
||||||
@ -227,7 +227,7 @@ class MainWindow(object):
|
|||||||
self.ServiceManagerDock.setFeatures(
|
self.ServiceManagerDock.setFeatures(
|
||||||
QtGui.QDockWidget.AllDockWidgetFeatures)
|
QtGui.QDockWidget.AllDockWidgetFeatures)
|
||||||
self.ServiceManagerDock.setObjectName(u'ServiceManagerDock')
|
self.ServiceManagerDock.setObjectName(u'ServiceManagerDock')
|
||||||
self.ServiceManagerDock.setMinimumWidth(250)
|
self.ServiceManagerDock.setMinimumWidth(300)
|
||||||
self.ServiceManagerContents = ServiceManager(self)
|
self.ServiceManagerContents = ServiceManager(self)
|
||||||
self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
|
self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
|
||||||
self.mainWindow.addDockWidget(
|
self.mainWindow.addDockWidget(
|
||||||
|
@ -21,100 +21,28 @@ import logging
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import OpenLPToolbar, translate
|
from openlp.core.lib import OpenLPToolbar, translate, buildIcon
|
||||||
|
|
||||||
class SlideData(QtCore.QAbstractListModel):
|
class SlideList(QtGui.QTableWidget):
|
||||||
"""
|
|
||||||
List of frames to be displayed on the list and the main display.
|
|
||||||
"""
|
|
||||||
global log
|
|
||||||
log = logging.getLogger(u'SlideData')
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
QtCore.QAbstractListModel.__init__(self)
|
|
||||||
self.items = []
|
|
||||||
self.rowheight = 50
|
|
||||||
self.maximagewidth = self.rowheight * 16 / 9.0;
|
|
||||||
log.info(u'Starting')
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
self.items = []
|
|
||||||
|
|
||||||
def columnCount(self, parent):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def rowCount(self, parent=None):
|
|
||||||
return len(self.items)
|
|
||||||
|
|
||||||
def insertRow(self, row, frame, framenumber):
|
|
||||||
self.beginInsertRows(QtCore.QModelIndex(), row, row)
|
|
||||||
log.info(u'insert row %d' % row)
|
|
||||||
# create a preview image
|
|
||||||
frame1 = frame.scaled(QtCore.QSize(280, 210), QtCore.Qt.KeepAspectRatio,
|
|
||||||
QtCore.Qt.SmoothTransformation)
|
|
||||||
self.items.insert(row, (frame1, framenumber))
|
|
||||||
log.info(u'Item loaded')
|
|
||||||
self.endInsertRows()
|
|
||||||
|
|
||||||
def removeRow(self, row):
|
|
||||||
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
|
|
||||||
self.items.pop(row)
|
|
||||||
self.endRemoveRows()
|
|
||||||
|
|
||||||
def addRow(self, frame, framenumber):
|
|
||||||
self.insertRow(len(self.items), frame, framenumber)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
|
||||||
row = index.row()
|
|
||||||
if row > len(self.items):
|
|
||||||
# if the last row is selected and deleted, we then get called with
|
|
||||||
# an empty row!
|
|
||||||
return QtCore.QVariant()
|
|
||||||
if role == QtCore.Qt.DecorationRole:
|
|
||||||
retval = self.items[row][0]
|
|
||||||
else:
|
|
||||||
retval = QtCore.QVariant()
|
|
||||||
if type(retval) is not type(QtCore.QVariant):
|
|
||||||
return QtCore.QVariant(retval)
|
|
||||||
else:
|
|
||||||
return retval
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
for item in self.items:
|
|
||||||
yield item
|
|
||||||
|
|
||||||
def getValue(self, index):
|
|
||||||
row = index.row()
|
|
||||||
return self.items[row]
|
|
||||||
|
|
||||||
def getItem(self, row):
|
|
||||||
log.info(u'Get Item:%d -> %s' %(row, unicode(self.items)))
|
|
||||||
return self.items[row]
|
|
||||||
|
|
||||||
def getList(self):
|
|
||||||
filelist = [item[3] for item in self.items];
|
|
||||||
return filelist
|
|
||||||
|
|
||||||
class SlideList(QtGui.QListView):
|
|
||||||
|
|
||||||
def __init__(self,parent=None,name=None):
|
def __init__(self,parent=None,name=None):
|
||||||
QtGui.QListView.__init__(self,parent.Controller)
|
QtGui.QTableWidget.__init__(self,parent.Controller)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if type(event) == QtGui.QKeyEvent:
|
if type(event) == QtGui.QKeyEvent:
|
||||||
#here accept the event and do something
|
#here accept the event and do something
|
||||||
if event.key() == QtCore.Qt.Key_Up:
|
if event.key() == QtCore.Qt.Key_Up:
|
||||||
self.parent.onSlideSelectedPrevious()
|
self.parent.BaseToolbar.onSlideSelectedPrevious()
|
||||||
event.accept()
|
event.accept()
|
||||||
elif event.key() == QtCore.Qt.Key_Down:
|
elif event.key() == QtCore.Qt.Key_Down:
|
||||||
self.parent.onSlideSelectedNext()
|
self.parent.BaseToolbar.onSlideSelectedNext()
|
||||||
event.accept()
|
event.accept()
|
||||||
elif event.key() == QtCore.Qt.Key_PageUp:
|
elif event.key() == QtCore.Qt.Key_PageUp:
|
||||||
self.parent.onSlideSelectedFirst()
|
self.parent.BaseToolbar.onSlideSelectedFirst()
|
||||||
event.accept()
|
event.accept()
|
||||||
elif event.key() == QtCore.Qt.Key_PageDown:
|
elif event.key() == QtCore.Qt.Key_PageDown:
|
||||||
self.parent.onSlideSelectedLast()
|
self.parent.BaseToolbar.onSlideSelectedLast()
|
||||||
event.accept()
|
event.accept()
|
||||||
event.ignore()
|
event.ignore()
|
||||||
else:
|
else:
|
||||||
@ -132,6 +60,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Set up the Slide Controller.
|
Set up the Slide Controller.
|
||||||
"""
|
"""
|
||||||
|
self.toolbarList = {}
|
||||||
QtGui.QWidget.__init__(self, parent.mainWindow)
|
QtGui.QWidget.__init__(self, parent.mainWindow)
|
||||||
self.isLive = isLive
|
self.isLive = isLive
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
@ -145,7 +74,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.PanelLayout.setMargin(0)
|
self.PanelLayout.setMargin(0)
|
||||||
# Actual controller section
|
# Actual controller section
|
||||||
self.Controller = QtGui.QWidget(self.Splitter)
|
self.Controller = QtGui.QWidget(self.Splitter)
|
||||||
self.Controller.setGeometry(QtCore.QRect(0, 0, 800, 536))
|
self.Controller.setGeometry(QtCore.QRect(0, 0, 100, 536))
|
||||||
self.Controller.setSizePolicy(
|
self.Controller.setSizePolicy(
|
||||||
QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
|
QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
|
||||||
QtGui.QSizePolicy.Maximum))
|
QtGui.QSizePolicy.Maximum))
|
||||||
@ -153,21 +82,17 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.ControllerLayout.setSpacing(0)
|
self.ControllerLayout.setSpacing(0)
|
||||||
self.ControllerLayout.setMargin(0)
|
self.ControllerLayout.setMargin(0)
|
||||||
# Controller list view
|
# Controller list view
|
||||||
self.PreviewListView = SlideList(self)
|
self.PreviewListWidget = SlideList(self)
|
||||||
self.PreviewListView.setUniformItemSizes(True)
|
self.PreviewListWidget.setColumnCount(1)
|
||||||
self.PreviewListView.setIconSize(QtCore.QSize(250, 190))
|
self.PreviewListWidget.horizontalHeader().setVisible(False)
|
||||||
self.PreviewListData = SlideData()
|
self.PreviewListWidget.verticalHeader().setVisible(False)
|
||||||
self.PreviewListView.isLive = self.isLive
|
self.PreviewListWidget.setColumnWidth(1, self.Controller.width())
|
||||||
if QtCore.QT_VERSION_STR > u'4.4.0':
|
self.PreviewListWidget.isLive = self.isLive
|
||||||
self.PreviewListView.setFlow(1)
|
self.PreviewListWidget.setObjectName(u'PreviewListWidget')
|
||||||
self.PreviewListView.setViewMode(1)
|
self.ControllerLayout.addWidget(self.PreviewListWidget)
|
||||||
self.PreviewListView.setWrapping(False)
|
|
||||||
self.PreviewListView.setModel(self.PreviewListData)
|
|
||||||
self.PreviewListView.setSpacing(0)
|
|
||||||
self.PreviewListView.setObjectName(u'PreviewListView')
|
|
||||||
self.ControllerLayout.addWidget(self.PreviewListView)
|
|
||||||
# Plugin the Base Toolbar class
|
# Plugin the Base Toolbar class
|
||||||
self.BaseToolbar = BaseToolbar(self.isLive)
|
self.BaseToolbar = MasterToolbar(self.isLive)
|
||||||
|
self.registerToolbar(u'master', self.BaseToolbar)
|
||||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||||
self.ControllerLayout.addWidget(self.Toolbar)
|
self.ControllerLayout.addWidget(self.Toolbar)
|
||||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||||
@ -179,7 +104,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||||
# Screen preview area
|
# Screen preview area
|
||||||
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
||||||
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 250, 190))
|
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 280, 190))
|
||||||
self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy(
|
self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy(
|
||||||
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum))
|
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum))
|
||||||
self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
|
self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
|
||||||
@ -197,44 +122,83 @@ class SlideController(QtGui.QWidget):
|
|||||||
sizePolicy.setHeightForWidth(
|
sizePolicy.setHeightForWidth(
|
||||||
self.SlidePreview.sizePolicy().hasHeightForWidth())
|
self.SlidePreview.sizePolicy().hasHeightForWidth())
|
||||||
self.SlidePreview.setSizePolicy(sizePolicy)
|
self.SlidePreview.setSizePolicy(sizePolicy)
|
||||||
self.SlidePreview.setMinimumSize(QtCore.QSize(280, 210))
|
self.SlidePreview.setFixedSize(QtCore.QSize(250, 210))
|
||||||
self.SlidePreview.setFrameShape(QtGui.QFrame.Box)
|
self.SlidePreview.setFrameShape(QtGui.QFrame.Box)
|
||||||
self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain)
|
self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain)
|
||||||
self.SlidePreview.setLineWidth(1)
|
self.SlidePreview.setLineWidth(1)
|
||||||
self.SlidePreview.setScaledContents(True)
|
self.SlidePreview.setScaledContents(True)
|
||||||
self.SlidePreview.setObjectName(u'SlidePreview')
|
self.SlidePreview.setObjectName(u'SlidePreview')
|
||||||
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
|
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
|
||||||
QtCore.QObject.connect(self.PreviewListView,
|
# Signals
|
||||||
|
QtCore.QObject.connect(self.PreviewListWidget,
|
||||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||||
QtCore.QObject.connect(self.PreviewListView,
|
QtCore.QObject.connect(self.PreviewListWidget,
|
||||||
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||||
# Add Late Arrivals
|
# Add Late Arrivals
|
||||||
self.BaseToolbar.PreviewListView = self.PreviewListView
|
self.BaseToolbar.PreviewListWidget = self.PreviewListWidget
|
||||||
self.BaseToolbar.PreviewListData = self.PreviewListData
|
|
||||||
self.BaseToolbar.SlidePreview = self.SlidePreview
|
self.BaseToolbar.SlidePreview = self.SlidePreview
|
||||||
self.BaseToolbar.mainDisplay = self.parent.mainDisplay
|
self.BaseToolbar.mainDisplay = self.parent.mainDisplay
|
||||||
|
|
||||||
|
def registerToolbar(self, handle,controller):
|
||||||
|
#store the handle name in lower case so no probems later
|
||||||
|
self.toolbarList[handle.lower()] = controller
|
||||||
|
|
||||||
|
def retrieveToolbar(self, handle):
|
||||||
|
"""
|
||||||
|
Find the toolbar and return master if none present
|
||||||
|
Add extra information back into toolbar class
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
toolbar = self.toolbarList[handle.lower()]
|
||||||
|
except:
|
||||||
|
toolbar = self.toolbarList[u'master']
|
||||||
|
toolbar.PreviewListWidget = self.PreviewListWidget
|
||||||
|
toolbar.SlidePreview = self.SlidePreview
|
||||||
|
toolbar.mainDisplay = self.parent.mainDisplay
|
||||||
|
return toolbar
|
||||||
|
|
||||||
def addServiceItem(self, item):
|
def addServiceItem(self, item):
|
||||||
|
"""
|
||||||
|
helper method to pass item to correct toolbar
|
||||||
|
"""
|
||||||
|
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||||
|
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||||
|
#remove the old toolbar
|
||||||
|
self.Toolbar.clear()
|
||||||
|
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||||
|
self.ControllerLayout.addWidget(self.Toolbar)
|
||||||
self.BaseToolbar.addServiceItem(item)
|
self.BaseToolbar.addServiceItem(item)
|
||||||
|
|
||||||
def addServiceManagerItem(self, item, slideno):
|
def addServiceManagerItem(self, item, slideno):
|
||||||
|
"""
|
||||||
|
helper method to pass item to correct toolbar
|
||||||
|
"""
|
||||||
|
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||||
|
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||||
|
#remove the old toolbar
|
||||||
|
self.Toolbar.clear()
|
||||||
|
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||||
|
self.ControllerLayout.addWidget(self.Toolbar)
|
||||||
self.BaseToolbar.addServiceManagerItem(item, slideno)
|
self.BaseToolbar.addServiceManagerItem(item, slideno)
|
||||||
|
|
||||||
class BaseToolbar(object):
|
class MasterToolbar(QtCore.QObject):
|
||||||
|
"""
|
||||||
|
Class from which all tollbars should extend
|
||||||
|
"""
|
||||||
def __init__(self, isLive):
|
def __init__(self, isLive):
|
||||||
self.Toolbar = None
|
self.Toolbar = None
|
||||||
self.PreviewListView = QtGui.QListWidget()
|
QtCore.QObject.__init__(self)
|
||||||
self.PreviewListData = None
|
self.PreviewListWidget = QtGui.QListWidget()
|
||||||
self.isLive = isLive
|
self.isLive = isLive
|
||||||
self.defineToolbar()
|
|
||||||
|
|
||||||
def getToolbar(self):
|
def getToolbar(self):
|
||||||
|
#define toolbar here as it needs to be redefined each time
|
||||||
|
#as the clear destroys it.
|
||||||
|
self.defineToolbar()
|
||||||
return self.Toolbar
|
return self.Toolbar
|
||||||
|
|
||||||
def defineToolbar(self):
|
def defineToolbar(self):
|
||||||
# Controller toolbar
|
# Controller toolbar
|
||||||
#self.Toolbar = OpenLPToolbar(self.Controller)
|
|
||||||
self.Toolbar = OpenLPToolbar(self)
|
self.Toolbar = OpenLPToolbar(self)
|
||||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||||
QtGui.QSizePolicy.Fixed)
|
QtGui.QSizePolicy.Fixed)
|
||||||
@ -249,11 +213,11 @@ class BaseToolbar(object):
|
|||||||
u':/slides/slide_first.png',
|
u':/slides/slide_first.png',
|
||||||
translate(u'SlideController', u'Move to first'),
|
translate(u'SlideController', u'Move to first'),
|
||||||
self.onSlideSelectedFirst)
|
self.onSlideSelectedFirst)
|
||||||
self.Toolbar.addToolbarButton(u'Last Slide',
|
self.Toolbar.addToolbarButton(u'Previous Slide',
|
||||||
u':/slides/slide_previous.png',
|
u':/slides/slide_previous.png',
|
||||||
translate(u'SlideController', u'Move to previous'),
|
translate(u'SlideController', u'Move to previous'),
|
||||||
self.onSlideSelectedPrevious)
|
self.onSlideSelectedPrevious)
|
||||||
self.Toolbar.addToolbarButton(u'First Slide',
|
self.Toolbar.addToolbarButton(u'Next Slide',
|
||||||
u':/slides/slide_next.png',
|
u':/slides/slide_next.png',
|
||||||
translate(u'SlideController', u'Move to next'),
|
translate(u'SlideController', u'Move to next'),
|
||||||
self.onSlideSelectedNext)
|
self.onSlideSelectedNext)
|
||||||
@ -272,56 +236,35 @@ class BaseToolbar(object):
|
|||||||
"""
|
"""
|
||||||
Go to the first slide.
|
Go to the first slide.
|
||||||
"""
|
"""
|
||||||
row = self.PreviewListData.createIndex(0, 0)
|
self.PreviewListWidget.selectRow(0)
|
||||||
if row.isValid():
|
self.onSlideSelected()
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def onSlideSelectedNext(self):
|
def onSlideSelectedNext(self):
|
||||||
"""
|
"""
|
||||||
Go to the next slide.
|
Go to the next slide.
|
||||||
"""
|
"""
|
||||||
indexes = self.PreviewListView.selectedIndexes()
|
row = self.PreviewListWidget.currentRow() + 1
|
||||||
rowNumber = 0
|
if row == self.PreviewListWidget.rowCount():
|
||||||
for index in indexes:
|
row = 0
|
||||||
if index.row() == self.PreviewListData.rowCount() - 1:
|
self.PreviewListWidget.selectRow(row)
|
||||||
rowNumber = 0
|
self.onSlideSelected()
|
||||||
else:
|
|
||||||
rowNumber = index.row() + 1
|
|
||||||
row = self.PreviewListData.createIndex(rowNumber, 0)
|
|
||||||
if row.isValid():
|
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def onSlideSelectedPrevious(self):
|
def onSlideSelectedPrevious(self):
|
||||||
"""
|
"""
|
||||||
Go to the previous slide.
|
Go to the previous slide.
|
||||||
"""
|
"""
|
||||||
indexes = self.PreviewListView.selectedIndexes()
|
row = self.PreviewListWidget.currentRow() - 1
|
||||||
rowNumber = 0
|
if row == -1:
|
||||||
for index in indexes:
|
row = self.PreviewListWidget.rowCount() - 1
|
||||||
if index.row() == 0:
|
self.PreviewListWidget.selectRow(row)
|
||||||
rowNumber = self.PreviewListData.rowCount() - 1
|
self.onSlideSelected()
|
||||||
else:
|
|
||||||
rowNumber = index.row() - 1
|
|
||||||
row = self.PreviewListData.createIndex(rowNumber, 0)
|
|
||||||
if row.isValid():
|
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def onSlideSelectedLast(self):
|
def onSlideSelectedLast(self):
|
||||||
"""
|
"""
|
||||||
Go to the last slide.
|
Go to the last slide.
|
||||||
"""
|
"""
|
||||||
row = self.PreviewListData.createIndex(
|
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
|
||||||
self.PreviewListData.rowCount() - 1, 0)
|
self.onSlideSelected()
|
||||||
if row.isValid():
|
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def onBlankScreen(self):
|
def onBlankScreen(self):
|
||||||
"""
|
"""
|
||||||
@ -329,54 +272,56 @@ class BaseToolbar(object):
|
|||||||
"""
|
"""
|
||||||
self.mainDisplay.blankDisplay()
|
self.mainDisplay.blankDisplay()
|
||||||
|
|
||||||
def onSlideSelected(self, index):
|
def onSlideSelected(self):
|
||||||
"""
|
"""
|
||||||
Generate the preview when you click on a slide.
|
Generate the preview when you click on a slide.
|
||||||
|
if this is the Live Controller also display on the screen
|
||||||
"""
|
"""
|
||||||
frame = self.PreviewListData.getValue(index)
|
row = self.PreviewListWidget.currentRow()
|
||||||
self.previewFrame(frame)
|
if row > -1 and row < self.PreviewListWidget.rowCount():
|
||||||
|
label = self.PreviewListWidget.cellWidget(row, 0)
|
||||||
def previewFrame(self, frame):
|
smallframe = label.pixmap()
|
||||||
"""
|
frame = self.serviceitem.frames[row][u'image']
|
||||||
Generates a preview of the current slide.
|
self.SlidePreview.setPixmap(smallframe)
|
||||||
"""
|
|
||||||
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[0]))
|
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
no = frame[1]
|
self.mainDisplay.frameView(frame)
|
||||||
LiveFrame = self.serviceitem.frames[no][u'image']
|
|
||||||
self.mainDisplay.frameView(LiveFrame)
|
|
||||||
|
|
||||||
def addServiceItem(self, serviceitem):
|
def addServiceItem(self, serviceitem, slideno = 1):
|
||||||
"""
|
"""
|
||||||
Loads a ServiceItem.
|
Loads a ServiceItem into the system from plugins
|
||||||
|
Display the first slide
|
||||||
"""
|
"""
|
||||||
log.debug(u'add Service Item')
|
log.debug(u'add Service Item')
|
||||||
self.serviceitem = serviceitem
|
serviceitem.render()
|
||||||
self.serviceitem.render()
|
self.addServiceManagerItem(serviceitem, 0)
|
||||||
self.PreviewListData.clear()
|
|
||||||
framenumber = 0
|
|
||||||
for frame in self.serviceitem.frames:
|
|
||||||
self.PreviewListData.addRow(frame[u'image'], framenumber)
|
|
||||||
framenumber += 1
|
|
||||||
row = self.PreviewListData.createIndex(0, 0)
|
|
||||||
if row.isValid():
|
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def addServiceManagerItem(self, serviceitem, slideno):
|
def addServiceManagerItem(self, serviceitem, slideno):
|
||||||
"""
|
"""
|
||||||
Loads a ServiceManagerItem.
|
Loads a ServiceItem into the system from ServiceManager
|
||||||
|
Display the Slide Passed
|
||||||
"""
|
"""
|
||||||
log.debug(u'add Service Manager Item')
|
log.debug(u'add Service Manager Item')
|
||||||
self.PreviewListData.clear()
|
self.PreviewListWidget.clear()
|
||||||
|
self.PreviewListWidget.setRowCount(0)
|
||||||
self.serviceitem = serviceitem
|
self.serviceitem = serviceitem
|
||||||
framenumber = 0
|
framenumber = 0
|
||||||
for frame in self.serviceitem.frames:
|
for frame in self.serviceitem.frames:
|
||||||
self.PreviewListData.addRow(frame[u'image'], framenumber)
|
self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1)
|
||||||
|
pixmap = QtGui.QPixmap.fromImage(frame[u'image'])
|
||||||
|
item = QtGui.QTableWidgetItem()
|
||||||
|
label = QtGui.QLabel()
|
||||||
|
label.setMargin(15)
|
||||||
|
label.setScaledContents(True)
|
||||||
|
width = 300
|
||||||
|
height = width * pixmap.height() / pixmap.width()
|
||||||
|
label.setPixmap(pixmap)
|
||||||
|
self.PreviewListWidget.setCellWidget(framenumber, 0,label)
|
||||||
|
self.PreviewListWidget.setItem( framenumber, 0, item)
|
||||||
|
self.PreviewListWidget.setRowHeight(framenumber, height)
|
||||||
|
self.PreviewListWidget.setColumnWidth(0, width)
|
||||||
framenumber += 1
|
framenumber += 1
|
||||||
row = self.PreviewListData.createIndex(slideno, 0)
|
if slideno > self.PreviewListWidget.rowCount():
|
||||||
if row.isValid():
|
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
else:
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
self.PreviewListWidget.selectRow(slideno)
|
||||||
self.onSlideSelected(row)
|
self.onSlideSelected()
|
||||||
|
@ -177,7 +177,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
items = self.ThemeListView.selectedIndexes()
|
items = self.ThemeListView.selectedIndexes()
|
||||||
if len(items) > 0:
|
if len(items) > 0:
|
||||||
for item in items:
|
for item in items:
|
||||||
print item
|
|
||||||
data = self.themeData.getValue(item)
|
data = self.themeData.getValue(item)
|
||||||
self.amendThemeForm.loadTheme(data[3])
|
self.amendThemeForm.loadTheme(data[3])
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
@ -222,7 +221,10 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
for root, dirs, files in os.walk(self.path):
|
for root, dirs, files in os.walk(self.path):
|
||||||
for name in files:
|
for name in files:
|
||||||
if name.endswith(u'.png'):
|
if name.endswith(u'.png'):
|
||||||
self.themeData.addRow(os.path.join(self.path, name))
|
#check to see file is in route directory
|
||||||
|
theme = os.path.join(self.path, name)
|
||||||
|
if os.path.exists(theme):
|
||||||
|
self.themeData.addRow(theme)
|
||||||
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
|
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
|
||||||
self.parent.ServiceManagerContents.updateThemeList(self.getThemes())
|
self.parent.ServiceManagerContents.updateThemeList(self.getThemes())
|
||||||
self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes())
|
self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes())
|
||||||
|
@ -37,7 +37,7 @@ class BiblePlugin(Plugin):
|
|||||||
self.weight = -9
|
self.weight = -9
|
||||||
# Create the plugin icon
|
# Create the plugin icon
|
||||||
self.icon = QtGui.QIcon()
|
self.icon = QtGui.QIcon()
|
||||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_verse.png'),
|
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_bible.png'),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
#Register the bible Manager
|
#Register the bible Manager
|
||||||
self.biblemanager = BibleManager(self.config)
|
self.biblemanager = BibleManager(self.config)
|
||||||
|
@ -245,7 +245,7 @@ class BibleManager():
|
|||||||
log.debug(u'get_verse_text : new book')
|
log.debug(u'get_verse_text : new book')
|
||||||
for chapter in range(schapter, echapter+1):
|
for chapter in range(schapter, echapter+1):
|
||||||
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter)
|
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter)
|
||||||
if search_results.has_verse_list() :
|
if search_results.has_verselist() :
|
||||||
## We have found a book of the bible lets check to see if it was there.
|
## We have found a book of the bible lets check to see if it was there.
|
||||||
## By reusing the returned book name we get a correct book.
|
## By reusing the returned book name we get a correct book.
|
||||||
## For example it is possible to request ac and get Acts back.
|
## For example it is possible to request ac and get Acts back.
|
||||||
|
@ -21,7 +21,7 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import ServiceItem, MediaManagerItem, Receiver, translate
|
from openlp.core.lib import ServiceItem, MediaManagerItem, Receiver, translate, contextMenuAction, contextMenuSeparator
|
||||||
from openlp.plugins.bibles.forms import BibleImportForm
|
from openlp.plugins.bibles.forms import BibleImportForm
|
||||||
|
|
||||||
class BibleList(QtGui.QListWidget):
|
class BibleList(QtGui.QListWidget):
|
||||||
@ -215,13 +215,13 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
||||||
# Context Menus
|
# Context Menus
|
||||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, u':/system/system_preview.png',
|
self.ListView, u':/system/system_preview.png',
|
||||||
translate(u'BibleMediaItem',u'&Preview Verse'), self.onPreviewClick))
|
translate(u'BibleMediaItem',u'&Preview Verse'), self.onPreviewClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, u':/system/system_live.png',
|
self.ListView, u':/system/system_live.png',
|
||||||
translate(u'BibleMediaItem',u'&Show Live'), self.onLiveClick))
|
translate(u'BibleMediaItem',u'&Show Live'), self.onLiveClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, u':/system/system_add.png',
|
self.ListView, u':/system/system_add.png',
|
||||||
translate(u'BibleMediaItem',u'&Add to Service'), self.onAddClick))
|
translate(u'BibleMediaItem',u'&Add to Service'), self.onAddClick))
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate
|
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator
|
||||||
|
|
||||||
class CustomList(QtGui.QListWidget):
|
class CustomList(QtGui.QListWidget):
|
||||||
|
|
||||||
@ -114,17 +114,17 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
|
||||||
#define and add the context menu
|
#define and add the context menu
|
||||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
|
':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
|
||||||
self.onCustomEditClick))
|
self.onCustomEditClick))
|
||||||
self.ListView.addAction(self.contextMenuSeparator(self.ListView))
|
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_preview.png',
|
self.ListView, ':/system/system_preview.png',
|
||||||
translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
|
translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_live.png',
|
self.ListView, ':/system/system_live.png',
|
||||||
translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
|
translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(
|
self.ListView.addAction(contextMenuAction(
|
||||||
self.ListView, ':/system/system_add.png',
|
self.ListView, ':/system/system_add.png',
|
||||||
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
|
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, Event, EventType
|
from openlp.core.lib import Plugin, Event, EventType
|
||||||
from openlp.plugins.images.lib import ImageMediaItem
|
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
|
||||||
|
|
||||||
class ImagePlugin(Plugin):
|
class ImagePlugin(Plugin):
|
||||||
global log
|
global log
|
||||||
@ -40,6 +40,10 @@ class ImagePlugin(Plugin):
|
|||||||
# passed with drag and drop messages
|
# passed with drag and drop messages
|
||||||
self.dnd_id = u'Image'
|
self.dnd_id = u'Image'
|
||||||
|
|
||||||
|
def get_settings_tab(self):
|
||||||
|
self.ImageTab = ImageTab()
|
||||||
|
return self.ImageTab
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the MediaManagerItem object
|
||||||
self.media_item = ImageMediaItem(self, self.icon, u'Images')
|
self.media_item = ImageMediaItem(self, self.icon, u'Images')
|
||||||
|
@ -19,3 +19,4 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
from mediaitem import ImageMediaItem
|
from mediaitem import ImageMediaItem
|
||||||
from imageslidecontroller import ImageToolbar
|
from imageslidecontroller import ImageToolbar
|
||||||
|
from imagetab import ImageTab
|
||||||
|
@ -22,23 +22,20 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import OpenLPToolbar, translate
|
from openlp.core.lib import OpenLPToolbar, translate
|
||||||
from openlp.core.ui.slidecontroller import BaseToolbar
|
from openlp.core.ui.slidecontroller import MasterToolbar
|
||||||
|
|
||||||
class ImageToolbar(BaseToolbar):
|
class ImageToolbar(MasterToolbar):
|
||||||
|
|
||||||
def __init__(self, isLive):
|
def __init__(self, parent, isLive):
|
||||||
|
MasterToolbar.__init__(self, isLive)
|
||||||
|
self.parent = parent
|
||||||
self.Toolbar = None
|
self.Toolbar = None
|
||||||
self.PreviewListView = QtGui.QListWidget()
|
|
||||||
self.PreviewListData = None
|
|
||||||
self.isLive = isLive
|
self.isLive = isLive
|
||||||
self.defineToolbar()
|
self.defineToolbar()
|
||||||
|
|
||||||
def getToolbar(self):
|
|
||||||
return self.Toolbar
|
|
||||||
|
|
||||||
def defineToolbar(self):
|
def defineToolbar(self):
|
||||||
# Controller toolbar
|
# Controller toolbar
|
||||||
#self.Toolbar = OpenLPToolbar(self.Controller)
|
self.Toolbar = OpenLPToolbar(self)
|
||||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||||
QtGui.QSizePolicy.Fixed)
|
QtGui.QSizePolicy.Fixed)
|
||||||
sizeToolbarPolicy.setHorizontalStretch(0)
|
sizeToolbarPolicy.setHorizontalStretch(0)
|
||||||
@ -50,11 +47,11 @@ class ImageToolbar(BaseToolbar):
|
|||||||
u':/slides/slide_first.png',
|
u':/slides/slide_first.png',
|
||||||
translate(u'SlideController', u'Move to first'),
|
translate(u'SlideController', u'Move to first'),
|
||||||
self.onSlideSelectedFirst)
|
self.onSlideSelectedFirst)
|
||||||
self.Toolbar.addToolbarButton(u'Last Slide',
|
self.Toolbar.addToolbarButton(u'Previous Slide',
|
||||||
u':/slides/slide_previous.png',
|
u':/slides/slide_previous.png',
|
||||||
translate(u'SlideController', u'Move to previous'),
|
translate(u'SlideController', u'Move to previous'),
|
||||||
self.onSlideSelectedPrevious)
|
self.onSlideSelectedPrevious)
|
||||||
self.Toolbar.addToolbarButton(u'First Slide',
|
self.Toolbar.addToolbarButton(u'Next Slide',
|
||||||
u':/slides/slide_next.png',
|
u':/slides/slide_next.png',
|
||||||
translate(u'SlideController', u'Move to next'),
|
translate(u'SlideController', u'Move to next'),
|
||||||
self.onSlideSelectedNext)
|
self.onSlideSelectedNext)
|
||||||
@ -70,34 +67,29 @@ class ImageToolbar(BaseToolbar):
|
|||||||
self.onBlankScreen)
|
self.onBlankScreen)
|
||||||
self.Toolbar.addSeparator()
|
self.Toolbar.addSeparator()
|
||||||
self.Toolbar.addToolbarButton(u'Start Loop',
|
self.Toolbar.addToolbarButton(u'Start Loop',
|
||||||
u':/slides/slide_last.png',
|
u':/media/media_time.png',
|
||||||
translate(u'SlideController', u'Start continuous loop'),
|
translate(u'SlideController', u'Start continuous loop'),
|
||||||
self.onStartLoop)
|
self.onStartLoop)
|
||||||
self.Toolbar.addToolbarButton(u'Stop Loop',
|
self.Toolbar.addToolbarButton(u'Stop Loop',
|
||||||
u':/slides/slide_last.png',
|
u':/media/media_stop.png',
|
||||||
translate(u'SlideController', u'Start continuous loop'),
|
translate(u'SlideController', u'Stop continuous loop'),
|
||||||
self.onStopLoop)
|
self.onStopLoop)
|
||||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||||
self.ControllerLayout.addWidget(self.Toolbar)
|
|
||||||
|
|
||||||
def onStartLoop(self):
|
def onStartLoop(self):
|
||||||
"""
|
"""
|
||||||
Go to the last slide.
|
Go to the last slide.
|
||||||
"""
|
"""
|
||||||
row = self.PreviewListData.createIndex(
|
delay = self.parent.parent.ImageTab.loop_delay
|
||||||
self.PreviewListData.rowCount() - 1, 0)
|
self.timer_id = self.startTimer(delay * 1000)
|
||||||
if row.isValid():
|
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
|
||||||
def onStopLoop(self):
|
def onStopLoop(self):
|
||||||
"""
|
"""
|
||||||
Go to the last slide.
|
Go to the last slide.
|
||||||
"""
|
"""
|
||||||
row = self.PreviewListData.createIndex(
|
self.killTimer(self.timer_id)
|
||||||
self.PreviewListData.rowCount() - 1, 0)
|
|
||||||
if row.isValid():
|
def timerEvent(self, event):
|
||||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
if event.timerId() == self.timer_id:
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
self.onSlideSelectedNext()
|
||||||
self.onSlideSelected(row)
|
|
||||||
|
69
openlp/plugins/images/lib/imagetab.py
Normal file
69
openlp/plugins/images/lib/imagetab.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# -*- 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-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
|
||||||
|
"""
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.lib import SettingsTab, str_to_bool, translate
|
||||||
|
|
||||||
|
class ImageTab(SettingsTab):
|
||||||
|
"""
|
||||||
|
ImageTab is the Image settings tab in the settings dialog.
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
SettingsTab.__init__(self, translate(u'ImageTab', u'Image'), u'Image')
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.setObjectName(u'ImageTab')
|
||||||
|
self.ImageLayout = QtGui.QFormLayout(self)
|
||||||
|
self.ImageLayout.setObjectName(u'ImageLayout')
|
||||||
|
self.ImageModeGroupBox = QtGui.QGroupBox(self)
|
||||||
|
self.ImageModeGroupBox.setObjectName(u'ImageModeGroupBox')
|
||||||
|
self.TimeoutLayout = QtGui.QHBoxLayout(self.ImageModeGroupBox)
|
||||||
|
self.TimeoutLayout.setSpacing(8)
|
||||||
|
self.TimeoutLayout.setMargin(0)
|
||||||
|
self.TimeoutLayout.setObjectName(u'TimeoutLayout')
|
||||||
|
self.TimeoutLabel = QtGui.QLabel(self.ImageModeGroupBox)
|
||||||
|
self.TimeoutLabel.setObjectName(u'TimeoutLabel')
|
||||||
|
self.TimeoutLayout.addWidget(self.TimeoutLabel)
|
||||||
|
self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageModeGroupBox)
|
||||||
|
self.TimeoutSpinBox.setMaximum(180)
|
||||||
|
self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox')
|
||||||
|
self.TimeoutLayout.addWidget(self.TimeoutSpinBox)
|
||||||
|
self.TimeoutSpacer = QtGui.QSpacerItem(147, 20,
|
||||||
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
|
self.TimeoutLayout.addItem(self.TimeoutSpacer)
|
||||||
|
|
||||||
|
self.ImageLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox)
|
||||||
|
# Signals and slots
|
||||||
|
QtCore.QObject.connect(self.TimeoutSpinBox,
|
||||||
|
QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
|
||||||
|
|
||||||
|
def retranslateUi(self):
|
||||||
|
self.TimeoutLabel.setText(translate(u'ImageTab', u'Slide Loop Delay:'))
|
||||||
|
|
||||||
|
def onTimeoutSpinBoxChanged(self):
|
||||||
|
self.loop_delay = self.TimeoutSpinBox.value()
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
self.loop_delay = int(self.config.get_config(u'loop delay', 5))
|
||||||
|
self.TimeoutSpinBox.setValue(self.loop_delay)
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
self.config.set_config(u'loop delay', self.loop_delay)
|
@ -53,12 +53,12 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = ImageListView
|
self.ListViewWithDnD_class = ImageListView
|
||||||
|
self.ServiceItemIconName = u':/media/media_image.png'
|
||||||
|
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
#create and install our own slide controllers
|
#create and install our own slide controller toolbar
|
||||||
#a=c
|
imageToolbar = ImageToolbar(self, True)
|
||||||
# live_controller = ImageSlideController(self.parent.slideManager.parent, True)
|
parent.live_controller.registerToolbar(self.ConfigSection, imageToolbar)
|
||||||
# preview_controller = ImageSlideController(self.parent.slideManager.parent)
|
|
||||||
# self.parent.slideManager.add_controllers(u'image', preview_controller, live_controller)
|
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
|
@ -19,6 +19,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import tempfile
|
||||||
|
try:
|
||||||
|
import gst
|
||||||
|
except:
|
||||||
|
log = logging.getLogger(u'MediaMediaItemSetup')
|
||||||
|
log.warning(u'Can\'t generate Videos previews - import gst failed');
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -26,6 +32,13 @@ from openlp.core.lib import MediaManagerItem, translate
|
|||||||
|
|
||||||
from openlp.plugins.media.lib import MediaTab
|
from openlp.plugins.media.lib import MediaTab
|
||||||
from openlp.plugins.media.lib import FileListData
|
from openlp.plugins.media.lib import FileListData
|
||||||
|
# from listwithpreviews import ListWithPreviews
|
||||||
|
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon
|
||||||
|
|
||||||
|
class MediaListView(BaseListWithDnD):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
self.PluginName = u'Media'
|
||||||
|
BaseListWithDnD.__init__(self, parent)
|
||||||
|
|
||||||
class MediaMediaItem(MediaManagerItem):
|
class MediaMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
@ -36,100 +49,98 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
log.info(u'Media Media Item loaded')
|
log.info(u'Media Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
|
self.TranslationContext = u'MediaPlugin'
|
||||||
|
self.hasFileIcon = True
|
||||||
|
self.hasNewIcon = False
|
||||||
|
self.hasEditIcon = False
|
||||||
|
self.IconPath = u'images/image'
|
||||||
|
self.PluginTextShort = u'Media'
|
||||||
|
self.ConfigSection = u'images'
|
||||||
|
self.OnNewPrompt = u'Select Media(s)'
|
||||||
|
self.OnNewFileMasks = u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
|
||||||
|
# this next is a class, not an instance of a class - it will
|
||||||
|
# be instanced by the base MediaManagerItem
|
||||||
|
self.ListViewWithDnD_class = MediaListView
|
||||||
|
#self.ServiceItemIconName = u':/media/media_image.png'
|
||||||
|
self.PreviewFunction = self.video_get_preview
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def video_get_preview(self, filename):
|
||||||
# Add a toolbar
|
"""Gets a preview of the first frame of a video file using
|
||||||
self.addToolbar()
|
GSTREAMER (non-portable??? - Can't figure out how to do with
|
||||||
# Create buttons for the toolbar
|
Phonon - returns a QImage"""
|
||||||
## New Media Button ##
|
try:
|
||||||
self.addToolbarButton(
|
# Define your pipeline, just as you would at the command prompt.
|
||||||
translate(u'MediaMediaItem',u'New Media'),
|
# This is much easier than trying to create and link each gstreamer element in Python.
|
||||||
translate(u'MediaMediaItem',u'Load Media into openlp.org'),
|
# This is great for pipelines that end with a filesink (i.e. there is no audible or visual output)
|
||||||
':/videos/video_load.png', self.onMediaNewClick, 'MediaNewItem')
|
log.info ("Video preview %s"%( filename))
|
||||||
## Delete Media Button ##
|
outfile=tempfile.NamedTemporaryFile(suffix='.png')
|
||||||
self.addToolbarButton(
|
cmd=u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name)
|
||||||
translate(u'MediaMediaItem',u'Delete Media'),
|
pipe = gst.parse_launch(cmd)
|
||||||
translate(u'MediaMediaItem',u'Delete the selected Media item'),
|
# Get a reference to the pipeline's bus
|
||||||
':/videos/video_delete.png', self.onMediaDeleteClick, 'MediaDeleteItem')
|
bus = pipe.get_bus()
|
||||||
## Separator Line ##
|
|
||||||
self.addToolbarSeparator()
|
|
||||||
## Preview Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Preview Media'),
|
|
||||||
translate(u'MediaMediaItem',u'Preview the selected Media item'),
|
|
||||||
':/system/system_preview.png', self.onMediaPreviewClick, 'MediaPreviewItem')
|
|
||||||
## Live Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Go Live'),
|
|
||||||
translate(u'MediaMediaItem',u'Send the selected Media item live'),
|
|
||||||
':/system/system_live.png', self.onMediaLiveClick, 'MediaLiveItem')
|
|
||||||
## Add Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Add Media To Service'),
|
|
||||||
translate(u'MediaMediaItem',u'Add the selected Media items(s) to the service'),
|
|
||||||
':/system/system_add.png',self.onMediaAddClick, 'MediaAddItem')
|
|
||||||
## Add the Medialist widget ##
|
|
||||||
|
|
||||||
self.MediaListView = QtGui.QListView()
|
# Set the pipeline's state to PLAYING
|
||||||
self.MediaListView.setAlternatingRowColors(True)
|
pipe.set_state(gst.STATE_PLAYING)
|
||||||
self.MediaListData = FileListData()
|
|
||||||
self.MediaListView.setModel(self.MediaListData)
|
|
||||||
|
|
||||||
self.PageLayout.addWidget(self.MediaListView)
|
# 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
|
||||||
|
|
||||||
#define and add the context menu
|
def generateSlideData(self, service_item):
|
||||||
self.MediaListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
indexes = self.ListView.selectedIndexes()
|
||||||
|
service_item.title = u'Media'
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_preview.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Preview Media'), self.onMediaPreviewClick))
|
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_live.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Show Live'), self.onMediaLiveClick))
|
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_add.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Add to Service'), self.onMediaAddClick))
|
|
||||||
|
|
||||||
def initialise(self):
|
|
||||||
list = self.parent.config.load_list(u'Media')
|
|
||||||
self.loadMediaList(list)
|
|
||||||
|
|
||||||
def onMediaNewClick(self):
|
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
|
||||||
translate(u'MediaMediaItem', u'Select Media(s) items'),
|
|
||||||
self.parent.config.get_last_dir(),
|
|
||||||
u'Videos (*.avi *.mpeg);;Audio (*.mp3 *.ogg *.wma);;All files (*)')
|
|
||||||
if len(files) > 0:
|
|
||||||
self.loadMediaList(files)
|
|
||||||
dir, filename = os.path.split(unicode(files[0]))
|
|
||||||
self.parent.config.set_last_dir(dir)
|
|
||||||
self.parent.config.set_list(u'media', self.MediaListData.getFileList())
|
|
||||||
|
|
||||||
def getFileList(self):
|
|
||||||
filelist = [item[0] for item in self.MediaListView];
|
|
||||||
return filelist
|
|
||||||
|
|
||||||
def loadMediaList(self, list):
|
|
||||||
for files in list:
|
|
||||||
self.MediaListData.addRow(files)
|
|
||||||
|
|
||||||
def onMediaDeleteClick(self):
|
|
||||||
indexes = self.MediaListView.selectedIndexes()
|
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
current_row = int(index.row())
|
filename = self.ListData.getFilename(index)
|
||||||
self.MediaListData.removeRow(current_row)
|
frame = QtGui.QImage(unicode(filename))
|
||||||
self.parent.config.set_list(u'media', self.MediaListData.getFileList())
|
(path, name) = os.path.split(filename)
|
||||||
|
service_item.add_from_image(path, name, frame)
|
||||||
|
|
||||||
def onMediaPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
log.debug(u'Media Preview Button pressed')
|
log.debug(u'Media Preview Button pressed')
|
||||||
items = self.MediaListView.selectedIndexes()
|
items = self.ListView.selectedIndexes()
|
||||||
for item in items:
|
for item in items:
|
||||||
text = self.MediaListData.getValue(item)
|
text = self.ListData.getValue(item)
|
||||||
print text
|
print text
|
||||||
|
|
||||||
def onMediaLiveClick(self):
|
def onMediaLiveClick(self):
|
||||||
|
log.debug(u'Media Live Button pressed')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onMediaAddClick(self):
|
def initialise(self):
|
||||||
pass
|
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
|
self.ListView.setIconSize(QtCore.QSize(88,50))
|
||||||
|
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
||||||
|
|
||||||
|
def onDeleteClick(self):
|
||||||
|
item = self.ListView.currentItem()
|
||||||
|
if item is not None:
|
||||||
|
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())
|
||||||
|
|
||||||
|
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.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
|
self.ListView.addItem(item_name)
|
||||||
|
|
||||||
|
# def onMediaAddClick(self):
|
||||||
|
# log.debug(u'Media Add Button pressed')
|
||||||
|
# pass
|
||||||
|
@ -22,7 +22,6 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
||||||
from openlp.plugins.media.lib import MediaTab,MediaMediaItem
|
from openlp.plugins.media.lib import MediaTab,MediaMediaItem
|
||||||
|
|
||||||
class MediaPlugin(Plugin):
|
class MediaPlugin(Plugin):
|
||||||
|
|
||||||
def __init__(self, plugin_helpers):
|
def __init__(self, plugin_helpers):
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
# -*- 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_()
|
|
||||||
|
|
@ -57,7 +57,7 @@ class Openoffice(object):
|
|||||||
self.createApp()
|
self.createApp()
|
||||||
|
|
||||||
def startOpenoffice(self):
|
def startOpenoffice(self):
|
||||||
cmd = u'openoffice.org -nologo -norestore -minimized -impress' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
|
cmd = u'openoffice.org -nologo -norestore -invisible -minimized -impress' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
|
||||||
retval = subprocess.Popen(cmd, shell=True)
|
retval = subprocess.Popen(cmd, shell=True)
|
||||||
self.oopid = retval.pid
|
self.oopid = retval.pid
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser
|
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser , contextMenuAction, contextMenuSeparator
|
||||||
|
|
||||||
from openlp.plugins.songs.forms import EditSongForm
|
from openlp.plugins.songs.forms import EditSongForm
|
||||||
|
|
||||||
@ -138,17 +138,17 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
|
||||||
#define and add the context menu
|
#define and add the context menu
|
||||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),
|
':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),
|
||||||
self.onSongEditClick))
|
self.onSongEditClick))
|
||||||
self.ListView.addAction(self.contextMenuSeparator(self.ListView))
|
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
|
':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
|
||||||
self.onSongPreviewClick))
|
self.onSongPreviewClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
|
':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
|
||||||
self.onSongLiveClick))
|
self.onSongLiveClick))
|
||||||
self.ListView.addAction(self.contextMenuAction(self.ListView,
|
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||||
':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
|
':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
|
||||||
self.onSongAddClick))
|
self.onSongAddClick))
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 590 B |
BIN
resources/images/media_stop.png
Normal file
BIN
resources/images/media_stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 722 B |
BIN
resources/images/media_time.png
Normal file
BIN
resources/images/media_time.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 975 B |
@ -86,8 +86,10 @@
|
|||||||
<file>media_presentation.png</file>
|
<file>media_presentation.png</file>
|
||||||
<file>media_image.png</file>
|
<file>media_image.png</file>
|
||||||
<file>media_song.png</file>
|
<file>media_song.png</file>
|
||||||
<file>media_verse.png</file>
|
<file>media_bible.png</file>
|
||||||
<file>media_video.png</file>
|
<file>media_video.png</file>
|
||||||
|
<file>media_time.png</file>
|
||||||
|
<file>media_stop.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="messagebox" >
|
<qresource prefix="messagebox" >
|
||||||
<file>messagebox_critical.png</file>
|
<file>messagebox_critical.png</file>
|
||||||
|
Loading…
Reference in New Issue
Block a user