Updated the documentation more. Moved the Songs plugin out into it's own file.

This commit is contained in:
Raoul Snyman 2009-09-02 22:42:57 +02:00
parent d1139653c5
commit a077fe40eb
8 changed files with 139 additions and 33 deletions

View File

@ -96,7 +96,14 @@ html_theme = 'default'
# 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
# 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.
#html_theme_path = []

View File

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

View File

@ -0,0 +1,28 @@
.. _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` Class
^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: openlp.plugins.songs.forms.authorsdialog.Ui_AuthorsDialog
:members:
.. autoclass:: openlp.plugins.songs.forms.authorsform.AuthorsForm
:members:

View File

@ -3,7 +3,9 @@
# 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-2009 Martin Thompson, Tim Bentley,
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.ui import MainWindow, SplashScreen
filename=u'openlp.log'
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):
"""
@ -78,22 +72,40 @@ class OpenLP(QtGui.QApplication):
self.mainWindow.show()
# now kill the splashscreen
self.splash.finish(self.mainWindow)
sys.exit(app.exec_())
sys.exit(self.exec_())
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.add_option("-d", "--debug",dest="debug",action="store_true",
help="Switch on Debugging ")
parser.add_option("-d", "--debug", dest="debug",
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()
if options.debug is not None:
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__':
"""
Instantiate and run the application.
"""
main()
app = OpenLP(sys.argv)
#import cProfile
#cProfile.run("app.run()", "profile.out")
app.run()
#cProfile.run("main()", "profile.out")
main()

View File

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

View File

@ -24,8 +24,9 @@ from PyQt4 import QtCore
class EventReceiver(QtCore.QObject):
"""
Class to allow events to be passed from different parts of the system.
This is a private class and should not be used directly but via the Receiver class
Class to allow events to be passed from different parts of the
system. This is a private class and should not be used directly
but rather via the Receiver class.
``stop_import``
Stops the Bible Import
@ -59,31 +60,57 @@ class EventReceiver(QtCore.QObject):
log = logging.getLogger(u'EventReceiver')
def __init__(self):
"""
Initialise the event receiver, calling the parent constructor.
"""
QtCore.QObject.__init__(self)
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)
class Receiver():
"""
Class to allow events to be passed from different parts of the system.
This is a static wrapper around the EventReceiver class.
As there is only one instance of it in the systems the QT signal/slot architecture
can send messages across the system
Class to allow events to be passed from different parts of the
system. This is a static wrapper around the ``EventReceiver``
class. As there is only one instance of it in the system the QT
signal/slot architecture can send messages across the system.
``Send message``
Receiver().send_message(u'<<Message ID>>', data)
To send a message:
``Receiver().send_message(u'<<Message ID>>', data)``
``Receive Message``
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
To receive a Message
``QtCore.QObject.connect(Receiver().get_receiver(), QtCore.SIGNAL(u'<<Message ID>>'), <<ACTION>>)``
"""
eventreceiver = EventReceiver()
@staticmethod
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)
@staticmethod
def get_receiver():
"""
Get the global ``eventreceiver`` instance.
"""
return Receiver.eventreceiver

View File

@ -28,12 +28,22 @@ from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
OpenSongImportForm, OpenLPExportForm
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
log = logging.getLogger(u'SongsPlugin')
log.info(u'Song Plugin loaded')
def __init__(self, plugin_helpers):
"""
Create and set up the Songs plugin.
"""
# Call the parent constructor
Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers)
self.weight = -10
@ -48,11 +58,22 @@ class SongsPlugin(Plugin):
QtGui.QIcon.Normal, QtGui.QIcon.Off)
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')
return self.media_item
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.setObjectName(u'ImportSongMenu')
self.ImportOpenSongItem = QtGui.QAction(import_menu)
@ -88,6 +109,14 @@ class SongsPlugin(Plugin):
QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
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.setObjectName(u'ExportSongMenu')
self.ExportOpenSongItem = QtGui.QAction(export_menu)