From a077fe40ebb20cd9e472297bca3b5d8280a9ae27 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 2 Sep 2009 22:42:57 +0200 Subject: [PATCH] Updated the documentation more. Moved the Songs plugin out into it's own file. --- documentation/source/conf.py | 9 ++++- documentation/source/plugins/index.rst | 7 ++-- documentation/source/plugins/songs.rst | 28 +++++++++++++++ openlp.pyw | 44 ++++++++++++++--------- openlp/__init__.py | 2 ++ openlp/core/__init__.py | 2 ++ openlp/core/lib/eventreceiver.py | 49 ++++++++++++++++++++------ openlp/plugins/songs/songsplugin.py | 31 +++++++++++++++- 8 files changed, 139 insertions(+), 33 deletions(-) create mode 100644 documentation/source/plugins/songs.rst diff --git a/documentation/source/conf.py b/documentation/source/conf.py index 05a3045df..e5dc88a7e 100644 --- a/documentation/source/conf.py +++ b/documentation/source/conf.py @@ -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 = [] diff --git a/documentation/source/plugins/index.rst b/documentation/source/plugins/index.rst index e618fa188..848f5a206 100644 --- a/documentation/source/plugins/index.rst +++ b/documentation/source/plugins/index.rst @@ -6,11 +6,10 @@ .. automodule:: openlp.plugins :members: -:mod:`songs` Plugin -------------------- +.. toctree:: + :maxdepth: 2 -.. automodule:: openlp.plugins.songs - :members: + songs :mod:`bibles` Plugin -------------------- diff --git a/documentation/source/plugins/songs.rst b/documentation/source/plugins/songs.rst new file mode 100644 index 000000000..fc1c6f5c4 --- /dev/null +++ b/documentation/source/plugins/songs.rst @@ -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: diff --git a/openlp.pyw b/openlp.pyw index 7c7f8f373..f86fb3269 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -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() diff --git a/openlp/__init__.py b/openlp/__init__.py index 6bcd6d97a..e70d1631d 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -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 diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index e3518b436..dff015d30 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -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 diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 15db0fead..b35586208 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -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'<>', data) + To send a message: + ``Receiver().send_message(u'<>', data)`` - ``Receive Message`` - QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<>'),<>) + To receive a Message + ``QtCore.QObject.connect(Receiver().get_receiver(), QtCore.SIGNAL(u'<>'), <>)`` """ 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 + + diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 598e32d06..d8d297f41 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -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)