2009-03-19 17:31:33 +00:00
|
|
|
# -*- 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
|
|
|
|
"""
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2009-05-21 16:07:01 +00:00
|
|
|
from openlp.core.lib import MediaManagerItem, translate
|
2009-03-19 17:31:33 +00:00
|
|
|
from openlp.plugins.presentations.lib import FileListData
|
|
|
|
|
|
|
|
class PresentationMediaItem(MediaManagerItem):
|
|
|
|
"""
|
|
|
|
This is the custom media manager item for Custom Slides.
|
|
|
|
"""
|
|
|
|
global log
|
|
|
|
log=logging.getLogger(u'PresentationsMediaItem')
|
|
|
|
log.info(u'Presentations Media Item loaded')
|
|
|
|
|
|
|
|
def __init__(self, parent, icon, title):
|
|
|
|
MediaManagerItem.__init__(self, parent, icon, title)
|
|
|
|
|
2009-05-18 16:04:34 +00:00
|
|
|
def setupUi(self):
|
2009-03-19 17:31:33 +00:00
|
|
|
# Add a toolbar
|
|
|
|
self.addToolbar()
|
|
|
|
# Create buttons for the toolbar
|
|
|
|
## New Presentation Button ##
|
|
|
|
self.addToolbarButton(
|
2009-05-18 16:04:34 +00:00
|
|
|
translate('PresentationsMediaItem',u'New presentations'),
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'Load presentations into openlp.org'),
|
|
|
|
':/presentations/presentation_load.png', self.onPresentationNewClick, 'PresentationNewItem')
|
|
|
|
## Delete Presentation Button ##
|
|
|
|
self.addToolbarButton(
|
2009-05-18 16:04:34 +00:00
|
|
|
translate('PresentationsMediaItem',u'Delete Presentation'),
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'Delete the selected presentation'),
|
|
|
|
':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem')
|
|
|
|
## Separator Line ##
|
|
|
|
self.addToolbarSeparator()
|
|
|
|
## Preview Presentation Button ##
|
|
|
|
self.addToolbarButton(
|
2009-05-18 16:04:34 +00:00
|
|
|
translate('PresentationsMediaItem',u'Preview Presentation'),
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'Preview the selected Presentation'),
|
|
|
|
':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem')
|
|
|
|
## Live Presentation Button ##
|
|
|
|
self.addToolbarButton(
|
2009-05-18 16:04:34 +00:00
|
|
|
translate('PresentationsMediaItem',u'Go Live'),
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'Send the selected presentation live'),
|
|
|
|
':/system/system_live.png', self.onPresentationLiveClick, 'PresentationLiveItem')
|
|
|
|
## Add Presentation Button ##
|
|
|
|
self.addToolbarButton(
|
|
|
|
translate('PresentationsMediaItem',u'Add Presentation To Service'),
|
2009-05-18 16:04:34 +00:00
|
|
|
translate('PresentationsMediaItem',u'Add the selected Presentations(s) to the service'),
|
2009-03-19 17:31:33 +00:00
|
|
|
':/system/system_add.png',self.onPresentationAddClick, 'PresentationsAddItem')
|
|
|
|
## Add the Presentationlist widget ##
|
2009-05-18 16:04:34 +00:00
|
|
|
|
|
|
|
self.PresentationWidget = QtGui.QWidget(self)
|
|
|
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
|
|
|
sizePolicy.setHorizontalStretch(0)
|
|
|
|
sizePolicy.setVerticalStretch(0)
|
|
|
|
sizePolicy.setHeightForWidth(self.PresentationWidget.sizePolicy().hasHeightForWidth())
|
|
|
|
self.PresentationWidget.setSizePolicy(sizePolicy)
|
|
|
|
self.PresentationWidget.setObjectName('PresentationWidget')
|
|
|
|
self.DisplayLayout = QtGui.QGridLayout(self.PresentationWidget)
|
|
|
|
self.DisplayLayout.setObjectName('DisplayLayout')
|
|
|
|
self.DisplayTypeComboBox = QtGui.QComboBox(self.PresentationWidget)
|
|
|
|
self.DisplayTypeComboBox.setObjectName('DisplayTypeComboBox')
|
|
|
|
self.DisplayLayout.addWidget(self.DisplayTypeComboBox, 0, 1, 1, 2)
|
|
|
|
self.DisplayTypeLabel = QtGui.QLabel(self.PresentationWidget)
|
|
|
|
self.DisplayTypeLabel.setObjectName('SearchTypeLabel')
|
|
|
|
self.DisplayLayout.addWidget(self.DisplayTypeLabel, 0, 0, 1, 1)
|
|
|
|
|
|
|
|
self.DisplayTypeLabel.setText(translate('PresentationMediaItem', u'Present using:'))
|
|
|
|
|
|
|
|
# Add the song widget to the page layout
|
|
|
|
self.PageLayout.addWidget(self.PresentationWidget)
|
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
self.PresentationsListView = QtGui.QListView()
|
|
|
|
self.PresentationsListView.setAlternatingRowColors(True)
|
|
|
|
self.PresentationsListData = FileListData()
|
|
|
|
self.PresentationsListView.setModel(self.PresentationsListData)
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
self.PageLayout.addWidget(self.PresentationsListView)
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
#define and add the context menu
|
|
|
|
self.PresentationsListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
|
|
|
|
|
|
|
self.PresentationsListView.addAction(self.contextMenuAction(
|
2009-05-18 16:04:34 +00:00
|
|
|
self.PresentationsListView, ':/system/system_preview.png',
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'&Preview presentations'), self.onPresentationPreviewClick))
|
|
|
|
self.PresentationsListView.addAction(self.contextMenuAction(
|
2009-05-18 16:04:34 +00:00
|
|
|
self.PresentationsListView, ':/system/system_live.png',
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'&Show Live'), self.onPresentationLiveClick))
|
|
|
|
self.PresentationsListView.addAction(self.contextMenuAction(
|
2009-05-18 16:04:34 +00:00
|
|
|
self.PresentationsListView, ':/system/system_add.png',
|
2009-03-19 17:31:33 +00:00
|
|
|
translate('PresentationsMediaItem',u'&Add to Service'), self.onPresentationAddClick))
|
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')
|
|
|
|
self.loadPresentationList(list)
|
2009-05-18 16:04:34 +00:00
|
|
|
self.DisplayTypeComboBox.addItem(u'Impress')
|
|
|
|
self.DisplayTypeComboBox.addItem(u'Powerpoint')
|
2009-05-18 19:04:25 +00:00
|
|
|
self.DisplayTypeComboBox.addItem(u'Keynote')
|
2009-03-19 17:31:33 +00:00
|
|
|
|
|
|
|
def onPresentationNewClick(self):
|
2009-05-18 16:04:34 +00:00
|
|
|
files = QtGui.QFileDialog.getOpenFileNames(None,
|
|
|
|
translate('PresentationsMediaItem', u'Select presentations(s)'),
|
2009-06-04 16:17:26 +00:00
|
|
|
self.parent.config.get_last_dir(), u'Presentations (*.ppt *.pps *.odp)')
|
2009-03-19 17:31:33 +00:00
|
|
|
if len(files) > 0:
|
|
|
|
self.loadPresentationList(files)
|
|
|
|
dir, filename = os.path.split(str(files[0]))
|
|
|
|
self.parent.config.set_last_dir(dir)
|
|
|
|
self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
def getFileList(self):
|
|
|
|
filelist = [item[0] for item in self.PresentationsListView];
|
2009-05-18 16:04:34 +00:00
|
|
|
return filelist
|
2009-03-19 17:31:33 +00:00
|
|
|
|
|
|
|
def loadPresentationList(self, list):
|
|
|
|
for files in list:
|
|
|
|
self.PresentationsListData.addRow(files)
|
2009-05-18 16:04:34 +00:00
|
|
|
|
2009-03-19 17:31:33 +00:00
|
|
|
def onPresentationDeleteClick(self):
|
|
|
|
indexes = self.PresentationsListView.selectedIndexes()
|
|
|
|
for index in indexes:
|
|
|
|
current_row = int(index.row())
|
|
|
|
self.PresentationsListData.removeRow(current_row)
|
2009-05-18 16:04:34 +00:00
|
|
|
self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
|
2009-03-19 17:31:33 +00:00
|
|
|
|
|
|
|
def onPresentationPreviewClick(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPresentationLiveClick(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPresentationAddClick(self):
|
2009-05-18 16:04:34 +00:00
|
|
|
pass
|