Update Presentation Plugin to match rest of the plugins

Fix style errors as discovered

bzr-revno: 425
This commit is contained in:
Tim Bentley 2009-03-19 17:31:33 +00:00
parent ca32157e9c
commit 1a8ab17bbb
8 changed files with 261 additions and 127 deletions

View File

@ -29,10 +29,10 @@ from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QDialog
from bibleimportdialog import Ui_BibleImportDialog
from openlp.core.lib import PluginUtils, Receiver
from openlp.core.lib import Receiver
class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
class BibleImportForm(QDialog, Ui_BibleImportDialog):
global log
log=logging.getLogger("BibleImportForm")
log.info("BibleImportForm loaded")
@ -86,24 +86,24 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
def onVersesFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(1))
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(1))
if filename != "":
self.VerseLocationEdit.setText(filename)
self._save_last_directory(filename, 1)
self.config.set_last_dir(filename, 1)
self.setCsv()
def onBooksFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(2))
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(2))
if filename != "":
self.BooksLocationEdit.setText(filename)
self._save_last_directory(filename, 2)
self.config.set_last_dir(filename, 2)
self.setCsv()
def onOsisFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(3))
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(3))
if filename != "":
self.OSISLocationEdit.setText(filename)
self._save_last_directory(filename, 3)
self.config.set_last_dir(filename, 3)
self.setOsis()
def onOSISLocationEditLostFocus(self):

View File

@ -179,20 +179,6 @@ class BibleMediaItem(MediaManagerItem):
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
# self.BibleListView = QtGui.QTableWidget()
# self.BibleListView.setColumnCount(2)
# self.BibleListView.setColumnHidden(0, True)
# self.BibleListView.setColumnWidth(1, 275)
# self.BibleListView.setShowGrid(False)
# self.BibleListView.setSortingEnabled(False)
# self.BibleListView.setAlternatingRowColors(True)
# self.BibleListView.verticalHeader().setVisible(False)
# self.BibleListView.horizontalHeader().setVisible(False)
# self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391))
# self.BibleListView.setObjectName(u'BibleListView')
# self.BibleListView.setAlternatingRowColors(True)
# self.PageLayout.addWidget(self.BibleListView)
self.BibleListView = QtGui.QListView()
self.BibleListView.setAlternatingRowColors(True)
self.BibleListData = TextListData()

View File

@ -0,0 +1,24 @@
# -*- 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 filelistdata import FileListData
from mediaitem import PresentationMediaItem
__all__ = ['PresentationMediaItem', 'FileListData']

View File

@ -0,0 +1,82 @@
# -*- 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("insert row %d:%s"%(row,filename))
# get short filename to display next to image
(prefix, shortfilename) = os.path.split(str(filename))
log.info("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("Returning"+ str(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

@ -0,0 +1,131 @@
# -*- 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
from openlp.core import translate
from openlp.core.lib import MediaManagerItem
from openlp.core.resources import *
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)
def setupUi(self):
# Add a toolbar
self.addToolbar()
# Create buttons for the toolbar
## New Presentation Button ##
self.addToolbarButton(
translate('PresentationsMediaItem',u'New presentations'),
translate('PresentationsMediaItem',u'Load presentations into openlp.org'),
':/presentations/presentation_load.png', self.onPresentationNewClick, 'PresentationNewItem')
## Delete Presentation Button ##
self.addToolbarButton(
translate('PresentationsMediaItem',u'Delete Presentation'),
translate('PresentationsMediaItem',u'Delete the selected presentation'),
':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem')
## Separator Line ##
self.addToolbarSeparator()
## Preview Presentation Button ##
self.addToolbarButton(
translate('PresentationsMediaItem',u'Preview Presentation'),
translate('PresentationsMediaItem',u'Preview the selected Presentation'),
':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem')
## Live Presentation Button ##
self.addToolbarButton(
translate('PresentationsMediaItem',u'Go Live'),
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'),
translate('PresentationsMediaItem',u'Add the selected Presentations(s) to the service'),
':/system/system_add.png',self.onPresentationAddClick, 'PresentationsAddItem')
## Add the Presentationlist widget ##
self.PresentationsListView = QtGui.QListView()
self.PresentationsListView.setAlternatingRowColors(True)
self.PresentationsListData = FileListData()
self.PresentationsListView.setModel(self.PresentationsListData)
self.PageLayout.addWidget(self.PresentationsListView)
#define and add the context menu
self.PresentationsListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.PresentationsListView.addAction(self.contextMenuAction(
self.PresentationsListView, ':/system/system_preview.png',
translate('PresentationsMediaItem',u'&Preview presentations'), self.onPresentationPreviewClick))
self.PresentationsListView.addAction(self.contextMenuAction(
self.PresentationsListView, ':/system/system_live.png',
translate('PresentationsMediaItem',u'&Show Live'), self.onPresentationLiveClick))
self.PresentationsListView.addAction(self.contextMenuAction(
self.PresentationsListView, ':/system/system_add.png',
translate('PresentationsMediaItem',u'&Add to Service'), self.onPresentationAddClick))
def initialise(self):
list = self.parent.config.load_list(u'presentations')
self.loadPresentationList(list)
def onPresentationNewClick(self):
files = QtGui.QFileDialog.getOpenFileNames(None,
translate('PresentationsMediaItem', u'Select presentations(s)'),
self.parent.config.get_last_dir(), u'Presentations (*.ppt *.pps *.odi)')
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())
def getFileList(self):
filelist = [item[0] for item in self.PresentationsListView];
return filelist
def loadPresentationList(self, list):
for files in list:
self.PresentationsListData.addRow(files)
def onPresentationDeleteClick(self):
indexes = self.PresentationsListView.selectedIndexes()
for index in indexes:
current_row = int(index.row())
self.PresentationsListData.removeRow(current_row)
self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
def onPresentationPreviewClick(self):
pass
def onPresentationLiveClick(self):
pass
def onPresentationAddClick(self):
pass

View File

@ -23,99 +23,24 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem
from openlp.core.lib import Plugin, MediaManagerItem
from openlp.plugins.presentations.lib import PresentationMediaItem
class PresentationPlugin(Plugin, PluginUtils):
class PresentationPlugin(Plugin):
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Presentations', '1.9.0')
Plugin.__init__(self, u'Presentations', u'1.9.0')
self.weight = -8
# Create the plugin icon
self.icon = QtGui.QIcon()
self.icon.addPixmap(QtGui.QPixmap(':/media/media_presentation.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
def get_settings_tab(self):
pass
def get_media_manager_item(self):
# Create the MediaManagerItem object
self.MediaManagerItem = MediaManagerItem(self, self.icon, 'Presentations')
# Add a toolbar
self.MediaManagerItem.addToolbar()
# Create buttons for the toolbar
## Load Presentation Button ##
self.MediaManagerItem.addToolbarButton('Load', 'Load presentations into openlp.org',
':/presentations/presentation_load.png', self.onPresentationLoadClick, 'PresentationLoadItem')
## Delete Presentation Button ##
self.MediaManagerItem.addToolbarButton('Delete Presentation', 'Delete the selected presentation',
':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem')
## Separator Line ##
self.MediaManagerItem.addToolbarSeparator()
## Preview Presentation Button ##
self.MediaManagerItem.addToolbarButton('Preview Presentation', 'Preview the selected presentation',
':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem')
## Live Presentation Button ##
self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected presentation live',
':/system/system_live.png', self.onPresentationLiveClick, 'PresentationLiveItem')
## Add Presentation Button ##
self.MediaManagerItem.addToolbarButton('Add Presentation To Service',
'Add the selected presentation(s) to the service', ':/system/system_add.png',
self.onPresentationAddClick, 'PresentationAddItem')
## Add the Presentation widget ##
self.PresentationListView = QtGui.QTableWidget()
self.PresentationListView.setColumnCount(2)
self.PresentationListView.setColumnHidden(0, True)
self.PresentationListView.setColumnWidth(1, 275)
self.PresentationListView.setShowGrid(False)
self.PresentationListView.setSortingEnabled(False)
self.PresentationListView.setAlternatingRowColors(True)
self.PresentationListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Name"]))
self.PresentationListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
self.PresentationListView.setObjectName("PresentationListView")
self.PresentationListView.setAlternatingRowColors(True)
self.MediaManagerItem.PageLayout.addWidget(self.PresentationListView)
#define and add the context menu
self.PresentationListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_preview.png', "&Preview Presentation", self.onPresentationPreviewClick))
self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_live.png', "&Show Live", self.onPresentationLiveClick))
self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_add.png', "&Add to Service", self.onPresentationAddClick))
return self.MediaManagerItem
def initialise(self):
list = self._load_display_list()
self._load_presentation_list(list)
def onPresentationLoadClick(self):
files = QtGui.QFileDialog.getOpenFileNames(None, "Select Presentation(s)", self._get_last_dir(), "Images (*.ppt *.pps *.odi)")
if len(files) > 0:
self._load_presentation_list(files)
self._save_last_directory(files[0])
self._save_display_list(self.PresentationListView)
def _load_presentation_list(self, list):
for f in list:
fl , nm = os.path.split(str(f))
c = self.PresentationListView.rowCount()
self.PresentationListView.setRowCount(c+1)
twi = QtGui.QTableWidgetItem(str(f))
self.PresentationListView.setItem(c , 0, twi)
twi = QtGui.QTableWidgetItem(str(nm))
self.PresentationListView.setItem(c , 1, twi)
self.PresentationListView.setRowHeight(c, 20)
def onPresentationDeleteClick(self):
cr = self.PresentationListView.currentRow()
self.PresentationListView.removeRow(int(cr))
self._save_display_list(self.PresentationListView)
def onPresentationPreviewClick(self):
pass
def onPresentationLiveClick(self):
pass
def onPresentationAddClick(self):
pass
self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
return self.media_item

View File

@ -44,29 +44,29 @@ class VideoMediaItem(MediaManagerItem):
# Add a toolbar
self.addToolbar()
# Create buttons for the toolbar
## New Song Button ##
## New Video Button ##
self.addToolbarButton(
translate('VideoMediaItem',u'New Video'),
translate('VideoMediaItem',u'Load videos into openlp.org'),
':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem')
## Delete Song Button ##
## Delete Video Button ##
self.addToolbarButton(
translate('VideoMediaItem',u'Delete Video'),
translate('VideoMediaItem',u'Delete the selected video'),
':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem')
## Separator Line ##
self.addToolbarSeparator()
## Preview Song Button ##
## Preview Video Button ##
self.addToolbarButton(
translate('VideoMediaItem',u'Preview Video'),
translate('VideoMediaItem',u'Preview the selected video'),
':/system/system_preview.png', self.onVideoPreviewClick, 'VideoPreviewItem')
## Live Song Button ##
## Live Video Button ##
self.addToolbarButton(
translate('VideoMediaItem',u'Go Live'),
translate('VideoMediaItem',u'Send the selected video live'),
':/system/system_live.png', self.onVideoLiveClick, 'VideoLiveItem')
## Add Song Button ##
## Add Video Button ##
self.addToolbarButton(
translate('VideoMediaItem',u'Add Video To Service'),
translate('VideoMediaItem',u'Add the selected video(s) to the service'),
@ -80,20 +80,6 @@ class VideoMediaItem(MediaManagerItem):
self.PageLayout.addWidget(self.VideoListView)
# self.VideoListView = QtGui.QTableWidget()
# self.VideoListView.setColumnCount(2)
# self.VideoListView.setColumnHidden(0, True)
# self.VideoListView.setColumnWidth(1, 275)
# self.VideoListView.setShowGrid(False)
# self.VideoListView.setSortingEnabled(False)
# self.VideoListView.setAlternatingRowColors(True)
# self.VideoListView.verticalHeader().setVisible(False)
# self.VideoListView.horizontalHeader().setVisible(False)
# self.VideoListView.setAlternatingRowColors(True)
# self.VideoListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
# self.VideoListView.setObjectName("VideoListView")
# self.PageLayout.addWidget(self.VideoListView)
#define and add the context menu
self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

View File

@ -28,7 +28,7 @@ class VideoPlugin(Plugin):
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Videos', '1.9.0')
Plugin.__init__(self, u'Videos', u'1.9.0')
self.weight = -6
# Create the plugin icon
self.icon = QtGui.QIcon()
@ -41,6 +41,6 @@ class VideoPlugin(Plugin):
def get_media_manager_item(self):
# Create the MediaManagerItem object
self.media_item = VideoMediaItem(self, self.icon, 'Videos')
self.media_item = VideoMediaItem(self, self.icon, u'Videos')
return self.media_item