This commit is contained in:
Tim Bentley 2009-09-07 18:07:29 +01:00
commit c1ccf8752f
26 changed files with 496 additions and 136 deletions

View File

@ -47,7 +47,7 @@ copyright = u'2009, Raoul Snyman'
# The short X.Y version. # The short X.Y version.
version = '2.0' version = '2.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '1.9.0' release = '2.0.pre'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
@ -96,7 +96,14 @@ html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} html_theme_options = {
'sidebarbgcolor': '#3a60a9',
'relbarbgcolor': '#203b6f',
'footerbgcolor': '#26437c',
'headtextcolor': '#203b6f',
'linkcolor': '#26437c',
'sidebarlinkcolor': '#ceceff'
}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] #html_theme_path = []

View File

@ -3,42 +3,9 @@
:mod:`core` Module :mod:`core` Module
================== ==================
.. automodule:: openlp.core .. toctree::
:members: :maxdepth: 2
:mod:`lib` Module lib
----------------- theme
.. automodule:: openlp.core.lib
:members:
:mod:`baselistwithdnd` Submodule
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. automodule:: openlp.core.lib.baselistwithdnd
:members:
:mod:`event` Submodule
^^^^^^^^^^^^^^^^^^^^^^
.. automodule:: openlp.core.lib.event
:members:
:mod:`eventmanager` Submodule
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. automodule:: openlp.core.lib.eventmanager
:members:
:mod:`eventreceiver` Submodule
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. automodule:: openlp.core.lib.eventreceiver
:members:
:mod:`theme` Submodule
----------------------
.. automodule:: openlp.core.theme
:members:

View File

@ -0,0 +1,110 @@
.. _core-lib:
:mod:`lib` Module
=================
Module Members
--------------
.. automodule:: openlp.core.lib
:members:
Module Classes
--------------
:mod:`BaseListWithDnD`
^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.baselistwithdnd.BaseListWithDnD
:members:
:mod:`EventReceiver`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.eventreceiver.EventReceiver
:members:
:mod:`ListWithPreviews`
^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.listwithpreviews.ListWithPreviews
:members:
:mod:`MediaManagerItem`
^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.mediamanageritem.MediaManagerItem
:members:
:mod:`Plugin`
^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.plugin.Plugin
:members:
:mod:`PluginConfig`
^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.pluginconfig.PluginConfig
:members:
:mod:`PluginManager`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.pluginmanager.PluginManager
:members:
:mod:`Renderer`
^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.renderer.Renderer
:members:
:mod:`RenderManager`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.rendermanager.RenderManager
:members:
:mod:`ServiceItem`
^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.serviceitem.ServiceItem
:members:
:mod:`SettingsTab`
^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.settingstab.SettingsTab
:members:
:mod:`SongXMLBuilder`
^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLBuilder
:members:
:mod:`SongXMLParser`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLParser
:members:
:mod:`ThemeXML`
^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.themexmlhandler.ThemeXML
:members:
:mod:`OpenLPToolbar`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.toolbar.OpenLPToolbar
:members:
:mod:`XmlRootClass`
^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.core.lib.xmlrootclass.XmlRootClass
:members:

View File

@ -0,0 +1,8 @@
.. _core-theme:
:mod:`theme` Module
===================
.. automodule:: openlp.core.theme
:members:

View File

@ -3,8 +3,12 @@
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
Welcome to OpenLP's documentation! Welcome
================================== =======
Welcome to the OpenLP 2.0 API Documentation! In here you will find all
information relating to OpenLP's core classes, core plugins, and anything else
deemed necessary or interesting by the developers.
Contents: Contents:

View File

@ -6,11 +6,10 @@
.. automodule:: openlp.plugins .. automodule:: openlp.plugins
:members: :members:
:mod:`songs` Plugin .. toctree::
------------------- :maxdepth: 2
.. automodule:: openlp.plugins.songs songs
:members:
:mod:`bibles` Plugin :mod:`bibles` Plugin
-------------------- --------------------

View File

@ -0,0 +1,46 @@
.. _plugins-songs:
:mod:`songs` Plugin
===================
.. automodule:: openlp.plugins.songs
:members:
:mod:`SongsPlugin` Class
------------------------
.. autoclass:: openlp.plugins.songs.songsplugin.SongsPlugin
:members:
:mod:`forms` Submodule
----------------------
.. automodule:: openlp.plugins.songs.forms
:members:
:mod:`AuthorsForm`
^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.plugins.songs.forms.authorsdialog.Ui_AuthorsDialog
:members:
.. autoclass:: openlp.plugins.songs.forms.authorsform.AuthorsForm
:members:
:mod:`EditSongForm`
^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.plugins.songs.forms.editsongdialog.Ui_EditSongDialog
:members:
.. autoclass:: openlp.plugins.songs.forms.editsongform.EditSongForm
:members:
:mod:`EditVerseForm`
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.plugins.songs.forms.editversedialog.Ui_EditVerseDialog
:members:
.. autoclass:: openlp.plugins.songs.forms.editverseform.EditVerseForm
:members:

View File

@ -3,7 +3,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -29,15 +31,7 @@ from openlp.core.lib import Receiver
from openlp.core.resources import * from openlp.core.resources import *
from openlp.core.ui import MainWindow, SplashScreen from openlp.core.ui import MainWindow, SplashScreen
filename=u'openlp.log'
log = logging.getLogger() log = logging.getLogger()
log.setLevel(logging.INFO)
logfile = logging.handlers.RotatingFileHandler(filename ,maxBytes=200000, backupCount=5)
logfile.setLevel(logging.DEBUG)
logfile.setFormatter(logging.Formatter(u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
log.addHandler(logfile)
class OpenLP(QtGui.QApplication): class OpenLP(QtGui.QApplication):
""" """
@ -78,22 +72,40 @@ class OpenLP(QtGui.QApplication):
self.mainWindow.show() self.mainWindow.show()
# now kill the splashscreen # now kill the splashscreen
self.splash.finish(self.mainWindow) self.splash.finish(self.mainWindow)
sys.exit(app.exec_()) sys.exit(self.exec_())
def main(): def main():
usage = "usage: %prog [options] arg1 arg2" """
The main function which parses command line options and then runs
the PyQt4 Application.
"""
# Set up command line options.
usage = u'Usage: %prog [options] [qt-options]'
parser = OptionParser(usage=usage) parser = OptionParser(usage=usage)
parser.add_option("-d", "--debug",dest="debug",action="store_true", parser.add_option("-d", "--debug", dest="debug",
help="Switch on Debugging ") action="store_true", help="set logging to DEBUG level")
# Set up logging
filename = u'openlp.log'
logfile = logging.handlers.RotatingFileHandler(
filename, maxBytes=200000, backupCount=5)
logfile.setFormatter(
logging.Formatter(u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
log.addHandler(logfile)
# Parse command line options and deal with them.
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if options.debug is not None: if options.debug is not None:
log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
# Now create and actually run the application.
app = OpenLP(sys.argv)
app.run()
if __name__ == u'__main__': if __name__ == u'__main__':
""" """
Instantiate and run the application. Instantiate and run the application.
""" """
main()
app = OpenLP(sys.argv)
#import cProfile #import cProfile
#cProfile.run("app.run()", "profile.out") #cProfile.run("main()", "profile.out")
app.run() main()

View File

@ -1,6 +1,8 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -21,17 +23,51 @@ import types
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
def translate(context, text): def translate(context, text):
"""
A special shortcut method to wrap around the Qt4 translation functions.
This abstracts the translation procedure so that we can change it if at a
later date if necessary, without having to redo the whole of OpenLP.
``context``
The translation context, used to give each string a context or a
namespace.
``text``
The text to put into the translation tables for translation.
"""
return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8) return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8)
def file_to_xml(xmlfile): def file_to_xml(xmlfile):
"""
Open a file and return the contents of the file.
``xmlfile``
The name of the file.
"""
return open(xmlfile).read() return open(xmlfile).read()
def str_to_bool(stringvalue): def str_to_bool(stringvalue):
"""
Convert a string version of a boolean into a real boolean.
``stringvalue``
The string value to examine and convert to a boolean type.
"""
if stringvalue is True or stringvalue is False: if stringvalue is True or stringvalue is False:
return stringvalue return stringvalue
return stringvalue.strip().lower() in (u'true', u'yes', u'y') return stringvalue.strip().lower() in (u'true', u'yes', u'y')
def buildIcon(icon): def buildIcon(icon):
"""
Build a QIcon instance from an existing QIcon, a resource location, or a
physical file location. If the icon is a QIcon instance, that icon is
simply returned. If not, it builds a QIcon instance from the resource or
file name.
``icon``
The icon to build. This can be a QIcon, a resource string in the form
``:/resource/file.png``, or a file location like ``/path/to/file.png``.
"""
ButtonIcon = None ButtonIcon = None
if type(icon) is QtGui.QIcon: if type(icon) is QtGui.QIcon:
ButtonIcon = icon ButtonIcon = icon
@ -59,6 +95,7 @@ def contextMenuSeparator(base):
action.setSeparator(True) action.setSeparator(True)
return action return action
from eventreceiver import Receiver
from settingsmanager import SettingsManager from settingsmanager import SettingsManager
from pluginconfig import PluginConfig from pluginconfig import PluginConfig
from plugin import Plugin from plugin import Plugin
@ -67,12 +104,10 @@ from settingstab import SettingsTab
from mediamanageritem import MediaManagerItem from mediamanageritem import MediaManagerItem
from xmlrootclass import XmlRootClass from xmlrootclass import XmlRootClass
from serviceitem import ServiceItem from serviceitem import ServiceItem
from eventreceiver import Receiver
from serviceitem import ServiceType from serviceitem import ServiceType
from serviceitem import ServiceItem from serviceitem import ServiceItem
from toolbar import OpenLPToolbar from toolbar import OpenLPToolbar
from songxmlhandler import SongXMLBuilder from songxmlhandler import SongXMLBuilder, SongXMLParser
from songxmlhandler import SongXMLParser
from themexmlhandler import ThemeXML from themexmlhandler import ThemeXML
from renderer import Renderer from renderer import Renderer
from rendermanager import RenderManager from rendermanager import RenderManager

View File

@ -24,8 +24,9 @@ from PyQt4 import QtCore
class EventReceiver(QtCore.QObject): class EventReceiver(QtCore.QObject):
""" """
Class to allow events to be passed from different parts of the system. Class to allow events to be passed from different parts of the
This is a private class and should not be used directly but via the Receiver class system. This is a private class and should not be used directly
but rather via the Receiver class.
``stop_import`` ``stop_import``
Stops the Bible Import Stops the Bible Import
@ -78,31 +79,57 @@ class EventReceiver(QtCore.QObject):
log = logging.getLogger(u'EventReceiver') log = logging.getLogger(u'EventReceiver')
def __init__(self): def __init__(self):
"""
Initialise the event receiver, calling the parent constructor.
"""
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
def send_message(self, event, msg=None): def send_message(self, event, msg=None):
log.debug(u'Event %s passed with payload %s' % (event, msg)) """
Emit a Qt signal.
``event``
The event to that was sent.
``msg``
Defaults to *None*. The message to send with the event.
"""
self.emit(QtCore.SIGNAL(event), msg) self.emit(QtCore.SIGNAL(event), msg)
class Receiver(): class Receiver():
""" """
Class to allow events to be passed from different parts of the system. Class to allow events to be passed from different parts of the
This is a static wrapper around the EventReceiver class. system. This is a static wrapper around the ``EventReceiver``
As there is only one instance of it in the systems the QT signal/slot architecture class. As there is only one instance of it in the system the QT
can send messages across the system signal/slot architecture can send messages across the system.
``Send message`` To send a message:
Receiver().send_message(u'<<Message ID>>', data) ``Receiver().send_message(u'<<Message ID>>', data)``
``Receive Message`` To receive a Message
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>) ``QtCore.QObject.connect(Receiver().get_receiver(), QtCore.SIGNAL(u'<<Message ID>>'), <<ACTION>>)``
""" """
eventreceiver = EventReceiver() eventreceiver = EventReceiver()
@staticmethod @staticmethod
def send_message(event, msg=None): def send_message(event, msg=None):
"""
Sends a message to the messaging system.
``event``
The event to send.
``msg``
Defaults to *None*. The message to send with the event.
"""
Receiver.eventreceiver.send_message(event, msg) Receiver.eventreceiver.send_message(event, msg)
@staticmethod @staticmethod
def get_receiver(): def get_receiver():
"""
Get the global ``eventreceiver`` instance.
"""
return Receiver.eventreceiver return Receiver.eventreceiver

View File

@ -31,28 +31,60 @@ class MediaManagerItem(QtGui.QWidget):
MediaManagerItem is a helper widget for plugins. MediaManagerItem is a helper widget for plugins.
None of the following *need* to be used, feel free to override None of the following *need* to be used, feel free to override
them cmopletely in your plugin's implementation. Alternatively, call them from your them cmopletely in your plugin's implementation. Alternatively,
plugin before or after you've done etra things that you need to. call them from your plugin before or after you've done extra
things that you need to.
The plugin will be assigned an icon called u':/media/media_' + 'self.ShortPluginName + u'image.png' **Constructor Parameters**
which needs to be available in the main resources in order for them to work, you need to have setup
self.TranslationContext ``parent``
self.PluginTextShort # eg 'Image' for the image plugin The parent widget. Usually this will be the *Media Manager*
self.ConfigSection - where the items in the media manager are stored itself. This needs to be a class descended from ``QWidget``.
this could potentially be self.PluginTextShort.lower()
self.OnNewPrompt=u'Select Image(s)' ``icon``
self.OnNewFileMasks=u'Images (*.jpg *jpeg *.gif *.png *.bmp)' Either a ``QIcon``, a resource path, or a file name. This is
assumes that the new action is to load a file. If not, override onnew the icon which is displayed in the *Media Manager*.
self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD()) ``title``
each plugin needs to inherit a class from this and pass that *class* (not an instance) to here The title visible on the item in the *Media Manager*.
via the ListViewWithDnD_class member
self.PreviewFunction - a function which returns a QImage to represent the item (a preview usually) **Member Variables**
- no scaling required - that's done later
If this fn is not defined, a default will be used (treat the filename as an image) When creating a descendant class from this class for your plugin,
the following member variables should be set.
``self.TranslationContext``
This sets the translation context of all the text in the
Media Manager item.
``self.PluginTextShort``
The shortened name for the plugin, e.g. *'Image'* for the
image plugin.
``self.ConfigSection``
The section in the configuration where the items in the media
manager are stored. This could potentially be
``self.PluginTextShort.lower()``.
``self.OnNewPrompt``
Defaults to *'Select Image(s)'*.
``self.OnNewFileMasks``
Defaults to *'Images (*.jpg *jpeg *.gif *.png *.bmp)'*. This
assumes that the new action is to load a file. If not, you
need to override the ``OnNew`` method.
``self.ListViewWithDnD_class``
This must be a **class**, not an object, descended from
``openlp.core.lib.BaseListWithDnD`` that is not used in any
other part of OpenLP.
``self.PreviewFunction``
This must be a method which returns a QImage to represent the
item (usually a preview). No scaling is required, that is
performed automatically by OpenLP when necessary. If this
method is not defined, a default will be used (treat the
filename as an image).
""" """
global log global log
@ -83,12 +115,17 @@ class MediaManagerItem(QtGui.QWidget):
self.initialise() self.initialise()
def retranslateUi(self): def retranslateUi(self):
"""
This method is called automatically to provide OpenLP with the
opportunity to translate the ``MediaManagerItem`` to another
language.
"""
pass pass
def addToolbar(self): def addToolbar(self):
""" """
A method to help developers easily add a toolbar to the media manager A method to help developers easily add a toolbar to the media
item. manager item.
""" """
if self.Toolbar is None: if self.Toolbar is None:
self.Toolbar = OpenLPToolbar(self) self.Toolbar = OpenLPToolbar(self)
@ -97,9 +134,29 @@ class MediaManagerItem(QtGui.QWidget):
def addToolbarButton(self, title, tooltip, icon, slot=None, objectname=None): def addToolbarButton(self, title, tooltip, icon, slot=None, objectname=None):
""" """
A method to help developers easily add a button to the toolbar. A method to help developers easily add a button to the toolbar.
``title``
The title of the button.
``tooltip``
The tooltip to be displayed when the mouse hovers over the
button.
``icon``
The icon of the button. This can be an instance of QIcon, or a
string cotaining either the absolute path to the image, or an
internal resource path starting with ':/'.
``slot``
The method to call when the button is clicked.
``objectname``
The name of the button.
""" """
# NB different order (when I broke this out, I wanted to not break compatability) # NB different order (when I broke this out, I didn't want to
# but it makes sense for the icon to come before the tooltip (as you have to have an icon, but not neccesarily a tooltip) # break compatability), but it makes sense for the icon to
# come before the tooltip (as you have to have an icon, but
# not neccesarily a tooltip)
self.Toolbar.addToolbarButton(title, icon, tooltip, slot, objectname) self.Toolbar.addToolbarButton(title, icon, tooltip, slot, objectname)
def addToolbarSeparator(self): def addToolbarSeparator(self):
@ -109,6 +166,11 @@ class MediaManagerItem(QtGui.QWidget):
self.Toolbar.addSeparator() self.Toolbar.addSeparator()
def setupUi(self): def setupUi(self):
"""
This method sets up the interface on the button. Plugin
developers use this to add and create toolbars, and the rest
of the interface of the media manager item.
"""
# Add a toolbar # Add a toolbar
self.addToolbar() self.addToolbar()
# Create buttons for the toolbar # Create buttons for the toolbar
@ -189,6 +251,11 @@ class MediaManagerItem(QtGui.QWidget):
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
def initialise(self): def initialise(self):
"""
Implement this method in your descendent media manager item to
do any UI or other initialisation. This method is called
automatically.
"""
pass pass
def addHeaderBar(self): def addHeaderBar(self):

View File

@ -21,17 +21,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import logging import logging
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.lib import PluginConfig from openlp.core.lib import PluginConfig, Receiver
# why does this not work???
# from openlp.core.lib import Event, EventType
# so I have to do this???
from eventreceiver import Receiver
class Plugin(object): class Plugin(object):
""" """
Base class for openlp plugins to inherit from. Base class for openlp plugins to inherit from.
Basic attributes are: **Basic Attributes**
``name`` ``name``
The name that should appear in the plugins list. The name that should appear in the plugins list.
@ -49,7 +45,7 @@ class Plugin(object):
``log`` ``log``
A log object used to log debugging messages. This is pre-instantiated. A log object used to log debugging messages. This is pre-instantiated.
Hook functions: **Hook Functions**
``check_pre_conditions()`` ``check_pre_conditions()``
Provides the Plugin with a handle to check if it can be loaded. Provides the Plugin with a handle to check if it can be loaded.
@ -201,7 +197,7 @@ class Plugin(object):
def finalise(self): def finalise(self):
""" """
Called by the plugin Manager to cleanup things Called by the plugin Manager to cleanup things.
""" """
pass pass

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 -2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008 -2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -19,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import os import os
from openlp.core.utils import ConfigHelper from openlp.core.utils import ConfigHelper
class PluginConfig(object): class PluginConfig(object):

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley, Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley,
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -52,7 +54,8 @@ class PluginManager(object):
def find_plugins(self, dir, plugin_helpers): def find_plugins(self, dir, plugin_helpers):
""" """
Scan the directory dir for objects inheriting from ``openlp.plugin``. Scan the directory ``dir`` for objects inheriting from the ``Plugin``
class.
``dir`` ``dir``
The directory to scan. The directory to scan.

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 - 2009Martin Thompson, Tim Bentley Portions copyright (c) 2008 - 2009Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -31,14 +33,6 @@ class RenderManager(object):
Class to pull all Renderer interactions into one place. The plugins will Class to pull all Renderer interactions into one place. The plugins will
call helper methods to do the rendering but this class will provide call helper methods to do the rendering but this class will provide
display defense code. display defense code.
"""
global log
log=logging.getLogger(u'RenderManager')
log.info(u'RenderManager Loaded')
def __init__(self, theme_manager, screen_list, screen_number=0):
"""
Initialise the render manager.
``theme_manager`` ``theme_manager``
The ThemeManager instance, used to get the current theme details. The ThemeManager instance, used to get the current theme details.
@ -49,6 +43,14 @@ class RenderManager(object):
``screen_number`` ``screen_number``
Defaults to *0*. The index of the output/display screen. Defaults to *0*. The index of the output/display screen.
""" """
global log
log = logging.getLogger(u'RenderManager')
log.info(u'RenderManager Loaded')
def __init__(self, theme_manager, screen_list, screen_number=0):
"""
Initialise the render manager.
"""
log.debug(u'Initilisation started') log.debug(u'Initilisation started')
self.screen_list = screen_list self.screen_list = screen_list
self.theme_manager = theme_manager self.theme_manager = theme_manager

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -20,8 +22,9 @@ Place, Suite 330, Boston, MA 02111-1307 USA
class SettingsManager(object): class SettingsManager(object):
""" """
Class to control the size of the UI components so they size correctly Class to control the size of the UI components so they size correctly.
This class is created by the main window and then calculates the size of individual components This class is created by the main window and then calculates the size of
individual components.
""" """
def __init__(self, screen): def __init__(self, screen):
self.screen = screen[0] self.screen = screen[0]

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 Martin Thompson, Tim Bentley Portions copyright (c) 2008 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -19,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginConfig from openlp.core.lib import PluginConfig
class SettingsTab(QtGui.QWidget): class SettingsTab(QtGui.QWidget):

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -16,9 +18,17 @@ 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 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 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 logging
from xml.dom.minidom import Document from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump from xml.etree.ElementTree import ElementTree, XML, dump
class SongXMLBuilder(object):
"""
This class builds the XML used to describe songs.
The basic XML looks like this::
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<song version="1.0"> <song version="1.0">
<lyrics language="en"> <lyrics language="en">
@ -27,15 +37,6 @@ from xml.etree.ElementTree import ElementTree, XML, dump
</verse> </verse>
</lyrics> </lyrics>
</song> </song>
"""
import logging
from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump
class SongXMLBuilder():
"""
This class builds the XML used to describe songs.
""" """
def __init__(self): def __init__(self):
""" """
@ -97,9 +98,21 @@ class SongXMLBuilder():
""" """
return self.song_xml.toxml(u'utf-8') return self.song_xml.toxml(u'utf-8')
class SongXMLParser():
class SongXMLParser(object):
""" """
A class to read in and parse a song's XML. A class to read in and parse a song's XML.
The basic XML looks like this::
<?xml version="1.0" encoding="UTF-8"?>
<song version="1.0">
<lyrics language="en">
<verse type="chorus" label="1">
<![CDATA[ ... ]]>
</verse>
</lyrics>
</song>
""" """
global log global log
log = logging.getLogger(u'SongXMLParser') log = logging.getLogger(u'SongXMLParser')

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2009 Raoul Snyman Copyright (c) 2009 Raoul Snyman
Portions copyright (c) 2009 Martin Thompson, Tim Bentley Portions copyright (c) 2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -109,9 +111,21 @@ class OpenLPToolbar(QtGui.QToolBar):
return QtGui.QIcon() return QtGui.QIcon()
def makeWidgetsInvisible(self, widgets): def makeWidgetsInvisible(self, widgets):
"""
Hide a set of widgets.
``widgets``
The list of names of widgets to be hidden.
"""
for widget in widgets: for widget in widgets:
self.actions[widget].setVisible(False) self.actions[widget].setVisible(False)
def makeWidgetsVisible(self, widgets): def makeWidgetsVisible(self, widgets):
"""
Show a set of widgets.
``widgets``
The list of names of widgets to be shown.
"""
for widget in widgets: for widget in widgets:
self.actions[widget].setVisible(True) self.actions[widget].setVisible(True)

View File

@ -2,7 +2,9 @@
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under

View File

@ -28,12 +28,22 @@ from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
OpenSongImportForm, OpenLPExportForm OpenSongImportForm, OpenLPExportForm
class SongsPlugin(Plugin): class SongsPlugin(Plugin):
"""
This is the number 1 plugin, if importance were placed on any
plugins. This plugin enables the user to create, edit and display
songs. Songs are divided into verses, and the verse order can be
specified. Authors, topics and song books can be assigned to songs
as well.
"""
global log global log
log = logging.getLogger(u'SongsPlugin') log = logging.getLogger(u'SongsPlugin')
log.info(u'Song Plugin loaded') log.info(u'Song Plugin loaded')
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
"""
Create and set up the Songs plugin.
"""
# Call the parent constructor # Call the parent constructor
Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers) Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers)
self.weight = -10 self.weight = -10
@ -48,11 +58,22 @@ class SongsPlugin(Plugin):
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
def get_media_manager_item(self): def get_media_manager_item(self):
# Create the MediaManagerItem object """
Create the MediaManagerItem object, which is displaed in the
Media Manager.
"""
self.media_item = SongMediaItem(self, self.icon, 'Songs') self.media_item = SongMediaItem(self, self.icon, 'Songs')
return self.media_item return self.media_item
def add_import_menu_item(self, import_menu): def add_import_menu_item(self, import_menu):
"""
Give the Songs plugin the opportunity to add items to the
**Import** menu.
``import_menu``
The actual **Import** menu item, so that your actions can
use it as their parent.
"""
self.ImportSongMenu = QtGui.QMenu(import_menu) self.ImportSongMenu = QtGui.QMenu(import_menu)
self.ImportSongMenu.setObjectName(u'ImportSongMenu') self.ImportSongMenu.setObjectName(u'ImportSongMenu')
self.ImportOpenSongItem = QtGui.QAction(import_menu) self.ImportOpenSongItem = QtGui.QAction(import_menu)
@ -88,6 +109,14 @@ class SongsPlugin(Plugin):
QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick) QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
def add_export_menu_item(self, export_menu): def add_export_menu_item(self, export_menu):
"""
Give the Songs plugin the opportunity to add items to the
**Export** menu.
``export_menu``
The actual **Export** menu item, so that your actions can
use it as their parent.
"""
self.ExportSongMenu = QtGui.QMenu(export_menu) self.ExportSongMenu = QtGui.QMenu(export_menu)
self.ExportSongMenu.setObjectName(u'ExportSongMenu') self.ExportSongMenu.setObjectName(u'ExportSongMenu')
self.ExportOpenSongItem = QtGui.QAction(export_menu) self.ExportOpenSongItem = QtGui.QAction(export_menu)