Add new plugins - shells

Update bibles 
Add CheckPreConditions to plugin manager.
Sort out merge problems 

bzr-revno: 220
This commit is contained in:
Tim Bentley 2008-12-14 16:19:28 +00:00
parent 508a542d6f
commit f90cdd27be
14 changed files with 287 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -72,6 +72,7 @@ class PluginManager(object):
plugin_objects = []
for p in self.plugin_classes:
plugin = p()
if plugin.checkPreConditions() == True:
plugin_objects.append(plugin)
self.plugins = sorted(plugin_objects, self.order_by_weight)

View File

@ -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))

View File

@ -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()

View File

@ -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.

View File

View File

@ -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

View File

View File

@ -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

View File

@ -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

View File

@ -11,3 +11,10 @@ data path = songs
[presentations]
suffix name = ppt,pps,odi
[images]
suffix name = jpg,gif,png,bmp
[videos]
suffix name = avi,mpeg

View File

@ -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

View File

@ -38,7 +38,7 @@
</rect>
</property>
<property name="currentIndex" >
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="FileImportPage" >
<property name="geometry" >
@ -160,9 +160,9 @@
<widget class="QLineEdit" name="BibleNameEdit" >
<property name="geometry" >
<rect>
<x>120</x>
<x>100</x>
<y>20</y>
<width>271</width>
<width>280</width>
<height>28</height>
</rect>
</property>
@ -233,6 +233,11 @@
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="LocationComboBox" >
<item>
<property name="text" >
<string/>
</property>
</item>
<item>
<property name="text" >
<string>BibleGateway</string>
@ -254,6 +259,11 @@
</item>
<item row="1" column="1" >
<widget class="QComboBox" name="TypeComboBox" >
<item>
<property name="text" >
<string/>
</property>
</item>
<item>
<property name="text" >
<string>Download As Needed</string>