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"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd"> <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
<!-- eric4 user project file for project openlp.org 2.0 --> <!-- 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 --> <!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
<UserProject version="4.0"> <UserProject version="4.0">
</UserProject> </UserProject>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd"> <!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
<!-- eric4 tasks file for project openlp.org 2.0 --> <!-- 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"> <Tasks version="4.2">
<Task priority="1" completed="False" bugfix="False"> <Task priority="1" completed="False" bugfix="False">
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary> <Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>

View File

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

View File

@ -74,6 +74,7 @@ class Plugin(object):
self.SettingsTab = None self.SettingsTab = None
self.ImportMenuItem = None self.ImportMenuItem = None
self.ExportMenuItem = None self.ExportMenuItem = None
self.Weight = 0
def about(self): 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 Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import os, sys import os
import sys
import logging import logging
from openlp.core.lib import Plugin 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): class PluginManager(object):
""" """
This is the Plugin manager, which loads all the plugins, This is the Plugin manager, which loads all the plugins,
@ -70,23 +67,27 @@ class PluginManager(object):
__import__(modulename, globals(), locals(), []) __import__(modulename, globals(), locals(), [])
except ImportError: except ImportError:
pass pass
self.plugins = Plugin.__subclasses__() self.plugin_classes = Plugin.__subclasses__()
self.plugin_by_name = {} self.plugins = []
for p in self.plugins: plugin_objects = []
for p in self.plugin_classes:
plugin = p() 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): def hookMediaManager(self, mediatoolbox):
""" """
Loop through all the plugins. If a plugin has a valid media manager item, Loop through all the plugins. If a plugin has a valid media manager item,
add it to the media manager. add it to the media manager.
""" """
for pname in self.plugin_by_name: for plugin in self.plugins:
plugin = self.plugin_by_name[pname]
media_manager_item = plugin.getMediaManagerItem() media_manager_item = plugin.getMediaManagerItem()
if media_manager_item is not None: if media_manager_item is not None:
log.debug('Inserting media manager item from %s' % plugin.Name) 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): def hookHandleEvent(self, event):
pass pass

View File

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

View File

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

View File

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