2009-03-19 17:31:33 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2009 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
|
|
|
|
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2009-03-19 17:31:33 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2009-09-25 00:43:42 +00:00
|
|
|
|
|
|
|
from openlp.core.lib import MediaManagerItem, translate, BaseListWithDnD
|
2009-09-05 13:30:09 +00:00
|
|
|
from openlp.plugins.presentations.lib import MessageListener
|
2009-06-26 16:39:16 +00:00
|
|
|
|
|
|
|
# We have to explicitly create separate classes for each plugin
|
|
|
|
# in order for DnD to the Service manager to work correctly.
|
|
|
|
class PresentationListView(BaseListWithDnD):
|
|
|
|
def __init__(self, parent=None):
|
2009-08-11 19:21:52 +00:00
|
|
|
self.PluginName = u'Presentations'
|
2009-06-26 16:39:16 +00:00
|
|
|
BaseListWithDnD.__init__(self, parent)
|
2009-03-19 17:31:33 +00:00
|
|
|
|
|
|
|
class PresentationMediaItem(MediaManagerItem):
|
|
|
|
"""
|
2009-08-11 19:21:52 +00:00
|
|
|
This is the Presentation media manager item for Presentation Items.
|
|
|
|
It can present files using Openoffice
|
2009-03-19 17:31:33 +00:00
|
|
|
"""
|
|
|
|
global log
|
2009-09-28 20:45:04 +00:00
|
|
|
log = logging.getLogger(u'PresentationsMediaItem')
|
2009-03-19 17:31:33 +00:00
|
|
|
log.info(u'Presentations Media Item loaded')
|
|
|
|
|
2009-08-11 19:21:52 +00:00
|
|
|
def __init__(self, parent, icon, title, controllers):
|
|
|
|
self.controllers = controllers
|
2009-06-26 16:39:16 +00:00
|
|
|
self.TranslationContext = u'PresentationPlugin'
|
|
|
|
self.PluginTextShort = u'Presentation'
|
2009-08-31 14:04:00 +00:00
|
|
|
self.ConfigSection = u'presentations'
|
2009-06-27 05:46:05 +00:00
|
|
|
self.IconPath = u'presentations/presentation'
|
|
|
|
self.OnNewPrompt = u'Select Presentation(s)'
|
|
|
|
self.OnNewFileMasks = u'Presentations (*.ppt *.pps *.odp)'
|
2009-06-26 16:39:16 +00:00
|
|
|
# this next is a class, not an instance of a class - it will
|
|
|
|
# be instanced by the base MediaManagerItem
|
|
|
|
self.ListViewWithDnD_class = PresentationListView
|
2009-03-19 17:31:33 +00:00
|
|
|
MediaManagerItem.__init__(self, parent, icon, title)
|
2009-09-05 13:30:09 +00:00
|
|
|
self.message_listener = MessageListener(controllers)
|
2009-03-19 17:31:33 +00:00
|
|
|
|
2009-09-26 09:11:39 +00:00
|
|
|
def requiredIcons(self):
|
|
|
|
MediaManagerItem.requiredIcons(self)
|
|
|
|
self.hasFileIcon = True
|
|
|
|
self.hasNewIcon = False
|
|
|
|
self.hasEditIcon = False
|
|
|
|
|
2009-09-11 19:29:57 +00:00
|
|
|
def addEndHeaderBar(self):
|
2009-06-27 05:46:05 +00:00
|
|
|
self.PresentationWidget = QtGui.QWidget(self)
|
2009-09-21 17:56:36 +00:00
|
|
|
sizePolicy = QtGui.QSizePolicy(
|
|
|
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
2009-06-27 05:46:05 +00:00
|
|
|
sizePolicy.setHorizontalStretch(0)
|
|
|
|
sizePolicy.setVerticalStretch(0)
|
2009-09-21 17:56:36 +00:00
|
|
|
sizePolicy.setHeightForWidth(
|
|
|
|
self.PresentationWidget.sizePolicy().hasHeightForWidth())
|
2009-06-27 05:46:05 +00:00
|
|
|
self.PresentationWidget.setSizePolicy(sizePolicy)
|
|
|
|
self.PresentationWidget.setObjectName(u'PresentationWidget')
|
|
|
|
self.DisplayLayout = QtGui.QGridLayout(self.PresentationWidget)
|
|
|
|
self.DisplayLayout.setObjectName(u'DisplayLayout')
|
|
|
|
self.DisplayTypeComboBox = QtGui.QComboBox(self.PresentationWidget)
|
|
|
|
self.DisplayTypeComboBox.setObjectName(u'DisplayTypeComboBox')
|
|
|
|
self.DisplayLayout.addWidget(self.DisplayTypeComboBox, 0, 1, 1, 2)
|
|
|
|
self.DisplayTypeLabel = QtGui.QLabel(self.PresentationWidget)
|
|
|
|
self.DisplayTypeLabel.setObjectName(u'SearchTypeLabel')
|
|
|
|
self.DisplayLayout.addWidget(self.DisplayTypeLabel, 0, 0, 1, 1)
|
2009-09-21 17:56:36 +00:00
|
|
|
self.DisplayTypeLabel.setText(
|
|
|
|
translate(u'PresentationMediaItem', u'Present using:'))
|
2009-06-27 05:46:05 +00:00
|
|
|
# Add the Presentation widget to the page layout
|
|
|
|
self.PageLayout.addWidget(self.PresentationWidget)
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
def initialise(self):
|
|
|
|
list = self.parent.config.load_list(u'presentations')
|
2009-08-11 19:21:52 +00:00
|
|
|
self.loadList(list)
|
|
|
|
for item in self.controllers:
|
|
|
|
#load the drop down selection
|
|
|
|
self.DisplayTypeComboBox.addItem(item)
|
2009-03-19 17:31:33 +00:00
|
|
|
|
2009-06-27 15:33:03 +00:00
|
|
|
def loadList(self, list):
|
|
|
|
for file in list:
|
|
|
|
(path, filename) = os.path.split(unicode(file))
|
|
|
|
item_name = QtGui.QListWidgetItem(filename)
|
|
|
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
|
|
|
self.ListView.addItem(item_name)
|
|
|
|
|
2009-08-11 19:21:52 +00:00
|
|
|
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)
|
2009-09-21 17:56:36 +00:00
|
|
|
self.parent.config.set_list(
|
|
|
|
self.ConfigSection, self.ListData.getFileList())
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-08-11 19:21:52 +00:00
|
|
|
def generateSlideData(self, service_item):
|
|
|
|
items = self.ListView.selectedIndexes()
|
2009-08-31 21:53:35 +00:00
|
|
|
if len(items) > 1:
|
|
|
|
return False
|
2009-08-31 18:27:36 +00:00
|
|
|
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
2009-08-11 19:21:52 +00:00
|
|
|
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
|
|
|
for item in items:
|
2009-09-21 17:56:36 +00:00
|
|
|
bitem = self.ListView.item(item.row())
|
2009-08-11 19:21:52 +00:00
|
|
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
|
|
|
(path, name) = os.path.split(filename)
|
2009-09-21 17:56:36 +00:00
|
|
|
service_item.add_from_command(path, name)
|
2009-08-31 21:53:35 +00:00
|
|
|
return True
|