Update Presentation Plugin

This commit is contained in:
Tim Bentley 2009-08-11 20:21:52 +01:00
parent 161973eef6
commit 7a6695b1a6
4 changed files with 63 additions and 112 deletions

View File

@ -17,10 +17,8 @@ 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 filelistdata import FileListData
from mediaitem import PresentationMediaItem from mediaitem import PresentationMediaItem
from presentationtab import PresentationTab from presentationtab import PresentationTab
from impresscom import Openoffice from impressslidecontroller import impressToolbar
__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice'] __all__ = ['PresentationMediaItem', 'PresentationTab', 'impressToolbar']

View File

@ -1,82 +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
import logging
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class FileListData(QAbstractListModel):
"""
An abstract list of strings and the preview icon to go with them
"""
global log
log=logging.getLogger(u'FileListData')
log.info(u'started')
def __init__(self):
QAbstractListModel.__init__(self)
self.items=[] # will be a list of (full filename shortname) tuples
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, filename):
self.beginInsertRows(QModelIndex(),row,row)
log.info(u'insert row %d:%s'%(row,filename))
# get short filename to display next to image
(prefix, shortfilename) = os.path.split(unicode(filename))
log.info(u'shortfilename=%s'%(shortfilename))
# create a preview image
self.items.insert(row, (filename, shortfilename))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QModelIndex(), row,row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, filename):
self.insertRow(len(self.items), filename)
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 QVariant()
if role==Qt.DisplayRole:
retval= self.items[row][1]
# elif role == Qt.DecorationRole:
# retval= self.items[row][1]
elif role == Qt.ToolTipRole:
retval= self.items[row][0]
else:
retval= QVariant()
# log.info(u'Returning"+ unicode(retval))
if type(retval) is not type(QVariant):
return QVariant(retval)
else:
return retval
def getFileList(self):
filelist = [item[0] for item in self.items];
return filelist
def getFilename(self, index):
row = index.row()
return self.items[row][0]

View File

@ -21,25 +21,26 @@ import logging
import os import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.plugins.presentations.lib import FileListData
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
# We have to explicitly create separate classes for each plugin # We have to explicitly create separate classes for each plugin
# in order for DnD to the Service manager to work correctly. # in order for DnD to the Service manager to work correctly.
class PresentationListView(BaseListWithDnD): class PresentationListView(BaseListWithDnD):
def __init__(self, parent=None): def __init__(self, parent=None):
self.PluginName = u'Presentation' self.PluginName = u'Presentations'
BaseListWithDnD.__init__(self, parent) BaseListWithDnD.__init__(self, parent)
class PresentationMediaItem(MediaManagerItem): class PresentationMediaItem(MediaManagerItem):
""" """
This is the custom media manager item for Custom Slides. This is the Presentation media manager item for Presentation Items.
It can present files using Openoffice
""" """
global log global log
log=logging.getLogger(u'PresentationsMediaItem') log=logging.getLogger(u'PresentationsMediaItem')
log.info(u'Presentations Media Item loaded') log.info(u'Presentations Media Item loaded')
def __init__(self, parent, icon, title): def __init__(self, parent, icon, title, controllers):
self.controllers = controllers
self.TranslationContext = u'PresentationPlugin' self.TranslationContext = u'PresentationPlugin'
self.PluginTextShort = u'Presentation' self.PluginTextShort = u'Presentation'
self.ConfigSection = u'presentation' self.ConfigSection = u'presentation'
@ -76,10 +77,13 @@ class PresentationMediaItem(MediaManagerItem):
def initialise(self): def initialise(self):
list = self.parent.config.load_list(u'presentations') list = self.parent.config.load_list(u'presentations')
self.loadPresentationList(list) self.loadList(list)
self.DisplayTypeComboBox.addItem(u'Impress') for item in self.controllers:
# self.DisplayTypeComboBox.addItem(u'Powerpoint') #load the drop down selection
# self.DisplayTypeComboBox.addItem(u'Keynote') self.DisplayTypeComboBox.addItem(item)
#load the preview toolbars
#self.parent.preview_controller.registerToolbar(item, self.controllers[item])
#self.parent.live_controller.registerToolbar(item, self.controllers[item])
def loadList(self, list): def loadList(self, list):
for file in list: for file in list:
@ -88,14 +92,21 @@ class PresentationMediaItem(MediaManagerItem):
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.ListView.addItem(item_name) self.ListView.addItem(item_name)
def loadPresentationList(self, list): def onDeleteClick(self):
pass item = self.ListView.currentItem()
# for files in list: if item is not None:
# self.PresentationsListData.addRow(files) 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 onPresentationDeleteClick(self): def generateSlideData(self, service_item):
indexes = self.PresentationsListView.selectedIndexes() items = self.ListView.selectedIndexes()
for index in indexes: service_item.title = self.DisplayTypeComboBox.currentText()
current_row = int(index.row()) service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
self.PresentationsListData.removeRow(current_row) for item in items:
self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
frame = QtGui.QImage(unicode(filename))
(path, name) = os.path.split(filename)
service_item.add_using_toolbar(path, name)

View File

@ -24,7 +24,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, MediaManagerItem from openlp.core.lib import Plugin, MediaManagerItem
from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, Openoffice from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, impressToolbar
class PresentationPlugin(Plugin): class PresentationPlugin(Plugin):
@ -34,25 +34,49 @@ class PresentationPlugin(Plugin):
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
# Call the parent constructor # Call the parent constructor
log.debug('Initialised') log.debug('Initialised')
self.controllers = {}
Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers) Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
self.weight = -8 self.weight = -8
# Create the plugin icon # Create the plugin icon
self.icon = QtGui.QIcon() self.icon = QtGui.QIcon()
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'), self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.dnd_id = u'Presentations'
def get_settings_tab(self): def get_settings_tab(self):
"""
Create the settings Tab
"""
self.presentation_tab = PresentationTab() self.presentation_tab = PresentationTab()
return self.presentation_tab return self.presentation_tab
def get_media_manager_item(self): def get_media_manager_item(self):
# Create the MediaManagerItem object """
self.media_item = PresentationMediaItem(self, self.icon, u'Presentations') Create the Media Manager List
"""
self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers)
return self.media_item return self.media_item
def check_pre_conditions(self): def registerControllers(self, handle, controller):
log.debug('check_pre_conditions') self.controllers[handle] = controller
return True
# self.openoffice = Openoffice()
# return self.openoffice.checkOoPid()
def check_pre_conditions(self):
"""
Check to see if we have any presentation software available
If Not do not install the plugin.
"""
log.debug('check_pre_conditions')
impress = True
try:
#Check to see if we have uno installed
import uno
#openoffice = impressToolbar()
self.registerControllers(u'Impress', None)
except:
pass
#If we have no controllers disable plugin
if len(self.controllers) > 0:
return True
else:
return False
# return self.openoffice.checkOoPid()