Fixed up them plugins.

bzr-revno: 154
This commit is contained in:
Raoul Snyman 2008-12-01 18:36:53 +00:00
parent d5c17f8518
commit 44c3063cc0
8 changed files with 34 additions and 32 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
<!-- eric4 user project file for project openlp.org 2.0 -->
<!-- Saved: 2008-12-01, 16:24:53 -->
<!-- Saved: 2008-12-01, 20:35:11 -->
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
<UserProject version="4.0">
</UserProject>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
<!-- eric4 tasks file for project openlp.org 2.0 -->
<!-- Saved: 2008-12-01, 16:24:55 -->
<!-- Saved: 2008-12-01, 20:35:12 -->
<Tasks version="4.2">
<Task priority="1" completed="False" bugfix="False">
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
<!-- eric4 project file for project openlp.org 2.0 -->
<!-- Saved: 2008-12-01, 16:24:53 -->
<!-- Saved: 2008-12-01, 20:35:01 -->
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
<Project version="4.4">
<ProgLanguage mixed="0">Python</ProgLanguage>
@ -80,8 +80,6 @@
<Source>openlp/core/lib/event.py</Source>
<Source>openlp/core/utils/confighelper.py</Source>
<Source>openlp/core/utils/winregistry.py</Source>
<Source>openlp/core/utils/linregistry.py</Source>
<Source>openlp/core/utils/registry.py</Source>
</Sources>
<Forms>
<Form>resources/forms/bibleimport.ui</Form>

View File

@ -74,6 +74,7 @@ class Plugin(object):
self.SettingsTab = None
self.ImportMenuItem = None
self.ExportMenuItem = None
self.Weight = 0
def about(self):
"""

View File

@ -18,15 +18,12 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os, sys
import os
import sys
import logging
from openlp.core.lib import Plugin
# Not sure what this is for. I prefer keeping as much code in the class as possible.
mypath=os.path.split(os.path.abspath(__file__))[0]
sys.path.insert(0,(os.path.join(mypath, '..' ,'..')))
class PluginManager(object):
"""
This is the Plugin manager, which loads all the plugins,
@ -70,23 +67,27 @@ class PluginManager(object):
__import__(modulename, globals(), locals(), [])
except ImportError:
pass
self.plugins = Plugin.__subclasses__()
self.plugin_by_name = {}
for p in self.plugins:
self.plugin_classes = Plugin.__subclasses__()
self.plugins = []
plugin_objects = []
for p in self.plugin_classes:
plugin = p()
self.plugin_by_name[plugin.Name] = plugin;
plugin_objects.append(plugin)
self.plugins = sorted(plugin_objects, self.orderByWeight)
def orderByWeight(self, x, y):
return cmp(x.Weight, y.Weight)
def hookMediaManager(self, mediatoolbox):
"""
Loop through all the plugins. If a plugin has a valid media manager item,
add it to the media manager.
"""
for pname in self.plugin_by_name:
plugin = self.plugin_by_name[pname]
for plugin in self.plugins:
media_manager_item = plugin.getMediaManagerItem()
if media_manager_item is not None:
log.debug('Inserting media manager item from %s' % plugin.Name)
mediatoolbox.addItem(media_manager_item, plugin.Icon, plugin.Name)
mediatoolbox.addItem(media_manager_item, plugin.Icon, media_manager_item.Title)
def hookHandleEvent(self, event):
pass

View File

@ -22,9 +22,9 @@ from time import sleep
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core import PluginManager
from openlp.core.ui import AboutForm, AlertForm, SettingsDialog
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
from openlp.core import PluginManager
class MainWindow(object):

View File

@ -20,32 +20,34 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core import Plugin
from openlp.core.lib import Plugin, MediaManagerItem
from biblemanager import BibleManager
from bibleimportform import BibleImportForm
#from bibleManager import BibleManager
#from forms.bibleimportform import BibleImportForm
class BiblePlugin(Plugin):
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Bible', '1.9.0')
self.Weight = -9
#Register the bible Manager
self.biblemanager = BibleManager()
#self.biblemanager = BibleManager()
def getMediaManagerItem(self):
# Create the plugin icon
self.Icon = QtGui.QIcon()
self.Icon.addPixmap(QtGui.QPixmap(':/media/media_Bible.png'),
self.Icon.addPixmap(QtGui.QPixmap(':/media/media_verse.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
# Create the MediaManagerItem object
self.MediaManagerItem = MediaManagerItem(self.Icon, 'Bibles')
self.MediaManagerItem = MediaManagerItem(self.Icon, 'Bible Verses')
# Add a toolbar
self.MediaManagerItem.addToolbar()
# Create buttons for the toolbar
## New Bible Button ##
self.MediaManagerItem.addToolbarButton('New Bible', 'Register a new Bible',
':/Bibles/Bible_new.png', self.onBibleNewClick, 'BibleNewItem')
## Separator Line ##
self.MediaManagerItem.addToolbarSeparator()
#self.MediaManagerItem.addToolbarButton('New Bible', 'Register a new Bible',
# ':/bibles/bible_new.png', self.onBibleNewClick, 'BibleNewItem')
## Separator Line ##
#self.MediaManagerItem.addToolbarSeparator()
## Preview Bible Button ##
self.MediaManagerItem.addToolbarButton('Preview Bible', 'Preview the selected Bible Verse',
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
@ -62,12 +64,11 @@ class BiblePlugin(Plugin):
self.BibleList.setColumnCount(0)
self.BibleList.setRowCount(0)
self.MediaManagerItem.PageLayout.addWidget(self.BibleList)
def getMediaManagerItem(self):
return self.MediaManagerItem
def onBibleNewClick(self):
self.bibleimportform(self.biblemanager)
#self.bibleimportform(self.biblemanager)
pass
def onBiblePreviewClick(self):
pass

View File

@ -20,13 +20,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core import Plugin, MediaManagerItem
from openlp.core.lib import Plugin, MediaManagerItem
from forms import EditSongForm
class SongsPlugin(Plugin):
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Songs', '1.9.0')
self.Weight = -10
self.edit_song_form = EditSongForm()
def getMediaManagerItem(self):