From f90cdd27bef9e7ca86fbc9aeca39fddf9d564808 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 14 Dec 2008 16:19:28 +0000 Subject: [PATCH] Add new plugins - shells Update bibles Add CheckPreConditions to plugin manager. Sort out merge problems bzr-revno: 220 --- openlp/core/lib/plugin.py | 23 +++++ openlp/core/lib/pluginconfig.py | 4 +- openlp/core/pluginmanager.py | 3 +- .../plugins/bibles/forms/bibleimportdialog.py | 18 ++-- .../plugins/bibles/forms/bibleimportform.py | 9 +- openlp/plugins/bibles/lib/biblemanager.py | 19 +++- openlp/plugins/images/__init__.py | 0 openlp/plugins/images/imageplugin.py | 95 +++++++++++++++++++ openlp/plugins/videos/__init__.py | 0 openlp/plugins/videos/videoplugin.py | 95 +++++++++++++++++++ resources/.openlp/openlp.conf | 8 +- resources/.openlp/openlp.conf_posix | 9 +- resources/.openlp/openlp.conf_win | 6 ++ resources/forms/bibleimport.ui | 16 +++- 14 files changed, 287 insertions(+), 18 deletions(-) create mode 100644 openlp/plugins/images/__init__.py create mode 100644 openlp/plugins/images/imageplugin.py create mode 100644 openlp/plugins/videos/__init__.py create mode 100644 openlp/plugins/videos/videoplugin.py diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 2a124253b..e66659c0f 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -158,3 +158,26 @@ class Plugin(object): Called by the plugin Manager to initialise anything it needs. """ pass + + def addToMenu(self, menubar): + """ + Add menu items to the menu, given the menubar. + """ + pass + + def handleEvent(self, event): + """ + Handle the event contained in the event object. + """ + pass + + def getName(self): + return self.Name + + def checkPreConditions(self): + """ + Provides the Plugin with a handle to check if it can be loaded. + Returns True or False. + """ + return True + diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index 95c38a4a2..57a0016b3 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -65,8 +65,8 @@ class PluginConfig(object): if f.find('.') != -1: nme = f.split('.') bname = nme[0] - sfx = nme[1] - sfx.lower() + sfx = nme[1].lower() + sfx = sfx.lower() if suffix.find(sfx) > -1 : # only load files with the correct suffix returnfiles.append(f) return returnfiles diff --git a/openlp/core/pluginmanager.py b/openlp/core/pluginmanager.py index 085c71239..372473485 100644 --- a/openlp/core/pluginmanager.py +++ b/openlp/core/pluginmanager.py @@ -72,7 +72,8 @@ class PluginManager(object): plugin_objects = [] for p in self.plugin_classes: plugin = p() - plugin_objects.append(plugin) + if plugin.checkPreConditions() == True: + plugin_objects.append(plugin) self.plugins = sorted(plugin_objects, self.order_by_weight) def order_by_weight(self, x, y): diff --git a/openlp/plugins/bibles/forms/bibleimportdialog.py b/openlp/plugins/bibles/forms/bibleimportdialog.py index 167fcfc76..9f85c3214 100644 --- a/openlp/plugins/bibles/forms/bibleimportdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportdialog.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'bibleimport.ui' # -# Created: Wed Dec 10 20:59:43 2008 +# Created: Sun Dec 14 08:57:40 2008 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! @@ -71,7 +71,7 @@ class Ui_BibleImportDialog(object): self.VersesFileButton.setObjectName("VersesFileButton") self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1) self.BibleNameEdit = QtGui.QLineEdit(self.FileImportPage) - self.BibleNameEdit.setGeometry(QtCore.QRect(120, 20, 271, 28)) + self.BibleNameEdit.setGeometry(QtCore.QRect(100, 20, 280, 28)) self.BibleNameEdit.setObjectName("BibleNameEdit") self.BibleNameLabel = QtGui.QLabel(self.FileImportPage) self.BibleNameLabel.setGeometry(QtCore.QRect(18, 20, 98, 22)) @@ -99,6 +99,8 @@ class Ui_BibleImportDialog(object): self.LocationComboBox = QtGui.QComboBox(self.OptionsGroupBox) self.LocationComboBox.setObjectName("LocationComboBox") self.LocationComboBox.addItem(QtCore.QString()) + self.LocationComboBox.setItemText(0, "") + self.LocationComboBox.addItem(QtCore.QString()) self.LocationComboBox.addItem(QtCore.QString()) self.OptionsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.LocationComboBox) self.TypeLabel = QtGui.QLabel(self.OptionsGroupBox) @@ -107,6 +109,8 @@ class Ui_BibleImportDialog(object): self.TypeComboBox = QtGui.QComboBox(self.OptionsGroupBox) self.TypeComboBox.setObjectName("TypeComboBox") self.TypeComboBox.addItem(QtCore.QString()) + self.TypeComboBox.setItemText(0, "") + self.TypeComboBox.addItem(QtCore.QString()) self.TypeComboBox.addItem(QtCore.QString()) self.OptionsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.TypeComboBox) self.BibleLabel = QtGui.QLabel(self.OptionsGroupBox) @@ -186,7 +190,7 @@ class Ui_BibleImportDialog(object): self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1) self.retranslateUi(BibleImportDialog) - self.ImportToolBox.setCurrentIndex(1) + self.ImportToolBox.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(BibleImportDialog) BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit) BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton) @@ -216,11 +220,11 @@ class Ui_BibleImportDialog(object): self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.FileImportPage), QtGui.QApplication.translate("BibleImportDialog", "File Import Page", None, QtGui.QApplication.UnicodeUTF8)) self.OptionsGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Download Options", None, QtGui.QApplication.UnicodeUTF8)) self.LocationLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Location:", None, QtGui.QApplication.UnicodeUTF8)) - self.LocationComboBox.setItemText(0, QtGui.QApplication.translate("BibleImportDialog", "BibleGateway", None, QtGui.QApplication.UnicodeUTF8)) - self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "CrossWire", None, QtGui.QApplication.UnicodeUTF8)) + self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "BibleGateway", None, QtGui.QApplication.UnicodeUTF8)) + self.LocationComboBox.setItemText(2, QtGui.QApplication.translate("BibleImportDialog", "CrossWire", None, QtGui.QApplication.UnicodeUTF8)) self.TypeLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8)) - self.TypeComboBox.setItemText(0, QtGui.QApplication.translate("BibleImportDialog", "Download As Needed", None, QtGui.QApplication.UnicodeUTF8)) - self.TypeComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Download All", None, QtGui.QApplication.UnicodeUTF8)) + self.TypeComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Download As Needed", None, QtGui.QApplication.UnicodeUTF8)) + self.TypeComboBox.setItemText(2, QtGui.QApplication.translate("BibleImportDialog", "Download All", None, QtGui.QApplication.UnicodeUTF8)) self.BibleLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Bible:", None, QtGui.QApplication.UnicodeUTF8)) self.BibleComboBox.setItemText(0, QtGui.QApplication.translate("BibleImportDialog", "NIV", None, QtGui.QApplication.UnicodeUTF8)) self.BibleComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "KJV", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 5d18ef34a..41d274e2f 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -83,10 +83,11 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog): #bipf.show() if self.biblemanager != None: self.MessageLabel.setText("Import Started") - self.ProgressBar.setValue(0) + self.ProgressBar.setValue(1) self.progress = 0 self.biblemanager.processDialog(self) self.biblemanager.registerOSISFileBible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) + self.biblemanager.saveMetaData(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText())) self.MessageLabel.setText("Import Complete") elif button.text() == "Cancel": self.close() @@ -94,7 +95,11 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog): def setMax(self, max): self.ProgressBar.setMaximum(max) - def incrementBar(self): + def incrementBar(self, text = None): + if text != None: + self.MessageLabel.setText("Import progressing with " + text) + else: + self.MessageLabel.setText("Import progressing") self.progress +=1 self.ProgressBar.setValue(self.progress) self.update() diff --git a/openlp/plugins/bibles/lib/biblemanager.py b/openlp/plugins/bibles/lib/biblemanager.py index f2f986e92..00b575cee 100644 --- a/openlp/plugins/bibles/lib/biblemanager.py +++ b/openlp/plugins/bibles/lib/biblemanager.py @@ -58,6 +58,7 @@ class BibleManager(): self.bibleDBCache[bname] = BibleDBImpl(self.biblePath, bname, self.bibleSuffix) biblesource = self.bibleDBCache[bname].getMeta("WEB") # look to see if lazy load bible exists and get create getter. if biblesource: + print biblesource nhttp = BibleHTTPImpl() nhttp.setBibleSource(biblesource) # tell The Server where to get the verses from. self.bibleHTTPCache[bname] = nhttp @@ -141,7 +142,7 @@ class BibleManager(): self._loadBook(biblename,bookid, bookname, bookabbrev) self._loadChapter(biblename,bookid, bookname, chptr) - def getBibles(self): + def getBibles(self, mode="full"): """ Returns a list of Books of the bible """ @@ -180,6 +181,22 @@ class BibleManager(): log.debug( "getVersesFromText %s,%s", bible, versetext) return self.bibleDBCache[bible].getVersesFromText(versetext) + def saveMetaData(self, bible, version, copyright, permissions): + """ + Saves the bibles meta data + """ + log.debug( "saveMetaData %s,%s, %s,%s", bible, version, copyright, permissions) + self.bibleDBCache[bible].saveMeta("Version", version) + self.bibleDBCache[bible].saveMeta("Copyright", copyright) + self.bibleDBCache[bible].saveMeta("Permissins", permissions) + + def getMetaData(self, bible, key): + """ + Returns the meta data for a given key + """ + log.debug( "getMetaData %s,%s", bible, key) + self.bibleDBCache[bible].getMeta(key) + def getVerseText(self, bible, bookname, chapter, sverse, everse = 0 ): """ Returns a list of verses for a given Book, Chapter and ranges of verses. diff --git a/openlp/plugins/images/__init__.py b/openlp/plugins/images/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py new file mode 100644 index 000000000..abf78ef96 --- /dev/null +++ b/openlp/plugins/images/imageplugin.py @@ -0,0 +1,95 @@ +# -*- 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 +""" + +from PyQt4 import QtCore, QtGui +from openlp.core.resources import * +from openlp.core.lib import Plugin, MediaManagerItem +#from forms import EditSongForm + +class ImagePlugin(Plugin): + def __init__(self): + # Call the parent constructor + Plugin.__init__(self, 'Images', '1.9.0') + self.Weight = -7 + + + def getMediaManagerItem(self): + # Create the plugin icon + self.Icon = QtGui.QIcon() + self.Icon.addPixmap(QtGui.QPixmap(':/media/media_song.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + # Create the MediaManagerItem object + self.MediaManagerItem = MediaManagerItem(self.Icon, 'Images') + # Add a toolbar + self.MediaManagerItem.addToolbar() + # Create buttons for the toolbar + ## New Song Button ## + self.MediaManagerItem.addToolbarButton('Update', 'Update Images', + ':/songs/song_new.png', self.onImagesNewClick, 'ImageNewItem') + ## Edit Song Button ## + self.MediaManagerItem.addToolbarButton('Edit Song', 'Edit the selected song', + ':/songs/song_edit.png', self.onSongEditClick, 'PresentationEditItem') + ## Delete Song Button ## + self.MediaManagerItem.addToolbarButton('Delete Song', 'Delete the selected song', + ':/songs/song_delete.png', self.onSongDeleteClick, 'SongDeleteItem') + ## Separator Line ## + self.MediaManagerItem.addToolbarSeparator() + ## Preview Song Button ## + self.MediaManagerItem.addToolbarButton('Preview Song', 'Preview the selected song', + ':/system/system_preview.png', self.onSongPreviewClick, 'SongPreviewItem') + ## Live Song Button ## + self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected song live', + ':/system/system_live.png', self.onSongLiveClick, 'SongLiveItem') + ## Add Song Button ## + self.MediaManagerItem.addToolbarButton('Add Song To Service', + 'Add the selected song(s) to the service', ':/system/system_add.png', + self.onSongAddClick, 'SongAddItem') + ## Add the songlist widget ## + + self.listView = QtGui.QListWidget() + self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.listView.setObjectName("listView") + self.MediaManagerItem.PageLayout.addWidget(self.listView) + + return self.MediaManagerItem + + def initalise_ui(self): + self.onImagesNewClick() + + def onImagesNewClick(self): + files = self.config.get_files() + self.listView.clear() + for f in files: + self.listView.addItem(f) + + def onSongEditClick(self): + self.edit_song_form.show() + + def onSongDeleteClick(self): + pass + + def onSongPreviewClick(self): + pass + + def onSongLiveClick(self): + pass + + def onSongAddClick(self): + pass diff --git a/openlp/plugins/videos/__init__.py b/openlp/plugins/videos/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openlp/plugins/videos/videoplugin.py b/openlp/plugins/videos/videoplugin.py new file mode 100644 index 000000000..b9c37976f --- /dev/null +++ b/openlp/plugins/videos/videoplugin.py @@ -0,0 +1,95 @@ +# -*- 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 +""" + +from PyQt4 import QtCore, QtGui +from openlp.core.resources import * +from openlp.core.lib import Plugin, MediaManagerItem +#from forms import EditSongForm + +class VideoPlugin(Plugin): + def __init__(self): + # Call the parent constructor + Plugin.__init__(self, 'Videos', '1.9.0') + self.Weight = -6 + + + def getMediaManagerItem(self): + # Create the plugin icon + self.Icon = QtGui.QIcon() + self.Icon.addPixmap(QtGui.QPixmap(':/media/media_song.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + # Create the MediaManagerItem object + self.MediaManagerItem = MediaManagerItem(self.Icon, 'Videos') + # Add a toolbar + self.MediaManagerItem.addToolbar() + # Create buttons for the toolbar + ## New Song Button ## + self.MediaManagerItem.addToolbarButton('Update', 'Update Videos', + ':/songs/song_new.png', self.onVideosNewClick, 'VideoNewItem') + ## Edit Song Button ## + self.MediaManagerItem.addToolbarButton('Edit Song', 'Edit the selected song', + ':/songs/song_edit.png', self.onSongEditClick, 'PresentationEditItem') + ## Delete Song Button ## + self.MediaManagerItem.addToolbarButton('Delete Song', 'Delete the selected song', + ':/songs/song_delete.png', self.onSongDeleteClick, 'SongDeleteItem') + ## Separator Line ## + self.MediaManagerItem.addToolbarSeparator() + ## Preview Song Button ## + self.MediaManagerItem.addToolbarButton('Preview Song', 'Preview the selected song', + ':/system/system_preview.png', self.onSongPreviewClick, 'SongPreviewItem') + ## Live Song Button ## + self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected song live', + ':/system/system_live.png', self.onSongLiveClick, 'SongLiveItem') + ## Add Song Button ## + self.MediaManagerItem.addToolbarButton('Add Song To Service', + 'Add the selected song(s) to the service', ':/system/system_add.png', + self.onSongAddClick, 'SongAddItem') + ## Add the songlist widget ## + + self.listView = QtGui.QListWidget() + self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.listView.setObjectName("listView") + self.MediaManagerItem.PageLayout.addWidget(self.listView) + + return self.MediaManagerItem + + def initalise(self): + self.onVideosNewClick() + + def onVideosNewClick(self): + files = self.config.get_files() + self.listView.clear() + for f in files: + self.listView.addItem(f) + + def onSongEditClick(self): + self.edit_song_form.show() + + def onSongDeleteClick(self): + pass + + def onSongPreviewClick(self): + pass + + def onSongLiveClick(self): + pass + + def onSongAddClick(self): + pass diff --git a/resources/.openlp/openlp.conf b/resources/.openlp/openlp.conf index 54cdf9246..ff25dae5a 100644 --- a/resources/.openlp/openlp.conf +++ b/resources/.openlp/openlp.conf @@ -10,4 +10,10 @@ file name = songs.sqlite data path = songs [presentations] -suffix name = ppt,pps,odi \ No newline at end of file +suffix name = ppt,pps,odi + +[images] +suffix name = jpg,gif,png,bmp + +[videos] +suffix name = avi,mpeg \ No newline at end of file diff --git a/resources/.openlp/openlp.conf_posix b/resources/.openlp/openlp.conf_posix index 01bd62aa8..b54a240dc 100644 --- a/resources/.openlp/openlp.conf_posix +++ b/resources/.openlp/openlp.conf_posix @@ -10,4 +10,11 @@ file name = songs.sqlite data path = songs [presentations] -suffix name = ppt,pps,odi \ No newline at end of file +suffix name = ppt,pps,odi + + +[images] +suffix name = jpg,gif,png,bmp + +[videos] +suffix name = avi,mpeg \ No newline at end of file diff --git a/resources/.openlp/openlp.conf_win b/resources/.openlp/openlp.conf_win index af27e8bdd..a115602ed 100644 --- a/resources/.openlp/openlp.conf_win +++ b/resources/.openlp/openlp.conf_win @@ -11,3 +11,9 @@ data path = songs [presentations] suffix name = ppt,pps,odi + +[images] +suffix name = jpg,gif,png,bmp + +[videos] +suffix name = avi,mpeg diff --git a/resources/forms/bibleimport.ui b/resources/forms/bibleimport.ui index feee92ab7..67703ed41 100644 --- a/resources/forms/bibleimport.ui +++ b/resources/forms/bibleimport.ui @@ -38,7 +38,7 @@ - 1 + 0 @@ -160,9 +160,9 @@ - 120 + 100 20 - 271 + 280 28 @@ -233,6 +233,11 @@ + + + + + BibleGateway @@ -254,6 +259,11 @@ + + + + + Download As Needed