This commit is contained in:
Tomas Groth 2014-03-19 18:49:46 +01:00
commit 991661b169
137 changed files with 1508 additions and 2116 deletions

View File

@ -49,8 +49,7 @@ def trace_error_handler(logger):
""" """
Log the calling path of an exception Log the calling path of an exception
``logger`` :param logger: logger to use so traceback is logged to correct class
logger to use so traceback is logged to correct class
""" """
for tb in traceback.extract_stack(): for tb in traceback.extract_stack():
logger.error('Called by ' + tb[3] + ' at line ' + str(tb[1]) + ' in ' + tb[0]) logger.error('Called by ' + tb[3] + ' at line ' + str(tb[1]) + ' in ' + tb[0])
@ -60,11 +59,8 @@ def check_directory_exists(directory, do_not_log=False):
""" """
Check a theme directory exists and if not create it Check a theme directory exists and if not create it
``directory`` :param directory: The directory to make sure exists
The directory to make sure exists :param do_not_log: To not log anything. This is need for the start up, when the log isn't ready.
``do_not_log``
To not log anything. This is need for the start up, when the log isn't ready.
""" """
if not do_not_log: if not do_not_log:
log.debug('check_directory_exists %s' % directory) log.debug('check_directory_exists %s' % directory)
@ -99,14 +95,12 @@ def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.Code
A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so 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. that we can change it if at a later date if necessary, without having to redo the whole of OpenLP.
``context`` :param context: The translation context, used to give each string a context or a namespace.
The translation context, used to give each string a context or a namespace. :param text: The text to put into the translation tables for translation.
:param comment: An identifying string for when the same text is used in different roles within the same context.
``text`` :param encoding:
The text to put into the translation tables for translation. :param n:
:param qt_translate:
``comment``
An identifying string for when the same text is used in different roles within the same context.
""" """
return qt_translate(context, text, comment, encoding, n) return qt_translate(context, text, comment, encoding, n)

View File

@ -69,8 +69,7 @@ class AppLocation(object):
""" """
Return the appropriate directory according to the directory type. Return the appropriate directory according to the directory type.
``dir_type`` :param dir_type: The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
""" """
if dir_type == AppLocation.AppDir: if dir_type == AppLocation.AppDir:
return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0])
@ -106,10 +105,9 @@ class AppLocation(object):
""" """
Get a list of files from the data files path. Get a list of files from the data files path.
``section`` :param section: Defaults to *None*. The section of code getting the files - used to load from a section's
Defaults to *None*. The section of code getting the files - used to load from a section's data subdirectory. data subdirectory.
:param extension:
``extension``
Defaults to *None*. The extension to search for. For example:: Defaults to *None*. The extension to search for. For example::
u'.png' u'.png'

View File

@ -73,8 +73,7 @@ class Registry(object):
""" """
Extracts the registry value from the list based on the key passed in Extracts the registry value from the list based on the key passed in
``key`` :param key: The service to be retrieved.
The service to be retrieved.
""" """
if key in self.service_list: if key in self.service_list:
return self.service_list[key] return self.service_list[key]
@ -88,11 +87,8 @@ class Registry(object):
""" """
Registers a component against a key. Registers a component against a key.
``key`` :param key: The service to be created this is usually a major class like "renderer" or "main_window" .
The service to be created this is usually a major class like "renderer" or "main_window" . :param reference: The service address to be saved.
``reference``
The service address to be saved.
""" """
if key in self.service_list: if key in self.service_list:
trace_error_handler(log) trace_error_handler(log)
@ -106,8 +102,7 @@ class Registry(object):
Removes the registry value from the list based on the key passed in (Only valid and active for testing Removes the registry value from the list based on the key passed in (Only valid and active for testing
framework). framework).
``key`` :param key: The service to be deleted.
The service to be deleted.
""" """
if key in self.service_list: if key in self.service_list:
del self.service_list[key] del self.service_list[key]
@ -116,13 +111,10 @@ class Registry(object):
""" """
Register an event and associated function to be called Register an event and associated function to be called
``event`` :param event: The function description like "live_display_hide" where a number of places in the code
The function description like "live_display_hide" where a number of places in the code
will/may need to respond to a single action and the caller does not need to understand or know about the will/may need to respond to a single action and the caller does not need to understand or know about the
recipients. recipients.
:param function: The function to be called when the event happens.
``function``
The function to be called when the event happens.
""" """
if event in self.functions_list: if event in self.functions_list:
self.functions_list[event].append(function) self.functions_list[event].append(function)
@ -133,11 +125,8 @@ class Registry(object):
""" """
Remove an event and associated handler Remove an event and associated handler
``event`` :param event: The function description..
The function description.. :param function: The function to be called when the event happens.
``function``
The function to be called when the event happens.
""" """
if self.running_under_test is False: if self.running_under_test is False:
trace_error_handler(log) trace_error_handler(log)
@ -150,14 +139,9 @@ class Registry(object):
""" """
Execute all the handlers associated with the event and return an array of results. Execute all the handlers associated with the event and return an array of results.
``event`` :param event: The function to be processed
The function to be processed :param args: Parameters to be passed to the function.
:param kwargs: Parameters to be passed to the function.
``*args``
Parameters to be passed to the function.
``*kwargs``
Parameters to be passed to the function.
""" """
results = [] results = []
if event in self.functions_list: if event in self.functions_list:

View File

@ -115,3 +115,38 @@ class RegistryProperties(object):
self._main_window = Registry().get('main_window') self._main_window = Registry().get('main_window')
return self._main_window return self._main_window
@property
def renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer') or not self._renderer:
self._renderer = Registry().get('renderer')
return self._renderer
@property
def theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager') or not self._theme_manager:
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
@property
def settings_form(self):
"""
Adds the settings form to the class dynamically
"""
if not hasattr(self, '_settings_form') or not self._settings_form:
self._settings_form = Registry().get('settings_form')
return self._settings_form
@property
def alerts_manager(self):
"""
Adds the alerts manager to the class dynamically
"""
if not hasattr(self, '_alerts_manager') or not self._alerts_manager:
self._alerts_manager = Registry().get('alerts_manager')
return self._alerts_manager

View File

@ -348,8 +348,7 @@ class Settings(QtCore.QSettings):
""" """
Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``. Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``.
``default_values`` :param default_values: A dict with setting keys and their default values.
A dict with setting keys and their default values.
""" """
Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items())) Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items()))
@ -419,8 +418,7 @@ class Settings(QtCore.QSettings):
Returns the value for the given ``key``. The returned ``value`` is of the same type as the default value in the Returns the value for the given ``key``. The returned ``value`` is of the same type as the default value in the
*Settings.__default_settings__* dict. *Settings.__default_settings__* dict.
``key`` :param key: The key to return the value from.
The key to return the value from.
""" """
# if group() is not empty the group has not been specified together with the key. # if group() is not empty the group has not been specified together with the key.
if self.group(): if self.group():
@ -434,12 +432,9 @@ class Settings(QtCore.QSettings):
""" """
This converts the given ``setting`` to the type of the given ``default_value``. This converts the given ``setting`` to the type of the given ``default_value``.
``setting`` :param setting: The setting to convert. This could be ``true`` for example.Settings()
The setting to convert. This could be ``true`` for example.Settings() :param default_value: Indication the type the setting should be converted to. For example ``True``
(type is boolean), meaning that we convert the string ``true`` to a python boolean.
``default_value``
Indication the type the setting should be converted to. For example ``True`` (type is boolean), meaning that
we convert the string ``true`` to a python boolean.
**Note**, this method only converts a few types and might need to be extended if a certain type is missing! **Note**, this method only converts a few types and might need to be extended if a certain type is missing!
""" """
@ -473,8 +468,7 @@ class Settings(QtCore.QSettings):
**Note**: Only a list of paths is returned; this does not convert anything! **Note**: Only a list of paths is returned; this does not convert anything!
``plugin`` :param plugin: The Plugin object.The caller has to convert/save the list himself; o
The Plugin object.The caller has to convert/save the list himself; o
""" """
files_list = [] files_list = []
# We need QSettings instead of Settings here to bypass our central settings dict. # We need QSettings instead of Settings here to bypass our central settings dict.

View File

@ -52,14 +52,9 @@ def init_db(url, auto_flush=True, auto_commit=False):
""" """
Initialise and return the session and metadata for a database Initialise and return the session and metadata for a database
``url`` :param url: The database to initialise connection with
The database to initialise connection with :param auto_flush: Sets the flushing behaviour of the session
:param auto_commit: Sets the commit behaviour of the session
``auto_flush``
Sets the flushing behaviour of the session
``auto_commit``
Sets the commit behaviour of the session
""" """
engine = create_engine(url, poolclass=NullPool) engine = create_engine(url, poolclass=NullPool)
metadata = MetaData(bind=engine) metadata = MetaData(bind=engine)
@ -71,8 +66,7 @@ def get_upgrade_op(session):
""" """
Create a migration context and an operations object for performing upgrades. Create a migration context and an operations object for performing upgrades.
``session`` :param session: The SQLAlchemy session object.
The SQLAlchemy session object.
""" """
context = MigrationContext.configure(session.bind.connect()) context = MigrationContext.configure(session.bind.connect())
return Operations(context) return Operations(context)

View File

@ -170,9 +170,7 @@ class FormattingTags(object):
""" """
Add a list of tags to the list. Add a list of tags to the list.
``tags`` :param tags: The list with tags to add.
The list with tags to add.
Each **tag** has to be a ``dict`` and should have the following keys: Each **tag** has to be a ``dict`` and should have the following keys:
* desc * desc

View File

@ -556,23 +556,12 @@ def build_html(item, screen, is_live, background, image=None, plugins=None):
""" """
Build the full web paged structure for display Build the full web paged structure for display
``item`` :param item: Service Item to be displayed
Service Item to be displayed :param screen: Current display information
:param is_live: Item is going live, rather than preview/theme building
``screen`` :param background: Theme background image - bytes
Current display information :param image: Image media item - bytes
:param plugins: The List of available plugins
``is_live``
Item is going live, rather than preview/theme building
``background``
Theme background image - bytes
``image``
Image media item - bytes
``plugins``
The List of available plugins
""" """
width = screen['size'].width() width = screen['size'].width()
height = screen['size'].height() height = screen['size'].height()
@ -626,8 +615,8 @@ def build_background_css(item, width):
""" """
Build the background css Build the background css
``item`` :param item: Service Item containing theme and location information
Service Item containing theme and location information :param width:
""" """
width = int(width) // 2 width = int(width) // 2
theme = item.theme_data theme = item.theme_data
@ -660,9 +649,7 @@ def build_lyrics_css(item):
""" """
Build the lyrics display css Build the lyrics display css
``item`` :param item: Service Item containing theme and location information
Service Item containing theme and location information
""" """
style = """ style = """
.lyricstable { .lyricstable {
@ -700,8 +687,7 @@ def build_lyrics_outline_css(theme_data):
""" """
Build the css which controls the theme outline. Also used by renderer for splitting verses Build the css which controls the theme outline. Also used by renderer for splitting verses
``theme_data`` :param theme_data: Object containing theme information
Object containing theme information
""" """
if theme_data.font_main_outline: if theme_data.font_main_outline:
size = float(theme_data.font_main_outline_size) / 16 size = float(theme_data.font_main_outline_size) / 16
@ -715,14 +701,9 @@ def build_lyrics_format_css(theme_data, width, height):
""" """
Build the css which controls the theme format. Also used by renderer for splitting verses Build the css which controls the theme format. Also used by renderer for splitting verses
``theme_data`` :param theme_data: Object containing theme information
Object containing theme information :param width: Width of the lyrics block
:param height: Height of the lyrics block
``width``
Width of the lyrics block
``height``
Height of the lyrics block
""" """
align = HorizontalType.Names[theme_data.display_horizontal_align] align = HorizontalType.Names[theme_data.display_horizontal_align]
valign = VerticalType.Names[theme_data.display_vertical_align] valign = VerticalType.Names[theme_data.display_vertical_align]
@ -756,8 +737,8 @@ def build_footer_css(item, height):
""" """
Build the display of the item footer Build the display of the item footer
``item`` :param item: Service Item to be processed.
Service Item to be processed. :param height:
""" """
style = """ style = """
left: %spx; left: %spx;

View File

@ -111,16 +111,12 @@ class Image(object):
""" """
Create an image for the :class:`ImageManager`'s cache. Create an image for the :class:`ImageManager`'s cache.
``path`` :param path: The image's file path. This should be an existing file path.
The image's file path. This should be an existing file path. :param source: The source describes the image's origin. Possible values are described in the
``source``
The source describes the image's origin. Possible values are described in the
:class:`~openlp.core.lib.ImageSource` class. :class:`~openlp.core.lib.ImageSource` class.
:param background: A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's ratio does not
``background``
A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's ratio does not
match with the display ratio. match with the display ratio.
""" """
self.path = path self.path = path
self.image = None self.image = None
@ -163,11 +159,8 @@ class PriorityQueue(queue.PriorityQueue):
""" """
Modifies the priority of the given ``image``. Modifies the priority of the given ``image``.
``image`` :param image: The image to remove. This should be an :class:`Image` instance.
The image to remove. This should be an :class:`Image` instance. :param new_priority: The image's new priority. See the :class:`Priority` class for priorities.
``new_priority``
The image's new priority. See the :class:`Priority` class for priorities.
""" """
self.remove(image) self.remove(image)
image.priority = new_priority image.priority = new_priority
@ -177,8 +170,7 @@ class PriorityQueue(queue.PriorityQueue):
""" """
Removes the given ``image`` from the queue. Removes the given ``image`` from the queue.
``image`` :param image: The image to remove. This should be an ``Image`` instance.
The image to remove. This should be an ``Image`` instance.
""" """
if (image.priority, image.secondary_priority, image) in self.queue: if (image.priority, image.secondary_priority, image) in self.queue:
self.queue.remove((image.priority, image.secondary_priority, image)) self.queue.remove((image.priority, image.secondary_priority, image))

View File

@ -95,8 +95,7 @@ class ListWidgetWithDnD(QtGui.QListWidget):
""" """
Receive drop event check if it is a file and process it if it is. Receive drop event check if it is a file and process it if it is.
``event`` :param event: Handle of the event pint passed
Handle of the event pint passed
""" """
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.setDropAction(QtCore.Qt.CopyAction) event.setDropAction(QtCore.Qt.CopyAction)

View File

@ -35,7 +35,7 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate
from openlp.core.lib import FileDialog, OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \ from openlp.core.lib import FileDialog, OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \
ServiceItemContext ServiceItemContext
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
@ -44,7 +44,7 @@ from openlp.core.lib.ui import create_widget_action, critical_error_message_box
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaManagerItem(QtGui.QWidget): class MediaManagerItem(QtGui.QWidget, RegistryProperties):
""" """
MediaManagerItem is a helper widget for plugins. MediaManagerItem is a helper widget for plugins.
@ -684,97 +684,3 @@ s
:param show_error: Should the error be shown (True) :param show_error: Should the error be shown (True)
""" """
raise NotImplementedError('Plugin.search needs to be defined by the plugin') raise NotImplementedError('Plugin.search needs to be defined by the plugin')
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)
def _get_preview_controller(self):
"""
Adds the preview controller to the class dynamically
"""
if not hasattr(self, '_preview_controller'):
self._preview_controller = Registry().get('preview_controller')
return self._preview_controller
preview_controller = property(_get_preview_controller)
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, '_media_controller'):
self._media_controller = Registry().get('media_controller')
return self._media_controller
media_controller = property(_get_media_controller)
def _get_service_manager(self):
"""
Adds the service manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager'):
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -30,11 +30,11 @@
Provide the generic plugin functionality for OpenLP plugins. Provide the generic plugin functionality for OpenLP plugins.
""" """
import logging import logging
import os
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.common import Registry, Settings, UiStrings from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings
from openlp.core.utils import get_application_version from openlp.core.utils import get_application_version
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -65,7 +65,7 @@ class StringContent(object):
VisibleName = 'visible_name' VisibleName = 'visible_name'
class Plugin(QtCore.QObject): class Plugin(QtCore.QObject, RegistryProperties):
""" """
Base class for openlp plugins to inherit from. Base class for openlp plugins to inherit from.
@ -122,28 +122,21 @@ class Plugin(QtCore.QObject):
def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None): def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None):
""" """
This is the constructor for the plugin object. This provides an easy This is the constructor for the plugin object. This provides an easy way for descendant plugins to populate
way for descendent plugins to populate common data. This method *must* common data. This method *must*
be overridden, like so:: be overridden, like so::
class MyPlugin(Plugin): class MyPlugin(Plugin):
def __init__(self): def __init__(self):
super(MyPlugin, self).__init__('MyPlugin', version=u'0.1') super(MyPlugin, self).__init__('MyPlugin', version=u'0.1')
``name`` :param name: Defaults to *None*. The name of the plugin.
Defaults to *None*. The name of the plugin. :param default_settings: A dict containing the plugin's settings. The value to each key is the default value
to be used.
``default_settings`` :param media_item_class: The class name of the plugin's media item.
A dict containing the plugin's settings. The value to each key is the default value to be used. :param settings_tab_class: The class name of the plugin's settings tab.
:param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number.
``media_item_class``
The class name of the plugin's media item.
``settings_tab_class``
The class name of the plugin's settings tab.
``version``
Defaults to *None*, which means that the same version number is used as OpenLP's version number.
""" """
log.debug('Plugin %s initialised' % name) log.debug('Plugin %s initialised' % name)
super(Plugin, self).__init__() super(Plugin, self).__init__()
@ -221,8 +214,7 @@ class Plugin(QtCore.QObject):
""" """
Upgrade the settings of this plugin. Upgrade the settings of this plugin.
``settings`` :param settings: The Settings object containing the old settings.
The Settings object containing the old settings.
""" """
pass pass
@ -230,8 +222,7 @@ class Plugin(QtCore.QObject):
""" """
Create a menu item and add it to the "Import" menu. Create a menu item and add it to the "Import" menu.
``import_menu`` :param import_menu: The Import menu.
The Import menu.
""" """
pass pass
@ -239,8 +230,7 @@ class Plugin(QtCore.QObject):
""" """
Create a menu item and add it to the "Export" menu. Create a menu item and add it to the "Export" menu.
``export_menu`` :param export_menu: The Export menu
The Export menu
""" """
pass pass
@ -248,8 +238,7 @@ class Plugin(QtCore.QObject):
""" """
Create a menu item and add it to the "Tools" menu. Create a menu item and add it to the "Tools" menu.
``tools_menu`` :param tools_menu: The Tools menu
The Tools menu
""" """
pass pass
@ -267,8 +256,7 @@ class Plugin(QtCore.QObject):
""" """
Add menu items to the menu, given the menubar. Add menu items to the menu, given the menubar.
``menubar`` :param menubar: The application's menu bar.
The application's menu bar.
""" """
pass pass
@ -284,8 +272,7 @@ class Plugin(QtCore.QObject):
def about(self): def about(self):
""" """
Show a dialog when the user clicks on the 'About' button in the plugin Show a dialog when the user clicks on the 'About' button in the plugin manager.
manager.
""" """
raise NotImplementedError('Plugin.about needs to be defined by the plugin') raise NotImplementedError('Plugin.about needs to be defined by the plugin')
@ -328,11 +315,8 @@ class Plugin(QtCore.QObject):
""" """
Renames a theme a plugin is using making the plugin use the new name. Renames a theme a plugin is using making the plugin use the new name.
``old_theme`` :param old_theme: The name of the theme the plugin should stop using.
The name of the theme the plugin should stop using. :param new_theme: The new name the plugin should now use
``new_theme``
The new name the plugin should now use.
""" """
pass pass
@ -410,26 +394,3 @@ class Plugin(QtCore.QObject):
The plugin's needs to handle a new song creation The plugin's needs to handle a new song creation
""" """
pass pass
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_application(self):
"""
Adds the openlp to the class dynamically
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -34,10 +34,10 @@ import sys
import imp import imp
from openlp.core.lib import Plugin, PluginStatus from openlp.core.lib import Plugin, PluginStatus
from openlp.core.common import AppLocation, Registry, OpenLPMixin, RegistryMixin from openlp.core.common import AppLocation, RegistryProperties, OpenLPMixin, RegistryMixin
class PluginManager(RegistryMixin, OpenLPMixin): class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties):
""" """
This is the Plugin manager, which loads all the plugins, This is the Plugin manager, which loads all the plugins,
and executes all the hooks, as and when necessary. and executes all the hooks, as and when necessary.
@ -176,8 +176,7 @@ class PluginManager(RegistryMixin, OpenLPMixin):
""" """
Loop through all the plugins and give them an opportunity to upgrade their settings. Loop through all the plugins and give them an opportunity to upgrade their settings.
``settings`` :param settings: The Settings object containing the old settings.
The Settings object containing the old settings.
""" """
for plugin in self.plugins: for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled: if plugin.status is not PluginStatus.Disabled:
@ -185,8 +184,7 @@ class PluginManager(RegistryMixin, OpenLPMixin):
def initialise_plugins(self): def initialise_plugins(self):
""" """
Loop through all the plugins and give them an opportunity to Loop through all the plugins and give them an opportunity to initialise themselves.
initialise themselves.
""" """
for plugin in self.plugins: for plugin in self.plugins:
self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active())) self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active()))
@ -196,8 +194,7 @@ class PluginManager(RegistryMixin, OpenLPMixin):
def finalise_plugins(self): def finalise_plugins(self):
""" """
Loop through all the plugins and give them an opportunity to Loop through all the plugins and give them an opportunity to clean themselves up
clean themselves up
""" """
for plugin in self.plugins: for plugin in self.plugins:
if plugin.is_active(): if plugin.is_active():
@ -220,23 +217,3 @@ class PluginManager(RegistryMixin, OpenLPMixin):
for plugin in self.plugins: for plugin in self.plugins:
if plugin.is_active(): if plugin.is_active():
plugin.new_service_created() plugin.new_service_created()
def _get_settings_form(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_settings_form'):
self._settings_form = Registry().get('settings_form')
return self._settings_form
settings_form = property(_get_settings_form)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -30,7 +30,7 @@
from PyQt4 import QtGui, QtCore, QtWebKit from PyQt4 import QtGui, QtCore, QtWebKit
from openlp.core.common import Registry, OpenLPMixin, RegistryMixin, Settings from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, RegistryMixin, Settings
from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, ScreenList, ServiceItem, expand_tags, \ from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, ScreenList, ServiceItem, expand_tags, \
build_lyrics_format_css, build_lyrics_outline_css build_lyrics_format_css, build_lyrics_outline_css
from openlp.core.common import ThemeLevel from openlp.core.common import ThemeLevel
@ -47,7 +47,7 @@ VERSE_FOR_LINE_COUNT = '\n'.join(map(str, range(100)))
FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456'] FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456']
class Renderer(OpenLPMixin, RegistryMixin): class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties):
""" """
Class to pull all Renderer interactions into one place. The plugins will call helper methods to do the rendering but Class to pull all Renderer interactions into one place. The plugins will call helper methods to do the rendering but
this class will provide display defense code. this class will provide display defense code.
@ -563,23 +563,3 @@ class Renderer(OpenLPMixin, RegistryMixin):
# this parse we are to be wordy # this parse we are to be wordy
line = line.replace('\n', ' ') line = line.replace('\n', ' ')
return line.split(' ') return line.split(' ')
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager') or not self._theme_manager :
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -150,8 +150,7 @@ class ScreenList(object):
""" """
Add a screen to the list of known screens. Add a screen to the list of known screens.
``screen`` :param screen: A dict with the screen properties::
A dict with the screen properties::
{ {
u'primary': True, u'primary': True,
@ -170,8 +169,7 @@ class ScreenList(object):
""" """
Remove a screen from the list of known screens. Remove a screen from the list of known screens.
``number`` :param number: The screen number (int).
The screen number (int).
""" """
log.info('remove_screen %d' % number) log.info('remove_screen %d' % number)
for screen in self.screen_list: for screen in self.screen_list:
@ -184,8 +182,7 @@ class ScreenList(object):
""" """
Confirms a screen is known. Confirms a screen is known.
``number`` :param number: The screen number (int).
The screen number (int).
""" """
for screen in self.screen_list: for screen in self.screen_list:
if screen['number'] == number: if screen['number'] == number:
@ -196,8 +193,7 @@ class ScreenList(object):
""" """
Set up the current screen dimensions. Set up the current screen dimensions.
``number`` :param number: The screen number (int).
The screen number (int).
""" """
log.debug('set_current_display %s' % number) log.debug('set_current_display %s' % number)
if number + 1 > self.display_count: if number + 1 > self.display_count:
@ -211,8 +207,7 @@ class ScreenList(object):
def set_override_display(self): def set_override_display(self):
""" """
Replace the current size with the override values, as the user wants to Replace the current size with the override values, as the user wants to have their own screen attributes.
have their own screen attributes.
""" """
log.debug('set_override_display') log.debug('set_override_display')
self.current = copy.deepcopy(self.override) self.current = copy.deepcopy(self.override)
@ -220,8 +215,7 @@ class ScreenList(object):
def reset_current_display(self): def reset_current_display(self):
""" """
Replace the current values with the correct values, as the user wants to Replace the current values with the correct values, as the user wants to use the correct screen attributes.
use the correct screen attributes.
""" """
log.debug('reset_current_display') log.debug('reset_current_display')
self.set_current_display(self.current['number']) self.set_current_display(self.current['number'])
@ -230,8 +224,7 @@ class ScreenList(object):
""" """
Return the screen number that the centre of the passed window is in. Return the screen number that the centre of the passed window is in.
``window`` :param window: A QWidget we are finding the location of.
A QWidget we are finding the location of.
""" """
x = window.x() + (window.width() // 2) x = window.x() + (window.width() // 2)
y = window.y() + (window.height() // 2) y = window.y() + (window.height() // 2)

View File

@ -79,8 +79,7 @@ class SearchEdit(QtGui.QLineEdit):
""" """
Reimplemented method to react to resizing of the widget. Reimplemented method to react to resizing of the widget.
``event`` :param event: The event that happened.
The event that happened.
""" """
size = self.clear_button.size() size = self.clear_button.size()
frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth)
@ -100,8 +99,7 @@ class SearchEdit(QtGui.QLineEdit):
""" """
Set a new current search type. Set a new current search type.
``identifier`` :param identifier: The search type identifier (int).
The search type identifier (int).
""" """
menu = self.menu_button.menu() menu = self.menu_button.menu()
for action in menu.actions(): for action in menu.actions():
@ -122,8 +120,8 @@ class SearchEdit(QtGui.QLineEdit):
A list of tuples to be used in the search type menu. The first item in the list will be preselected as the A list of tuples to be used in the search type menu. The first item in the list will be preselected as the
default. default.
``items`` :param items: The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or
The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or
string) and a title for the item in the menu. In short, they should look like this:: string) and a title for the item in the menu. In short, they should look like this::
(<identifier>, <icon>, <title>, <place holder text>) (<identifier>, <icon>, <title>, <place holder text>)
@ -162,8 +160,7 @@ class SearchEdit(QtGui.QLineEdit):
Internally implemented slot to react to when the text in the line edit has changed so that we can show or hide Internally implemented slot to react to when the text in the line edit has changed so that we can show or hide
the clear button. the clear button.
``text`` :param text: A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit.
A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit.
""" """
self.clear_button.setVisible(bool(text)) self.clear_button.setVisible(bool(text))

View File

@ -39,7 +39,7 @@ import uuid
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, Settings, translate from openlp.core.common import RegistryProperties, Settings, translate
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -140,7 +140,7 @@ class ItemCapabilities(object):
HasThumbnails = 19 HasThumbnails = 19
class ServiceItem(object): class ServiceItem(RegistryProperties):
""" """
The service item is a base class for the plugins to use to interact with The service item is a base class for the plugins to use to interact with
the service manager, the slide controller, and the projection screen the service manager, the slide controller, and the projection screen
@ -152,8 +152,7 @@ class ServiceItem(object):
""" """
Set up the service item. Set up the service item.
``plugin`` :param plugin: The plugin that this service item belongs to.
The plugin that this service item belongs to.
""" """
if plugin: if plugin:
self.name = plugin.name self.name = plugin.name
@ -199,8 +198,7 @@ class ServiceItem(object):
def _new_item(self): def _new_item(self):
""" """
Method to set the internal id of the item. This is used to compare Method to set the internal id of the item. This is used to compare service items to see if they are the same.
service items to see if they are the same.
""" """
self.unique_identifier = str(uuid.uuid1()) self.unique_identifier = str(uuid.uuid1())
self.validate_item() self.validate_item()
@ -209,8 +207,7 @@ class ServiceItem(object):
""" """
Add an ItemCapability to a ServiceItem Add an ItemCapability to a ServiceItem
``capability`` :param capability: The capability to add
The capability to add
""" """
self.capabilities.append(capability) self.capabilities.append(capability)
@ -218,30 +215,25 @@ class ServiceItem(object):
""" """
Tell the caller if a ServiceItem has a capability Tell the caller if a ServiceItem has a capability
``capability`` :param capability: The capability to test for
The capability to test for
""" """
return capability in self.capabilities return capability in self.capabilities
def add_icon(self, icon): def add_icon(self, icon):
""" """
Add an icon to the service item. This is used when displaying the Add an icon to the service item. This is used when displaying the service item in the service manager.
service item in the service manager.
``icon`` :param icon: A string to an icon in the resources or on disk.
A string to an icon in the resources or on disk.
""" """
self.icon = icon self.icon = icon
self.iconic_representation = build_icon(icon) self.iconic_representation = build_icon(icon)
def render(self, provides_own_theme_data=False): def render(self, provides_own_theme_data=False):
""" """
The render method is what generates the frames for the screen and The render method is what generates the frames for the screen and obtains the display information from the
obtains the display information from the renderer. At this point all renderer. At this point all slides are built for the given display size.
slides are built for the given display size.
``provides_own_theme_data`` :param provides_own_theme_data: This switch disables the usage of the item's theme. However, this is
This switch disables the usage of the item's theme. However, this is
disabled by default. If this is used, it has to be taken care, that disabled by default. If this is used, it has to be taken care, that
the renderer knows the correct theme data. However, this is needed the renderer knows the correct theme data. However, this is needed
for the theme manager. for the theme manager.
@ -289,11 +281,9 @@ class ServiceItem(object):
""" """
Add an image slide to the service item. Add an image slide to the service item.
``path`` :param path: The directory in which the image file is located.
The directory in which the image file is located. :param title: A title for the slide in the service item.
:param background:
``title``
A title for the slide in the service item.
""" """
if background: if background:
self.image_border = background self.image_border = background
@ -306,8 +296,8 @@ class ServiceItem(object):
""" """
Add a text slide to the service item. Add a text slide to the service item.
``raw_slide`` :param raw_slide: The raw text of the slide.
The raw text of the slide. :param verse_tag:
""" """
if verse_tag: if verse_tag:
verse_tag = verse_tag.upper() verse_tag = verse_tag.upper()
@ -320,14 +310,9 @@ class ServiceItem(object):
""" """
Add a slide from a command. Add a slide from a command.
``path`` :param path: The title of the slide in the service item.
The title of the slide in the service item. :param file_name: The title of the slide in the service item.
:param image: The command of/for the slide.
``file_name``
The title of the slide in the service item.
``image``
The command of/for the slide.
""" """
self.service_item_type = ServiceItemType.Command self.service_item_type = ServiceItemType.Command
self._raw_frames.append({'title': file_name, 'image': image, 'path': path, self._raw_frames.append({'title': file_name, 'image': image, 'path': path,
@ -336,8 +321,7 @@ class ServiceItem(object):
def get_service_repr(self, lite_save): def get_service_repr(self, lite_save):
""" """
This method returns some text which can be saved into the service This method returns some text which can be saved into the service file to represent this item.
file to represent this item.
""" """
service_header = { service_header = {
'name': self.name, 'name': self.name,
@ -380,21 +364,17 @@ class ServiceItem(object):
'display_title': slide['display_title'], 'notes': slide['notes']}) 'display_title': slide['display_title'], 'notes': slide['notes']})
return {'header': service_header, 'data': service_data} return {'header': service_header, 'data': service_data}
def set_from_service(self, serviceitem, path=None): def set_from_service(self, service_item, path=None):
""" """
This method takes a service item from a saved service file (passed This method takes a service item from a saved service file (passed from the ServiceManager) and extracts the
from the ServiceManager) and extracts the data actually required. data actually required.
``serviceitem`` :param service_item: The item to extract data from.
The item to extract data from. :param path: Defaults to *None*. This is the service manager path for things which have their files saved
with them or None when the saved service is lite and the original file paths need to be preserved.
``path``
Defaults to *None*. This is the service manager path for things
which have their files saved with them or None when the saved
service is lite and the original file paths need to be preserved..
""" """
log.debug('set_from_service called with path %s' % path) log.debug('set_from_service called with path %s' % path)
header = serviceitem['serviceitem']['header'] header = service_item['serviceitem']['header']
self.title = header['title'] self.title = header['title']
self.name = header['name'] self.name = header['name']
self.service_item_type = header['type'] self.service_item_type = header['type']
@ -430,21 +410,21 @@ class ServiceItem(object):
self.background_audio.append(os.path.join(path, filename)) self.background_audio.append(os.path.join(path, filename))
self.theme_overwritten = header.get('theme_overwritten', False) self.theme_overwritten = header.get('theme_overwritten', False)
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
for slide in serviceitem['serviceitem']['data']: for slide in service_item['serviceitem']['data']:
self._raw_frames.append(slide) self._raw_frames.append(slide)
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
settings_section = serviceitem['serviceitem']['header']['name'] settings_section = service_item['serviceitem']['header']['name']
background = QtGui.QColor(Settings().value(settings_section + '/background color')) background = QtGui.QColor(Settings().value(settings_section + '/background color'))
if path: if path:
self.has_original_files = False self.has_original_files = False
for text_image in serviceitem['serviceitem']['data']: for text_image in service_item['serviceitem']['data']:
filename = os.path.join(path, text_image) filename = os.path.join(path, text_image)
self.add_from_image(filename, text_image, background) self.add_from_image(filename, text_image, background)
else: else:
for text_image in serviceitem['serviceitem']['data']: for text_image in service_item['serviceitem']['data']:
self.add_from_image(text_image['path'], text_image['title'], background) self.add_from_image(text_image['path'], text_image['title'], background)
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem['serviceitem']['data']: for text_image in service_item['serviceitem']['data']:
if not self.title: if not self.title:
self.title = text_image['title'] self.title = text_image['title']
if path: if path:
@ -470,11 +450,9 @@ class ServiceItem(object):
def merge(self, other): def merge(self, other):
""" """
Updates the unique_identifier with the value from the original one Updates the unique_identifier with the value from the original one
The unique_identifier is unique for a given service item but this allows one to The unique_identifier is unique for a given service item but this allows one to replace an original version.
replace an original version.
``other`` :param other: The service item to be merged with
The service item to be merged with
""" """
self.unique_identifier = other.unique_identifier self.unique_identifier = other.unique_identifier
self.notes = other.notes self.notes = other.notes
@ -541,8 +519,7 @@ class ServiceItem(object):
""" """
Stores the media length of the item Stores the media length of the item
``length`` :param length: The length of the media item
The length of the media item
""" """
self.media_length = length self.media_length = length
if length > 0: if length > 0:
@ -560,8 +537,8 @@ class ServiceItem(object):
def get_rendered_frame(self, row): def get_rendered_frame(self, row):
""" """
Returns the correct frame for a given list and renders it if required. Returns the correct frame for a given list and renders it if required.
``row``
The service item slide to be returned :param row: The service item slide to be returned
""" """
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
return self._display_frames[row]['html'].split('\n')[0] return self._display_frames[row]['html'].split('\n')[0]
@ -626,8 +603,7 @@ class ServiceItem(object):
""" """
updates the theme in the service item updates the theme in the service item
``theme`` :param theme: The new theme to be replaced in the service item
The new theme to be replaced in the service item
""" """
self.theme_overwritten = (theme is None) self.theme_overwritten = (theme is None)
self.theme = theme self.theme = theme
@ -668,23 +644,3 @@ class ServiceItem(object):
if file_suffix.lower() not in suffix_list: if file_suffix.lower() not in suffix_list:
self.is_valid = False self.is_valid = False
break break
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)

View File

@ -35,10 +35,10 @@ own tab to the settings dialog.
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry from openlp.core.common import RegistryProperties
class SettingsTab(QtGui.QWidget): class SettingsTab(QtGui.QWidget, RegistryProperties):
""" """
SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. SettingsTab is a helper widget for plugins to define Tabs for the settings dialog.
""" """
@ -46,11 +46,10 @@ class SettingsTab(QtGui.QWidget):
""" """
Constructor to create the Settings tab item. Constructor to create the Settings tab item.
``title`` :param parent:
The title of the tab, which is used internally for the tab handling. :param title: The title of the tab, which is used internally for the tab handling.
:param visible_title: The title of the tab, which is usually displayed on the tab.
``visible_title`` :param icon_path:
The title of the tab, which is usually displayed on the tab.
""" """
super(SettingsTab, self).__init__(parent) super(SettingsTab, self).__init__(parent)
self.tab_title = title self.tab_title = title
@ -129,9 +128,7 @@ class SettingsTab(QtGui.QWidget):
""" """
Changes which need to be made after setup of application Changes which need to be made after setup of application
``postUpdate`` :param post_update: Indicates if called before or after updates.
Indicates if called before or after updates.
""" """
pass pass
@ -140,63 +137,3 @@ class SettingsTab(QtGui.QWidget):
Tab has just been made visible to the user Tab has just been made visible to the user
""" """
self.tab_visited = True self.tab_visited = True
def _get_service_manager(self):
"""
Adds the service manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager'):
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, '_media_controller'):
self._media_controller = Registry().get('media_controller')
return self._media_controller
media_controller = property(_get_media_controller)
def _get_settings_form(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_settings_form'):
self._settings_form = Registry().get('settings_form')
return self._settings_form
settings_form = property(_get_settings_form)

View File

@ -128,8 +128,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
""" """
Changes the language for this spelltextedit. Changes the language for this spelltextedit.
``action`` :param action: The action.
The action.
""" """
self.dictionary = enchant.Dict(action.text()) self.dictionary = enchant.Dict(action.text())
self.highlighter.spelling_dictionary = self.dictionary self.highlighter.spelling_dictionary = self.dictionary
@ -182,7 +181,7 @@ class Highlighter(QtGui.QSyntaxHighlighter):
def highlightBlock(self, text): def highlightBlock(self, text):
""" """
Highlight misspelt words in a block of text. Highlight mis spelt words in a block of text.
Note, this is a Qt hook. Note, this is a Qt hook.
""" """

View File

@ -172,11 +172,8 @@ class ThemeXML(object):
""" """
Expand the json objects and make into variables. Expand the json objects and make into variables.
``var`` :param var: The array list to be processed.
The array list to be processed. :param prev: The preceding string to add to the key to make the variable.
``prev``
The preceding string to add to the key to make the variable.
""" """
for key, value in var.items(): for key, value in var.items():
if prev: if prev:
@ -192,8 +189,7 @@ class ThemeXML(object):
""" """
Add the path name to the image name so the background can be rendered. Add the path name to the image name so the background can be rendered.
``path`` :param path: The path name to be added.
The path name to be added.
""" """
if self.background_type == 'image': if self.background_type == 'image':
if self.background_filename and path: if self.background_filename and path:
@ -226,8 +222,7 @@ class ThemeXML(object):
""" """
Add a Solid background. Add a Solid background.
``bkcolor`` :param bkcolor: The color of the background.
The color of the background.
""" """
background = self.theme_xml.createElement('background') background = self.theme_xml.createElement('background')
background.setAttribute('type', 'solid') background.setAttribute('type', 'solid')
@ -238,14 +233,9 @@ class ThemeXML(object):
""" """
Add a gradient background. Add a gradient background.
``startcolor`` :param startcolor: The gradient's starting colour.
The gradient's starting colour. :param endcolor: The gradient's ending colour.
:param direction: The direction of the gradient.
``endcolor``
The gradient's ending colour.
``direction``
The direction of the gradient.
""" """
background = self.theme_xml.createElement('background') background = self.theme_xml.createElement('background')
background.setAttribute('type', 'gradient') background.setAttribute('type', 'gradient')
@ -261,8 +251,8 @@ class ThemeXML(object):
""" """
Add a image background. Add a image background.
``filename`` :param filename: The file name of the image.
The file name of the image. :param border_color:
""" """
background = self.theme_xml.createElement('background') background = self.theme_xml.createElement('background')
background.setAttribute('type', 'image') background.setAttribute('type', 'image')
@ -278,57 +268,24 @@ class ThemeXML(object):
""" """
Add a Font. Add a Font.
``name`` :param name: The name of the font.
The name of the font. :param color: The colour of the font.
:param size: The size of the font.
``color`` :param override: Whether or not to override the default positioning of the theme.
The colour of the font. :param fonttype: The type of font, ``main`` or ``footer``. Defaults to ``main``.
:param bold:
``size`` :param italics: The weight of then font Defaults to 50 Normal
The size of the font. :param line_adjustment: Does the font render to italics Defaults to 0 Normal
:param xpos: The X position of the text block.
``override`` :param ypos: The Y position of the text block.
Whether or not to override the default positioning of the theme. :param width: The width of the text block.
:param height: The height of the text block.
``fonttype`` :param outline: Whether or not to show an outline.
The type of font, ``main`` or ``footer``. Defaults to ``main``. :param outline_color: The colour of the outline.
:param outline_pixel: How big the Shadow is
``weight`` :param shadow: Whether or not to show a shadow.
The weight of then font Defaults to 50 Normal :param shadow_color: The colour of the shadow.
:param shadow_pixel: How big the Shadow is
``italics``
Does the font render to italics Defaults to 0 Normal
``xpos``
The X position of the text block.
``ypos``
The Y position of the text block.
``width``
The width of the text block.
``height``
The height of the text block.
``outline``
Whether or not to show an outline.
``outline_color``
The colour of the outline.
``outline_size``
How big the Shadow is
``shadow``
Whether or not to show a shadow.
``shadow_color``
The colour of the shadow.
``shadow_size``
How big the Shadow is
""" """
background = self.theme_xml.createElement('font') background = self.theme_xml.createElement('font')
background.setAttribute('type', fonttype) background.setAttribute('type', fonttype)
@ -372,15 +329,9 @@ class ThemeXML(object):
""" """
Add a Display options. Add a Display options.
``horizontal`` :param horizontal: The horizontal alignment of the text.
The horizontal alignment of the text. :param vertical: The vertical alignment of the text.
:param transition: Whether the slide transition is active.
``vertical``
The vertical alignment of the text.
``transition``
Whether the slide transition is active.
""" """
background = self.theme_xml.createElement('display') background = self.theme_xml.createElement('display')
self.theme.appendChild(background) self.theme.appendChild(background)
@ -446,8 +397,7 @@ class ThemeXML(object):
""" """
Read in an XML string and parse it. Read in an XML string and parse it.
``xml`` :param xml: The XML string to parse.
The XML string to parse.
""" """
self.parse_xml(str(xml)) self.parse_xml(str(xml))
@ -455,8 +405,7 @@ class ThemeXML(object):
""" """
Parse an XML string. Parse an XML string.
``xml`` :param xml: The XML string to parse.
The XML string to parse.
""" """
# remove encoding string # remove encoding string
line = xml.find('?>') line = xml.find('?>')

View File

@ -74,11 +74,8 @@ class OpenLPToolbar(QtGui.QToolBar):
""" """
Set the visibility for a widget or a list of widgets. Set the visibility for a widget or a list of widgets.
``widget`` :param widgets: A list of string with widget object names.
A list of string with widget object names. :param visible: The new state as bool.
``visible``
The new state as bool.
""" """
for handle in widgets: for handle in widgets:
if handle in self.actions: if handle in self.actions:

View File

@ -66,8 +66,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
Drag and drop event does not care what data is selected as the recipient will use events to request the data Drag and drop event does not care what data is selected as the recipient will use events to request the data
move just tell it what plugin to call move just tell it what plugin to call
``event`` :param event: The event that occurred
The event that occurred
""" """
if event.buttons() != QtCore.Qt.LeftButton: if event.buttons() != QtCore.Qt.LeftButton:
event.ignore() event.ignore()
@ -85,8 +84,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
""" """
Receive drag enter event, check if it is a file or internal object and allow it if it is. Receive drag enter event, check if it is a file or internal object and allow it if it is.
``event`` :param event: The event that occurred
The event that occurred
""" """
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.accept() event.accept()
@ -99,8 +97,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
""" """
Receive drag move event, check if it is a file or internal object and allow it if it is. Receive drag move event, check if it is a file or internal object and allow it if it is.
``event`` :param event: The event that occurred
The event that occurred
""" """
QtGui.QTreeWidget.dragMoveEvent(self, event) QtGui.QTreeWidget.dragMoveEvent(self, event)
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
@ -116,8 +113,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
""" """
Receive drop event, check if it is a file or internal object and process it if it is. Receive drop event, check if it is a file or internal object and process it if it is.
``event`` :param event: Handle of the event pint passed
Handle of the event pint passed
""" """
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.setDropAction(QtCore.Qt.CopyAction) event.setDropAction(QtCore.Qt.CopyAction)

View File

@ -45,11 +45,8 @@ def add_welcome_page(parent, image):
""" """
Generate an opening welcome page for a wizard using a provided image. Generate an opening welcome page for a wizard using a provided image.
``parent`` :param parent: A ``QWizard`` object to add the welcome page to.
A ``QWizard`` object to add the welcome page to. :param image: A splash image for the wizard.
``image``
A splash image for the wizard.
""" """
parent.welcome_page = QtGui.QWizardPage() parent.welcome_page = QtGui.QWizardPage()
parent.welcome_page.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image)) parent.welcome_page.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image))
@ -73,19 +70,12 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and ``rejected()`` signals of the button box Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and ``rejected()`` signals of the button box
are connected with the dialogs ``accept()`` and ``reject()`` slots. are connected with the dialogs ``accept()`` and ``reject()`` slots.
``dialog`` :param dialog: The parent object. This has to be a ``QDialog`` descendant.
The parent object. This has to be a ``QDialog`` descendant. :param name: A string which is set as object name.
:param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``,
``name`` ``close``, and ``defaults``.
A string which is set as object name. :param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added
with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole.
``standard_buttons``
A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, ``close``, and
``defaults``.
``custom_buttons``
A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added with
QDialogButtonBox.ActionRole. Otherwhise the item has to be a tuple of a button and a ButtonRole.
""" """
if custom_buttons is None: if custom_buttons is None:
custom_buttons = [] custom_buttons = []
@ -117,17 +107,10 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F
""" """
Provides a standard critical message box for errors that OpenLP displays to users. Provides a standard critical message box for errors that OpenLP displays to users.
``title`` :param title: The title for the message box.
The title for the message box. :param message: The message to display to the user.
:param parent: The parent UI element to attach the dialog to.
``message`` :param question: Should this message box question the user.
The message to display to the user.
``parent``
The parent UI element to attach the dialog to.
``question``
Should this message box question the user.
""" """
if question: if question:
return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, return QtGui.QMessageBox.critical(parent, UiStrings().Error, message,
@ -140,11 +123,8 @@ def create_horizontal_adjusting_combo_box(parent, name):
""" """
Creates a QComboBox with adapting width for media items. Creates a QComboBox with adapting width for media items.
``parent`` :param parent: The parent widget.
The parent widget. :param name: A string set as object name for the combo box.
``name``
A string set as object name for the combo box.
""" """
combo = QtGui.QComboBox(parent) combo = QtGui.QComboBox(parent)
combo.setObjectName(name) combo.setObjectName(name)
@ -157,11 +137,9 @@ def create_button(parent, name, **kwargs):
""" """
Return an button with the object name set and the given parameters. Return an button with the object name set and the given parameters.
``parent`` :param parent: A QtCore.QWidget for the buttons parent (required).
A QtCore.QWidget for the buttons parent (required). :param name: A string which is set as object name (required).
:param kwargs:
``name``
A string which is set as object name (required).
``role`` ``role``
A string which can have one value out of ``delete``, ``up``, and ``down``. This decides about default values A string which can have one value out of ``delete``, ``up``, and ``down``. This decides about default values
@ -178,6 +156,7 @@ def create_button(parent, name, **kwargs):
``enabled`` ``enabled``
False in case the button should be disabled. False in case the button should be disabled.
""" """
if 'role' in kwargs: if 'role' in kwargs:
role = kwargs.pop('role') role = kwargs.pop('role')
@ -217,11 +196,9 @@ def create_action(parent, name, **kwargs):
""" """
Return an action with the object name set and the given parameters. Return an action with the object name set and the given parameters.
``parent`` :param parent: A QtCore.QObject for the actions parent (required).
A QtCore.QObject for the actions parent (required). :param name: A string which is set as object name (required).
:param kwargs:
``name``
A string which is set as object name (required).
``text`` ``text``
A string for the action text. A string for the action text.
@ -253,6 +230,7 @@ def create_action(parent, name, **kwargs):
``can_shortcuts`` ``can_shortcuts``
Capability stating if this action can have shortcuts. If ``True`` the action is added to shortcut dialog Capability stating if this action can have shortcuts. If ``True`` the action is added to shortcut dialog
otherwise it it not. Define your shortcut in the :class:`~openlp.core.lib.Settings` class. *Note*: When *not* otherwise it it not. Define your shortcut in the :class:`~openlp.core.lib.Settings` class. *Note*: When *not*
``True`` you *must not* set a shortcuts at all. ``True`` you *must not* set a shortcuts at all.
@ -314,11 +292,8 @@ def set_case_insensitive_completer(cache, widget):
""" """
Sets a case insensitive text completer for a widget. Sets a case insensitive text completer for a widget.
``cache`` :param cache: The list of items to use as suggestions.
The list of items to use as suggestions. :param widget: A widget to set the completer (QComboBox or QTextEdit instance)
``widget``
A widget to set the completer (QComboBox or QTextEdit instance)
""" """
completer = QtGui.QCompleter(cache) completer = QtGui.QCompleter(cache)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
@ -329,10 +304,7 @@ def create_valign_selection_widgets(parent):
""" """
Creates a standard label and combo box for asking users to select a vertical alignment. Creates a standard label and combo box for asking users to select a vertical alignment.
``parent`` :param parent: The parent object. This should be a ``QWidget`` descendant.
The parent object. This should be a ``QWidget`` descendant.
Returns a tuple of QLabel and QComboBox.
""" """
label = QtGui.QLabel(parent) label = QtGui.QLabel(parent)
label.setText(translate('OpenLP.Ui', '&Vertical Align:')) label.setText(translate('OpenLP.Ui', '&Vertical Align:'))

View File

@ -641,8 +641,7 @@ class AdvancedTab(SettingsTab):
""" """
Notify user about required restart. Notify user about required restart.
``checked`` :param checked: The state of the check box (boolean).
The state of the check box (boolean).
""" """
QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'),
translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP ' translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP '

View File

@ -38,7 +38,7 @@ import bs4
import sqlalchemy import sqlalchemy
from lxml import etree from lxml import etree
from openlp.core.common import Registry from openlp.core.common import RegistryProperties
from PyQt4 import Qt, QtCore, QtGui, QtWebKit from PyQt4 import Qt, QtCore, QtGui, QtWebKit
@ -93,7 +93,7 @@ from .exceptiondialog import Ui_ExceptionDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
""" """
The exception dialog The exception dialog
""" """
@ -260,13 +260,3 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
return '-' return '-'
except: except:
return '- (Possible non-standard UNO installation)' return '- (Possible non-standard UNO installation)'
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -34,10 +34,10 @@ from PyQt4 import QtGui
from .filerenamedialog import Ui_FileRenameDialog from .filerenamedialog import Ui_FileRenameDialog
from openlp.core.common import Registry, translate from openlp.core.common import Registry, RegistryProperties, translate
class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties):
""" """
The file rename dialog The file rename dialog
""" """
@ -58,13 +58,3 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog):
self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename'))
self.file_name_edit.setFocus() self.file_name_edit.setFocus()
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -41,7 +41,7 @@ from configparser import ConfigParser
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, translate from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, translate
from openlp.core.lib import PluginStatus, build_icon from openlp.core.lib import PluginStatus, build_icon
from openlp.core.utils import get_web_page from openlp.core.utils import get_web_page
from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
@ -75,7 +75,7 @@ class ThemeScreenshotThread(QtCore.QThread):
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties):
""" """
This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes.
""" """
@ -284,8 +284,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
def _build_theme_screenshots(self): def _build_theme_screenshots(self):
""" """
This method builds the theme screenshots' icons for all items in the This method builds the theme screenshots' icons for all items in the ``self.themes_list_widget``.
``self.themes_list_widget``.
""" """
themes = self.config.get('themes', 'files') themes = self.config.get('themes', 'files')
themes = themes.split(',') themes = themes.split(',')
@ -298,12 +297,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
break break
item.setIcon(build_icon(os.path.join(gettempdir(), 'openlp', screenshot))) item.setIcon(build_icon(os.path.join(gettempdir(), 'openlp', screenshot)))
def _getFileSize(self, url): def _get_file_size(self, url):
""" """
Get the size of a file. Get the size of a file.
``url`` :param url: The URL of the file we want to download.
The URL of the file we want to download.
""" """
site = urllib.request.urlopen(url) site = urllib.request.urlopen(url)
meta = site.info() meta = site.info()
@ -321,11 +319,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
Update the wizard progress page. Update the wizard progress page.
``status_text`` :param status_text: Current status information to display.
Current status information to display. :param increment: The value to increment the progress bar by.
``increment``
The value to increment the progress bar by.
""" """
if status_text: if status_text:
self.progress_label.setText(status_text) self.progress_label.setText(status_text)
@ -346,7 +341,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
item = self.songs_list_widget.item(i) item = self.songs_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked: if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole) filename = item.data(QtCore.Qt.UserRole)
size = self._getFileSize('%s%s' % (self.web, filename)) size = self._get_file_size('%s%s' % (self.web, filename))
self.max_progress += size self.max_progress += size
# Loop through the Bibles list and increase for each selected item # Loop through the Bibles list and increase for each selected item
iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget) iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget)
@ -355,7 +350,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
item = iterator.value() item = iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked: if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
filename = item.data(0, QtCore.Qt.UserRole) filename = item.data(0, QtCore.Qt.UserRole)
size = self._getFileSize('%s%s' % (self.web, filename)) size = self._get_file_size('%s%s' % (self.web, filename))
self.max_progress += size self.max_progress += size
iterator += 1 iterator += 1
# Loop through the themes list and increase for each selected item # Loop through the themes list and increase for each selected item
@ -364,7 +359,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
item = self.themes_list_widget.item(i) item = self.themes_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked: if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole) filename = item.data(QtCore.Qt.UserRole)
size = self._getFileSize('%s%s' % (self.web, filename)) size = self._get_file_size('%s%s' % (self.web, filename))
self.max_progress += size self.max_progress += size
if self.max_progress: if self.max_progress:
# Add on 2 for plugins status setting plus a "finished" point. # Add on 2 for plugins status setting plus a "finished" point.
@ -474,27 +469,3 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive
Settings().setValue(tag, status) Settings().setValue(tag, status)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager'):
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -335,8 +335,7 @@ class GeneralTab(SettingsTab):
""" """
Toggle screen state depending on check box state. Toggle screen state depending on check box state.
``checked`` :param checked: The state of the check box (boolean).
The state of the check box (boolean).
""" """
self.monitor_combo_box.setDisabled(checked) self.monitor_combo_box.setDisabled(checked)
self.custom_X_value_edit.setEnabled(checked) self.custom_X_value_edit.setEnabled(checked)

View File

@ -33,11 +33,11 @@ It is based on a QTableWidget but represents its contents in list form.
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry from openlp.core.common import RegistryProperties
from openlp.core.lib import ImageSource, ServiceItem from openlp.core.lib import ImageSource, ServiceItem
class ListPreviewWidget(QtGui.QTableWidget): class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties):
def __init__(self, parent, screen_ratio): def __init__(self, parent, screen_ratio):
""" """
Initializes the widget to default state. Initializes the widget to default state.
@ -161,14 +161,3 @@ class ListPreviewWidget(QtGui.QTableWidget):
Returns the number of slides this widget holds. Returns the number of slides this widget holds.
""" """
return super(ListPreviewWidget, self).rowCount() return super(ListPreviewWidget, self).rowCount()
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically.
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)

View File

@ -38,13 +38,12 @@ Some of the code for this form is based on the examples at:
import cgi import cgi
import logging import logging
import os
import sys import sys
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
from openlp.core.common import Registry, OpenLPMixin, Settings, translate from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate
from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte
from openlp.core.lib.theme import BackgroundType from openlp.core.lib.theme import BackgroundType
@ -118,7 +117,7 @@ class Display(QtGui.QGraphicsView):
self.web_loaded = True self.web_loaded = True
class MainDisplay(OpenLPMixin, Display): class MainDisplay(OpenLPMixin, Display, RegistryProperties):
""" """
This is the display screen as a specialized class from the Display class This is the display screen as a specialized class from the Display class
""" """
@ -468,50 +467,6 @@ class MainDisplay(OpenLPMixin, Display):
self.setCursor(QtCore.Qt.ArrowCursor) self.setCursor(QtCore.Qt.ArrowCursor)
self.frame.evaluateJavaScript('document.body.style.cursor = "auto"') self.frame.evaluateJavaScript('document.body.style.cursor = "auto"')
def _get_plugin_manager(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)
class AudioPlayer(OpenLPMixin, QtCore.QObject): class AudioPlayer(OpenLPMixin, QtCore.QObject):
""" """
@ -522,8 +477,7 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject):
""" """
The constructor for the display form. The constructor for the display form.
``parent`` :param parent: The parent widget.
The parent widget.
""" """
super(AudioPlayer, self).__init__(parent) super(AudioPlayer, self).__init__(parent)
self.current_index = -1 self.current_index = -1

View File

@ -493,13 +493,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
Settings().set_up_default_values() Settings().set_up_default_values()
self.about_form = AboutForm(self) self.about_form = AboutForm(self)
MediaController() MediaController()
self.settings_form = SettingsForm(self) SettingsForm(self)
self.formatting_tag_form = FormattingTagForm(self) self.formatting_tag_form = FormattingTagForm(self)
self.shortcut_form = ShortcutListForm(self) self.shortcut_form = ShortcutListForm(self)
# Set up the path with plugins # Set up the path with plugins
PluginManager(self) PluginManager(self)
ImageManager() ImageManager()
self.renderer = Renderer() Renderer()
# Set up the interface # Set up the interface
self.setupUi(self) self.setupUi(self)
# Define the media Dock Manager # Define the media Dock Manager
@ -697,11 +697,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Display an error message Display an error message
``title`` :param title: The title of the warning box.
The title of the warning box. :param message: The message to be displayed.
``message``
The message to be displayed.
""" """
if hasattr(self.application, 'splash'): if hasattr(self.application, 'splash'):
self.application.splash.close() self.application.splash.close()
@ -711,11 +708,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Display a warning message Display a warning message
``title`` :param title: The title of the warning box.
The title of the warning box. :param message: The message to be displayed.
``message``
The message to be displayed.
""" """
if hasattr(self.application, 'splash'): if hasattr(self.application, 'splash'):
self.application.splash.close() self.application.splash.close()
@ -725,11 +719,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Display an informational message Display an informational message
``title`` :param title: The title of the warning box.
The title of the warning box. :param message: The message to be displayed.
``message``
The message to be displayed.
""" """
if hasattr(self.application, 'splash'): if hasattr(self.application, 'splash'):
self.application.splash.close() self.application.splash.close()
@ -1067,8 +1058,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Runs all the cleanup code before OpenLP shuts down. Runs all the cleanup code before OpenLP shuts down.
``save_settings`` :param save_settings: Switch to prevent saving settings. Defaults to **True**.
Switch to prevent saving settings. Defaults to **True**.
""" """
self.image_manager.stop_manager = True self.image_manager.stop_manager = True
while self.image_manager.image_thread.isRunning(): while self.image_manager.image_thread.isRunning():
@ -1099,11 +1089,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
This method is called from the ServiceManager to set the title of the main window. This method is called from the ServiceManager to set the title of the main window.
``modified`` :param modified: Whether or not this service has been modified.
Whether or not this service has been modified. :param file_name: The file name of the service file.
``file_name``
The file name of the service file.
""" """
if modified: if modified:
title = '%s - %s*' % (UiStrings().OLPV2x, file_name) title = '%s - %s*' % (UiStrings().OLPV2x, file_name)
@ -1146,10 +1133,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Sets the visibility of the preview panel including saving the setting and updating the menu. Sets the visibility of the preview panel including saving the setting and updating the menu.
``visible`` :param visible: A bool giving the state to set the panel to
A bool giving the state to set the panel to
True - Visible True - Visible
False - Hidden False - Hidden
""" """
self.preview_controller.panel.setVisible(visible) self.preview_controller.panel.setVisible(visible)
Settings().setValue('user interface/preview panel', visible) Settings().setValue('user interface/preview panel', visible)
@ -1183,8 +1170,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Sets the visibility of the live panel including saving the setting and updating the menu. Sets the visibility of the live panel including saving the setting and updating the menu.
``visible``
A bool giving the state to set the panel to :param visible: A bool giving the state to set the panel to
True - Visible True - Visible
False - Hidden False - Hidden
""" """
@ -1266,8 +1253,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
""" """
Adds a service to the list of recently used files. Adds a service to the list of recently used files.
``filename`` :param filename: The service filename to add
The service filename to add
""" """
# The max_recent_files value does not have an interface and so never gets # The max_recent_files value does not have an interface and so never gets
# actually stored in the settings therefore the default value of 20 will # actually stored in the settings therefore the default value of 20 will

View File

@ -96,14 +96,10 @@ def get_media_players():
def set_media_players(players_list, overridden_player='auto'): def set_media_players(players_list, overridden_player='auto'):
""" """
This method saves the configured media players and overridden player to the This method saves the configured media players and overridden player to the settings
settings
``players_list`` :param players_list: A list with all active media players.
A list with all active media players. :param overridden_player: Here an special media player is chosen for all media actions.
``overridden_player``
Here an special media player is chosen for all media actions.
""" """
log.debug('set_media_players') log.debug('set_media_players')
players = ','.join(players_list) players = ','.join(players_list)

View File

@ -35,7 +35,7 @@ import os
import datetime import datetime
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, RegistryMixin, Settings, UiStrings, translate from openlp.core.common import OpenLPMixin, Registry, RegistryMixin, RegistryProperties, Settings, UiStrings, translate
from openlp.core.lib import OpenLPToolbar from openlp.core.lib import OpenLPToolbar
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
@ -80,26 +80,24 @@ class MediaSlider(QtGui.QSlider):
QtGui.QSlider.mouseReleaseEvent(self, event) QtGui.QSlider.mouseReleaseEvent(self, event)
class MediaController(object): class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
""" """
The implementation of the Media Controller. The Media Controller adds an own The implementation of the Media Controller. The Media Controller adds an own class for every Player.
class for every Player. Currently these are QtWebkit, Phonon and Vlc. Currently these are QtWebkit, Phonon and Vlc. display_controllers are an array of controllers keyed on the
slidecontroller or plugin which built them.
display_controllers are an array of controllers keyed on the ControllerType is the class containing the key values.
slidecontroller or plugin which built them. ControllerType is the class
containing the key values.
media_players are an array of media players keyed on player name. media_players are an array of media players keyed on player name.
current_media_players is an array of player instances keyed on ControllerType. current_media_players is an array of player instances keyed on ControllerType.
""" """
def __init__(self): def __init__(self, parent=None):
""" """
Constructor Constructor
""" """
Registry().register('media_controller', self) super(MediaController, self).__init__(parent)
Registry().register_function('bootstrap_initialise', self.bootstrap_initialise)
self.media_players = {} self.media_players = {}
self.display_controllers = {} self.display_controllers = {}
self.current_media_players = {} self.current_media_players = {}
@ -156,8 +154,7 @@ class MediaController(object):
Register each media Player (Webkit, Phonon, etc) and store Register each media Player (Webkit, Phonon, etc) and store
for later use for later use
``player`` :param player: Individual player class which has been enabled
Individual player class which has been enabled
""" """
self.media_players[player.name] = player self.media_players[player.name] = player
@ -199,8 +196,7 @@ class MediaController(object):
def media_state(self): def media_state(self):
""" """
Check if there is a running media Player and do updating stuff (e.g. Check if there is a running media Player and do updating stuff (e.g. update the UI)
update the UI)
""" """
if not list(self.current_media_players.keys()): if not list(self.current_media_players.keys()):
self.timer.stop() self.timer.stop()
@ -256,8 +252,7 @@ class MediaController(object):
""" """
Registers media controls where the players will be placed to run. Registers media controls where the players will be placed to run.
``controller`` :param controller: The controller where a player will be placed
The controller where a player will be placed
""" """
self.display_controllers[controller.controller_type] = controller self.display_controllers[controller.controller_type] = controller
self.setup_generic_controls(controller) self.setup_generic_controls(controller)
@ -266,8 +261,7 @@ class MediaController(object):
""" """
Set up controls on the control_panel for a given controller Set up controls on the control_panel for a given controller
``controller`` :param controller: First element is the controller which should be used
First element is the controller which should be used
""" """
controller.media_info = MediaInfo() controller.media_info = MediaInfo()
# Build a Media ToolBar # Build a Media ToolBar
@ -313,14 +307,10 @@ class MediaController(object):
def setup_display(self, display, preview): def setup_display(self, display, preview):
""" """
After a new display is configured, all media related widgets will be After a new display is configured, all media related widgets will be created too
created too
``display`` :param display: Display on which the output is to be played
Display on which the output is to be played :param preview: Whether the display is a main or preview display
``preview``
Whether the display is a main or preview display
""" """
# clean up possible running old media files # clean up possible running old media files
self.finalise() self.finalise()
@ -337,14 +327,10 @@ class MediaController(object):
def set_controls_visible(self, controller, value): def set_controls_visible(self, controller, value):
""" """
After a new display is configured, all media related widget will be After a new display is configured, all media related widget will be created too
created too
``controller`` :param controller: The controller on which controls act.
The controller on which controls act. :param value: control name to be changed.
``value``
control name to be changed.
""" """
# Generic controls # Generic controls
controller.mediabar.setVisible(value) controller.mediabar.setVisible(value)
@ -355,14 +341,10 @@ class MediaController(object):
def resize(self, display, player): def resize(self, display, player):
""" """
After Mainwindow changes or Splitter moved all related media widgets After Mainwindow changes or Splitter moved all related media widgets have to be resized
have to be resized
``display`` :param display: The display on which output is playing.
The display on which output is playing. :param player: The player which is doing the playing.
``player``
The player which is doing the playing.
""" """
player.resize(display) player.resize(display)
@ -370,17 +352,10 @@ class MediaController(object):
""" """
Loads and starts a video to run with the option of sound Loads and starts a video to run with the option of sound
``source`` :param source: Where the call originated form
Where the call originated form :param service_item: The player which is doing the playing
:param hidden: The player which is doing the playing
``service_item`` :param video_behind_text: Is the video to be played behind text.
The player which is doing the playing
``hidden``
The player which is doing the playing
``video_behind_text``
Is the video to be played behind text.
""" """
log.debug('video') log.debug('video')
is_valid = False is_valid = False
@ -437,8 +412,7 @@ class MediaController(object):
""" """
Loads and starts a media item to obtain the media length Loads and starts a media item to obtain the media length
``service_item`` :param service_item: The ServiceItem containing the details to be played.
The ServiceItem containing the details to be played.
""" """
controller = self.display_controllers[DisplayControllerType.Plugin] controller = self.display_controllers[DisplayControllerType.Plugin]
log.debug('media_length') log.debug('media_length')
@ -466,11 +440,9 @@ class MediaController(object):
""" """
Select the correct media Player type from the prioritized Player list Select the correct media Player type from the prioritized Player list
``controller`` :param controller: First element is the controller which should be used
First element is the controller which should be used :param display: Which display to use
:param service_item: The ServiceItem containing the details to be played.
``service_item``
The ServiceItem containing the details to be played.
""" """
used_players = get_media_players()[0] used_players = get_media_players()[0]
if service_item.processor != UiStrings().Automatic: if service_item.processor != UiStrings().Automatic:
@ -508,8 +480,8 @@ class MediaController(object):
""" """
Responds to the request to play a loaded video Responds to the request to play a loaded video
``msg`` :param msg: First element is the controller which should be used
First element is the controller which should be used :param status:
""" """
log.debug('media_play_msg') log.debug('media_play_msg')
self.media_play(msg[0], status) self.media_play(msg[0], status)
@ -518,8 +490,8 @@ class MediaController(object):
""" """
Responds to the request to play a loaded video Responds to the request to play a loaded video
``controller`` :param controller: The controller to be played
The controller to be played :param status:
""" """
log.debug('media_play') log.debug('media_play')
controller.seek_slider.blockSignals(True) controller.seek_slider.blockSignals(True)
@ -558,8 +530,7 @@ class MediaController(object):
""" """
Responds to the request to pause a loaded video Responds to the request to pause a loaded video
``msg`` :param msg: First element is the controller which should be used
First element is the controller which should be used
""" """
log.debug('media_pause_msg') log.debug('media_pause_msg')
self.media_pause(msg[0]) self.media_pause(msg[0])
@ -568,8 +539,7 @@ class MediaController(object):
""" """
Responds to the request to pause a loaded video Responds to the request to pause a loaded video
``controller`` :param controller: The Controller to be paused
The Controller to be paused
""" """
log.debug('media_pause') log.debug('media_pause')
display = self._define_display(controller) display = self._define_display(controller)
@ -582,8 +552,7 @@ class MediaController(object):
""" """
Responds to the request to stop a loaded video Responds to the request to stop a loaded video
``msg`` :param msg: First element is the controller which should be used
First element is the controller which should be used
""" """
log.debug('media_stop_msg') log.debug('media_stop_msg')
self.media_stop(msg[0]) self.media_stop(msg[0])
@ -592,8 +561,7 @@ class MediaController(object):
""" """
Responds to the request to stop a loaded video Responds to the request to stop a loaded video
``controller`` :param controller: The controller that needs to be stopped
The controller that needs to be stopped
""" """
log.debug('media_stop') log.debug('media_stop')
display = self._define_display(controller) display = self._define_display(controller)
@ -610,8 +578,7 @@ class MediaController(object):
""" """
Changes the volume of a running video Changes the volume of a running video
``msg`` :param msg: First element is the controller which should be used
First element is the controller which should be used
""" """
controller = msg[0] controller = msg[0]
vol = msg[1][0] vol = msg[1][0]
@ -621,8 +588,8 @@ class MediaController(object):
""" """
Changes the volume of a running video Changes the volume of a running video
``msg`` :param controller: The Controller to use
First element is the controller which should be used :param volume: The volume to be set
""" """
log.debug('media_volume %d' % volume) log.debug('media_volume %d' % volume)
display = self._define_display(controller) display = self._define_display(controller)
@ -633,8 +600,7 @@ class MediaController(object):
""" """
Responds to the request to change the seek Slider of a loaded video via a message Responds to the request to change the seek Slider of a loaded video via a message
``msg`` :param msg: First element is the controller which should be used
First element is the controller which should be used
Second element is a list with the seek value as first element Second element is a list with the seek value as first element
""" """
log.debug('media_seek') log.debug('media_seek')
@ -646,12 +612,8 @@ class MediaController(object):
""" """
Responds to the request to change the seek Slider of a loaded video Responds to the request to change the seek Slider of a loaded video
``controller`` :param controller: The controller to use.
The controller to use. :param seek_value: The value to set.
``seek_value``
The value to set.
""" """
log.debug('media_seek') log.debug('media_seek')
display = self._define_display(controller) display = self._define_display(controller)
@ -675,8 +637,7 @@ class MediaController(object):
""" """
Hide the related video Widget Hide the related video Widget
``msg`` :param msg: First element is the boolean for Live indication
First element is the boolean for Live indication
""" """
is_live = msg[1] is_live = msg[1]
if not is_live: if not is_live:
@ -691,8 +652,7 @@ class MediaController(object):
""" """
Blank the related video Widget Blank the related video Widget
``msg`` :param msg: First element is the boolean for Live indication
First element is the boolean for Live indication
Second element is the hide mode Second element is the hide mode
""" """
is_live = msg[1] is_live = msg[1]
@ -709,8 +669,7 @@ class MediaController(object):
""" """
Unblank the related video Widget Unblank the related video Widget
``msg`` :param msg: First element is not relevant in this context
First element is not relevant in this context
Second element is the boolean for Live indication Second element is the boolean for Live indication
""" """
Registry().execute('live_display_show') Registry().execute('live_display_show')
@ -738,29 +697,8 @@ class MediaController(object):
""" """
Extract the correct display for a given controller Extract the correct display for a given controller
``controller`` :param controller: Controller to be used
Controller to be used
""" """
if controller.is_live: if controller.is_live:
return controller.display return controller.display
return controller.preview_display return controller.preview_display
def _get_service_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)

View File

@ -31,11 +31,11 @@ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer cla
""" """
import os import os
from openlp.core.common import Registry from openlp.core.common import RegistryProperties
from openlp.core.ui.media import MediaState from openlp.core.ui.media import MediaState
class MediaPlayer(object): class MediaPlayer(RegistryProperties):
""" """
This is the base class media Player class to provide OpenLP with a pluggable media display framework. This is the base class media Player class to provide OpenLP with a pluggable media display framework.
""" """
@ -151,17 +151,3 @@ class MediaPlayer(object):
Returns Information about the player Returns Information about the player
""" """
return '' return ''
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -66,10 +66,8 @@ ADDITIONAL_EXT = {
class PhononPlayer(MediaPlayer): class PhononPlayer(MediaPlayer):
""" """
A specialised version of the MediaPlayer class, which provides a Phonon A specialised version of the MediaPlayer class, which provides a Phonon display.
display.
""" """
def __init__(self, parent): def __init__(self, parent):
""" """
Constructor Constructor
@ -83,11 +81,11 @@ class PhononPlayer(MediaPlayer):
for mime_type in Phonon.BackendCapabilities.availableMimeTypes(): for mime_type in Phonon.BackendCapabilities.availableMimeTypes():
mime_type = str(mime_type) mime_type = str(mime_type)
if mime_type.startswith('audio/'): if mime_type.startswith('audio/'):
self._addToList(self.audio_extensions_list, mime_type) self._add_to_list(self.audio_extensions_list, mime_type)
elif mime_type.startswith('video/'): elif mime_type.startswith('video/'):
self._addToList(self.video_extensions_list, mime_type) self._add_to_list(self.video_extensions_list, mime_type)
def _addToList(self, mimetype_list, mimetype): def _add_to_list(self, mime_type_list, mimetype):
""" """
Add mimetypes to the provided list Add mimetypes to the provided list
""" """
@ -95,8 +93,8 @@ class PhononPlayer(MediaPlayer):
extensions = mimetypes.guess_all_extensions(str(mimetype)) extensions = mimetypes.guess_all_extensions(str(mimetype))
for extension in extensions: for extension in extensions:
ext = '*%s' % extension ext = '*%s' % extension
if ext not in mimetype_list: if ext not in mime_type_list:
mimetype_list.append(ext) mime_type_list.append(ext)
log.info('MediaPlugin: %s extensions: %s' % (mimetype, ' '.join(extensions))) log.info('MediaPlugin: %s extensions: %s' % (mimetype, ' '.join(extensions)))
# Add extensions for this mimetype from self.additional_extensions. # Add extensions for this mimetype from self.additional_extensions.
# This hack clears mimetypes' and operating system's shortcomings # This hack clears mimetypes' and operating system's shortcomings
@ -104,8 +102,8 @@ class PhononPlayer(MediaPlayer):
if mimetype in list(self.additional_extensions.keys()): if mimetype in list(self.additional_extensions.keys()):
for extension in self.additional_extensions[mimetype]: for extension in self.additional_extensions[mimetype]:
ext = '*%s' % extension ext = '*%s' % extension
if ext not in mimetype_list: if ext not in mime_type_list:
mimetype_list.append(ext) mime_type_list.append(ext)
log.info('MediaPlugin: %s additional extensions: %s' % log.info('MediaPlugin: %s additional extensions: %s' %
(mimetype, ' '.join(self.additional_extensions[mimetype]))) (mimetype, ' '.join(self.additional_extensions[mimetype])))

View File

@ -99,11 +99,11 @@ class PlayerTab(SettingsTab):
self.player_order_layout = QtGui.QHBoxLayout(self.player_order_group_box) self.player_order_layout = QtGui.QHBoxLayout(self.player_order_group_box)
self.player_order_layout.setObjectName('player_order_layout') self.player_order_layout.setObjectName('player_order_layout')
self.player_order_list_widget = QtGui.QListWidget(self.player_order_group_box) self.player_order_list_widget = QtGui.QListWidget(self.player_order_group_box)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0) size_policy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) size_policy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth()) size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth())
self.player_order_list_widget.setSizePolicy(sizePolicy) self.player_order_list_widget.setSizePolicy(size_policy)
self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.player_order_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.player_order_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)

View File

@ -50,11 +50,9 @@ class MediaDockManager(object):
""" """
Add a MediaManagerItem to the dock Add a MediaManagerItem to the dock
``media_item`` :param media_item: The item to add to the dock
The item to add to the dock :param icon: An icon for this dock item
:param weight:
``icon``
An icon for this dock item
""" """
visible_title = media_item.plugin.get_string(StringContent.VisibleName) visible_title = media_item.plugin.get_string(StringContent.VisibleName)
log.info('Adding %s dock' % visible_title) log.info('Adding %s dock' % visible_title)
@ -80,8 +78,7 @@ class MediaDockManager(object):
""" """
Removes a MediaManagerItem from the dock Removes a MediaManagerItem from the dock
``media_item`` :param media_item: The item to add to the dock
The item to add to the dock
""" """
visible_title = media_item.plugin.get_string(StringContent.VisibleName) visible_title = media_item.plugin.get_string(StringContent.VisibleName)
log.debug('remove %s dock' % visible_title['title']) log.debug('remove %s dock' % visible_title['title'])

View File

@ -34,14 +34,14 @@ import os
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, translate from openlp.core.common import RegistryProperties, translate
from openlp.core.lib import PluginStatus from openlp.core.lib import PluginStatus
from .plugindialog import Ui_PluginViewDialog from .plugindialog import Ui_PluginViewDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): class PluginForm(QtGui.QDialog, Ui_PluginViewDialog, RegistryProperties):
""" """
The plugin form provides user control over the plugins OpenLP uses. The plugin form provides user control over the plugins OpenLP uses.
""" """
@ -155,27 +155,3 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
status_text = translate('OpenLP.PluginForm', '%s (Disabled)') status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
self.plugin_list_widget.currentItem().setText( self.plugin_list_widget.currentItem().setText(
status_text % self.active_plugin.name_strings['singular']) status_text % self.active_plugin.name_strings['singular'])
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -36,7 +36,7 @@ import lxml.html
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate
from openlp.core.lib import get_text_file_string from openlp.core.lib import get_text_file_string
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
from openlp.core.common import AppLocation from openlp.core.common import AppLocation
@ -111,7 +111,7 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties
""" """
class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties):
""" """
The :class:`~openlp.core.ui.printserviceform.PrintServiceForm` class displays a dialog for printing the service. The :class:`~openlp.core.ui.printserviceform.PrintServiceForm` class displays a dialog for printing the service.
""" """
@ -239,23 +239,14 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
def _add_element(self, tag, text=None, parent=None, classId=None, attribute=None): def _add_element(self, tag, text=None, parent=None, classId=None, attribute=None):
""" """
Creates a html element. If ``text`` is given, the element's text will Creates a html element. If ``text`` is given, the element's text will set and if a ``parent`` is given,
set and if a ``parent`` is given, the element is appended. the element is appended.
``tag`` :param tag: The html tag, e. g. ``u'span'``. Defaults to ``None``.
The html tag, e. g. ``u'span'``. Defaults to ``None``. :param text: The text for the tag. Defaults to ``None``.
:param parent: The parent element. Defaults to ``None``.
``text`` :param classId: Value for the class attribute
The text for the tag. Defaults to ``None``. :param attribute: Tuple name/value pair to add as an optional attribute
``parent``
The parent element. Defaults to ``None``.
``classId``
Value for the class attribute
``attribute``
Tuple name/value pair to add as an optional attribute
""" """
if text is not None: if text is not None:
element = lxml.html.fragment_fromstring(str(text), create_parent=tag) element = lxml.html.fragment_fromstring(str(text), create_parent=tag)
@ -404,23 +395,3 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
for item in self.service_manager.service_items: for item in self.service_manager.service_items:
# Trigger Audit requests # Trigger Audit requests
Registry().register_function('print_service_started', [item['service_item']]) Registry().register_function('print_service_started', [item['service_item']])
def _get_service_manager(self):
"""
Adds the service manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -30,12 +30,12 @@
The service item edit dialog The service item edit dialog
""" """
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry from openlp.core.common import Registry, RegistryProperties
from .serviceitemeditdialog import Ui_ServiceItemEditDialog from .serviceitemeditdialog import Ui_ServiceItemEditDialog
class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog, RegistryProperties):
""" """
This is the form that is used to edit the verses of the song. This is the form that is used to edit the verses of the song.
""" """
@ -131,8 +131,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
""" """
Called when the currentRow has changed. Called when the currentRow has changed.
``row`` :param row: The row number (int).
The row number (int).
""" """
# Disable all buttons, as no row is selected or only one image is left. # Disable all buttons, as no row is selected or only one image is left.
if row == -1 or self.list_widget.count() == 1: if row == -1 or self.list_widget.count() == 1:
@ -151,14 +150,3 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
else: else:
self.up_button.setEnabled(True) self.up_button.setEnabled(True)
self.delete_button.setEnabled(True) self.delete_button.setEnabled(True)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -39,8 +39,8 @@ from datetime import datetime, timedelta
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, ThemeLevel, OpenLPMixin, RegistryMixin, \ from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, ThemeLevel, OpenLPMixin, \
check_directory_exists, UiStrings, translate RegistryMixin, check_directory_exists, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, PluginStatus, build_icon from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, PluginStatus, build_icon
from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
@ -306,7 +306,7 @@ class Ui_ServiceManager(object):
event.accept() event.accept()
class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManager): class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManager, RegistryProperties):
""" """
Manages the services. This involves taking text strings from plugins and adding them to the service. This service Manages the services. This involves taking text strings from plugins and adding them to the service. This service
can then be zipped up with all the resources used into one OSZ or oszl file for use on any OpenLP v2 installation. can then be zipped up with all the resources used into one OSZ or oszl file for use on any OpenLP v2 installation.
@ -1640,67 +1640,3 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
""" """
setting_dialog = PrintServiceForm() setting_dialog = PrintServiceForm()
setting_dialog.exec_() setting_dialog.exec_()
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)
def _get_preview_controller(self):
"""
Adds the preview controller to the class dynamically
"""
if not hasattr(self, '_preview_controller'):
self._preview_controller = Registry().get('preview_controller')
return self._preview_controller
preview_controller = property(_get_preview_controller)
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -31,12 +31,12 @@ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm`
""" """
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, translate from openlp.core.common import Registry, RegistryProperties, translate
from openlp.core.lib import SpellTextEdit from openlp.core.lib import SpellTextEdit
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class ServiceNoteForm(QtGui.QDialog): class ServiceNoteForm(QtGui.QDialog, RegistryProperties):
""" """
This is the form that is used to edit the verses of the song. This is the form that is used to edit the verses of the song.
""" """
@ -75,13 +75,3 @@ class ServiceNoteForm(QtGui.QDialog):
Translate the UI on the fly Translate the UI on the fly
""" """
self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -33,7 +33,7 @@ import logging
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry from openlp.core.common import Registry, RegistryProperties
from openlp.core.lib import PluginStatus, build_icon from openlp.core.lib import PluginStatus, build_icon
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
from openlp.core.ui.media import PlayerTab from openlp.core.ui.media import PlayerTab
@ -42,7 +42,7 @@ from .settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties):
""" """
Provide the form to manipulate the settings for OpenLP Provide the form to manipulate the settings for OpenLP
""" """
@ -148,38 +148,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
""" """
Register for updates to be done on save removing duplicate functions Register for updates to be done on save removing duplicate functions
``function`` :param function: The function to be called
The function to be called
""" """
if not function in self.processes: if not function in self.processes:
self.processes.append(function) self.processes.append(function)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_service_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)

View File

@ -33,7 +33,7 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, Settings, translate from openlp.core.common import RegistryProperties, Settings, translate
from openlp.core.utils.actions import ActionList from openlp.core.utils.actions import ActionList
from .shortcutlistdialog import Ui_ShortcutListDialog from .shortcutlistdialog import Ui_ShortcutListDialog
@ -42,7 +42,7 @@ REMOVE_AMPERSAND = re.compile(r'&{1}')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties):
""" """
The shortcut list dialog The shortcut list dialog
""" """
@ -397,11 +397,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
Checks if the given ``changing_action `` can use the given ``key_sequence``. Returns ``True`` if the Checks if the given ``changing_action `` can use the given ``key_sequence``. Returns ``True`` if the
``key_sequence`` can be used by the action, otherwise displays a dialog and returns ``False``. ``key_sequence`` can be used by the action, otherwise displays a dialog and returns ``False``.
``changing_action`` :param changing_action: The action which wants to use the ``key_sequence``.
The action which wants to use the ``key_sequence``. :param key_sequence: The key sequence which the action want so use.
``key_sequence``
The key sequence which the action want so use.
""" """
is_valid = True is_valid = True
for category in self.action_list.categories: for category in self.action_list.categories:
@ -462,14 +459,3 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
button.setChecked(checked) button.setChecked(checked)
if enabled is not None: if enabled is not None:
button.setEnabled(enabled) button.setEnabled(enabled)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -33,11 +33,11 @@ from PyQt4 import QtGui
from .starttimedialog import Ui_StartTimeDialog from .starttimedialog import Ui_StartTimeDialog
from openlp.core.common import Registry, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, UiStrings, translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties):
""" """
The start time dialog The start time dialog
""" """
@ -88,20 +88,10 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
def _time_split(self, seconds): def _time_split(self, seconds):
""" """
Split time up into hours minutes and seconds from secongs Split time up into hours minutes and seconds from seconds
""" """
hours = seconds // 3600 hours = seconds // 3600
seconds -= 3600 * hours seconds -= 3600 * hours
minutes = seconds // 60 minutes = seconds // 60
seconds -= 60 * minutes seconds -= 60 * minutes
return hours, minutes, seconds return hours, minutes, seconds
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -34,7 +34,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, UiStrings, translate
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui import ThemeLayoutForm from openlp.core.ui import ThemeLayoutForm
@ -44,7 +44,7 @@ from .themewizard import Ui_ThemeWizard
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties):
""" """
This is the Theme Import Wizard, which allows easy creation and editing of This is the Theme Import Wizard, which allows easy creation and editing of
OpenLP themes. OpenLP themes.
@ -55,8 +55,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
""" """
Instantiate the wizard, and run any extra setup we need to. Instantiate the wizard, and run any extra setup we need to.
``parent`` :param parent: The QWidget-derived parent of the wizard.
The QWidget-derived parent of the wizard.
""" """
super(ThemeForm, self).__init__(parent) super(ThemeForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
@ -542,23 +541,3 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
if new_color.isValid(): if new_color.isValid():
field = new_color.name() field = new_color.name()
return field return field
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager'):
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -36,8 +36,8 @@ import shutil
from xml.etree.ElementTree import ElementTree, XML from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, OpenLPMixin, RegistryMixin, check_directory_exists, \ from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, OpenLPMixin, RegistryMixin, \
UiStrings, translate check_directory_exists, UiStrings, translate
from openlp.core.lib import FileDialog, ImageSource, OpenLPToolbar, get_text_file_string, build_icon, \ from openlp.core.lib import FileDialog, ImageSource, OpenLPToolbar, get_text_file_string, build_icon, \
check_item_selected, create_thumb, validate_thumb check_item_selected, create_thumb, validate_thumb
from openlp.core.lib.theme import ThemeXML, BackgroundType from openlp.core.lib.theme import ThemeXML, BackgroundType
@ -127,7 +127,7 @@ class Ui_ThemeManager(object):
self.theme_list_widget.currentItemChanged.connect(self.check_list_state) self.theme_list_widget.currentItemChanged.connect(self.check_list_state)
class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager): class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, RegistryProperties):
""" """
Manages the orders of Theme. Manages the orders of Theme.
""" """
@ -754,57 +754,3 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager):
return False return False
return True return True
return False return False
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_renderer'):
self._renderer = Registry().get('renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)
def _get_plugin_manager(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -186,8 +186,7 @@ class ThemesTab(SettingsTab):
""" """
Called from ThemeManager when the Themes have changed. Called from ThemeManager when the Themes have changed.
``theme_list`` :param theme_list: The list of available themes::
The list of available themes::
[u'Bible Theme', u'Song Theme'] [u'Bible Theme', u'Song Theme']
""" """

View File

@ -34,7 +34,7 @@ import os
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate
from openlp.core.lib import build_icon from openlp.core.lib import build_icon
from openlp.core.lib.ui import add_welcome_page from openlp.core.lib.ui import add_welcome_page
@ -64,15 +64,15 @@ class WizardStrings(object):
PercentSymbolFormat = translate('OpenLP.Ui', '%p%') PercentSymbolFormat = translate('OpenLP.Ui', '%p%')
Ready = translate('OpenLP.Ui', 'Ready.') Ready = translate('OpenLP.Ui', 'Ready.')
StartingImport = translate('OpenLP.Ui', 'Starting import...') StartingImport = translate('OpenLP.Ui', 'Starting import...')
YouSpecifyFile = translate('OpenLP.Ui', 'You need to specify one ' YouSpecifyFile = translate('OpenLP.Ui', 'You need to specify one %s file to import from.',
'%s file to import from.', 'A file type e.g. OpenSong') 'A file type e.g. OpenSong')
YouSpecifyFiles = translate('OpenLP.Ui', 'You need to specify at ' YouSpecifyFiles = translate('OpenLP.Ui', 'You need to specify at least one %s file to import from.',
'least one %s file to import from.', 'A file type e.g. OpenSong') 'A file type e.g. OpenSong')
YouSpecifyFolder = translate('OpenLP.Ui', 'You need to specify one ' YouSpecifyFolder = translate('OpenLP.Ui', 'You need to specify one %s folder to import from.',
'%s folder to import from.', 'A song format e.g. PowerSong') 'A song format e.g. PowerSong')
class OpenLPWizard(QtGui.QWizard): class OpenLPWizard(QtGui.QWizard, RegistryProperties):
""" """
Generic OpenLP wizard to provide generic functionality and a unified look Generic OpenLP wizard to provide generic functionality and a unified look
and feel. and feel.
@ -209,18 +209,18 @@ class OpenLPWizard(QtGui.QWizard):
Registry().execute('openlp_stop_wizard') Registry().execute('openlp_stop_wizard')
self.done(QtGui.QDialog.Rejected) self.done(QtGui.QDialog.Rejected)
def on_current_id_changed(self, pageId): def on_current_id_changed(self, page_id):
""" """
Perform necessary functions depending on which wizard page is active. Perform necessary functions depending on which wizard page is active.
""" """
if self.with_progress_page and self.page(pageId) == self.progress_page: if self.with_progress_page and self.page(page_id) == self.progress_page:
self.pre_wizard() self.pre_wizard()
self.perform_wizard() self.perform_wizard()
self.post_wizard() self.post_wizard()
else: else:
self.custom_page_changed(pageId) self.custom_page_changed(page_id)
def custom_page_changed(self, pageId): def custom_page_changed(self, page_id):
""" """
Called when changing to a page other than the progress page Called when changing to a page other than the progress page
""" """
@ -242,11 +242,8 @@ class OpenLPWizard(QtGui.QWizard):
""" """
Update the wizard progress page. Update the wizard progress page.
``status_text`` :param status_text: Current status information to display.
Current status information to display. :param increment: The value to increment the progress bar by.
``increment``
The value to increment the progress bar by.
""" """
log.debug('IncrementBar %s', status_text) log.debug('IncrementBar %s', status_text)
self.progress_label.setText(status_text) self.progress_label.setText(status_text)
@ -276,17 +273,10 @@ class OpenLPWizard(QtGui.QWizard):
""" """
Opens a QFileDialog and saves the filename to the given editbox. Opens a QFileDialog and saves the filename to the given editbox.
``title`` :param title: The title of the dialog (unicode).
The title of the dialog (unicode). :param editbox: An editbox (QLineEdit).
:param setting_name: The place where to save the last opened directory.
``editbox`` :param filters: The file extension filters. It should contain the file description
An editbox (QLineEdit).
``setting_name``
The place where to save the last opened directory.
``filters``
The file extension filters. It should contain the file description
as well as the file extension. For example:: as well as the file extension. For example::
u'OpenLP 2.0 Databases (*.sqlite)' u'OpenLP 2.0 Databases (*.sqlite)'
@ -304,14 +294,9 @@ class OpenLPWizard(QtGui.QWizard):
""" """
Opens a QFileDialog and saves the selected folder to the given editbox. Opens a QFileDialog and saves the selected folder to the given editbox.
``title`` :param title: The title of the dialog (unicode).
The title of the dialog (unicode). :param editbox: An editbox (QLineEdit).
:param setting_name: The place where to save the last opened directory.
``editbox``
An editbox (QLineEdit).
``setting_name``
The place where to save the last opened directory.
""" """
folder = QtGui.QFileDialog.getExistingDirectory( folder = QtGui.QFileDialog.getExistingDirectory(
self, title, Settings().value(self.plugin.settings_section + '/' + setting_name), self, title, Settings().value(self.plugin.settings_section + '/' + setting_name),
@ -319,17 +304,3 @@ class OpenLPWizard(QtGui.QWizard):
if folder: if folder:
editbox.setText(folder) editbox.setText(folder)
Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -179,8 +179,7 @@ def check_latest_version(current_version):
Check the latest version of OpenLP against the version file on the OpenLP Check the latest version of OpenLP against the version file on the OpenLP
site. site.
``current_version`` :param current_version: The current version of OpenLP.
The current version of OpenLP.
**Rules around versions and version files:** **Rules around versions and version files:**
@ -222,11 +221,8 @@ def add_actions(target, actions):
""" """
Adds multiple actions to a menu or toolbar in one command. Adds multiple actions to a menu or toolbar in one command.
``target`` :param target: The menu or toolbar to add actions to
The menu or toolbar to add actions to. :param actions: The actions to be added. An action consisting of the keyword ``None``
``actions``
The actions to be added. An action consisting of the keyword ``None``
will result in a separator being inserted into the target. will result in a separator being inserted into the target.
""" """
for action in actions: for action in actions:
@ -264,8 +260,7 @@ def is_not_image_file(file_name):
""" """
Validate that the file is not an image file. Validate that the file is not an image file.
``file_name`` :param file_name: File name to be checked.
File name to be checked.
""" """
if not file_name: if not file_name:
return True return True
@ -292,8 +287,7 @@ def clean_filename(filename):
""" """
Removes invalid characters from the given ``filename``. Removes invalid characters from the given ``filename``.
``filename`` :param filename: The "dirty" file name to clean.
The "dirty" file name to clean.
""" """
if not isinstance(filename, str): if not isinstance(filename, str):
filename = str(filename, 'utf-8') filename = str(filename, 'utf-8')
@ -304,8 +298,7 @@ def delete_file(file_path_name):
""" """
Deletes a file from the system. Deletes a file from the system.
``file_path_name`` :param file_path_name: The file, including path, to delete.
The file, including path, to delete.
""" """
if not file_path_name: if not file_path_name:
return False return False
@ -333,14 +326,9 @@ def get_web_page(url, header=None, update_openlp=False):
""" """
Attempts to download the webpage at url and returns that page or None. Attempts to download the webpage at url and returns that page or None.
``url`` :param url: The URL to be downloaded.
The URL to be downloaded. :param header: An optional HTTP header to pass in the request to the web server.
:param update_openlp: Tells OpenLP to update itself if the page is successfully downloaded.
``header``
An optional HTTP header to pass in the request to the web server.
``update_openlp``
Tells OpenLP to update itself if the page is successfully downloaded.
Defaults to False. Defaults to False.
""" """
# TODO: Add proxy usage. Get proxy info from OpenLP settings, add to a # TODO: Add proxy usage. Get proxy info from OpenLP settings, add to a
@ -386,8 +374,7 @@ def get_uno_instance(resolver):
""" """
Returns a running openoffice.org instance. Returns a running openoffice.org instance.
``resolver`` :param resolver: The UNO resolver to use to find a running instance.
The UNO resolver to use to find a running instance.
""" """
log.debug('get UNO Desktop Openoffice - resolve') log.debug('get UNO Desktop Openoffice - resolve')
if UNO_CONNECTION_TYPE == 'pipe': if UNO_CONNECTION_TYPE == 'pipe':
@ -404,11 +391,8 @@ def format_time(text, local_time):
unicode string and passes individual % placeholders to time.strftime(). unicode string and passes individual % placeholders to time.strftime().
This ensures only ascii characters are passed to time.strftime(). This ensures only ascii characters are passed to time.strftime().
``text`` :param text: The text to be processed.
The text to be processed. :param local_time: The time to be used to add to the string. This is a time object
``local_time``
The time to be used to add to the string. This is a time object
""" """
def match_formatting(match): def match_formatting(match):
""" """
@ -422,8 +406,7 @@ def get_locale_key(string):
""" """
Creates a key for case insensitive, locale aware string sorting. Creates a key for case insensitive, locale aware string sorting.
``string`` :param string: The corresponding string.
The corresponding string.
""" """
string = string.lower() string = string.lower()
# ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases. # ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases.
@ -439,6 +422,7 @@ def get_locale_key(string):
except: except:
return locale.strxfrm(string).encode() return locale.strxfrm(string).encode()
def get_natural_key(string): def get_natural_key(string):
""" """
Generate a key for locale aware natural string sorting. Generate a key for locale aware natural string sorting.

View File

@ -258,17 +258,12 @@ class ActionList(object):
**Note**: The action's objectName must be set when you want to add it! **Note**: The action's objectName must be set when you want to add it!
``action`` :param action: The action to add (QAction). **Note**, the action must not have an empty ``objectName``.
The action to add (QAction). **Note**, the action must not have an empty ``objectName``. :param category: The category this action belongs to. The category has to be a python string. . **Note**,
if the category is ``None``, the category and its actions are being hidden in the shortcut dialog. However,
``category`` if they are added, it is possible to avoid assigning shortcuts twice, which is important.
The category this action belongs to. The category has to be a python string. . **Note**, if the category :param weight: The weight specifies how important a category is. However, this only has an impact on the order
is ``None``, the category and its actions are being hidden in the shortcut dialog. However, if they are the categories are displayed.
added, it is possible to avoid assigning shortcuts twice, which is important.
``weight``
The weight specifies how important a category is. However, this only has an impact on the order the
categories are displayed.
""" """
if category not in self.categories: if category not in self.categories:
self.categories.append(category) self.categories.append(category)
@ -319,11 +314,8 @@ class ActionList(object):
""" """
This removes an action from its category. Empty categories are automatically removed. This removes an action from its category. Empty categories are automatically removed.
``action`` :param action: The ``QAction`` object to be removed.
The ``QAction`` object to be removed. :param category: The name (unicode string) of the category, which contains the action. Defaults to None.
``category``
The name (unicode string) of the category, which contains the action. Defaults to None.
""" """
if category not in self.categories: if category not in self.categories:
return return
@ -343,11 +335,8 @@ class ActionList(object):
""" """
Add an empty category to the list of categories. This is only convenient for categories with a given weight. Add an empty category to the list of categories. This is only convenient for categories with a given weight.
``name`` :param name: The category's name.
The category's name. :param weight: The category's weight (int).
``weight``
The category's weight (int).
""" """
if name in self.categories: if name in self.categories:
# Only change the weight and resort the categories again. # Only change the weight and resort the categories again.
@ -361,15 +350,11 @@ class ActionList(object):
def update_shortcut_map(self, action, old_shortcuts): def update_shortcut_map(self, action, old_shortcuts):
""" """
Remove the action for the given ``old_shortcuts`` from the ``shortcut_map`` to ensure its up-to-dateness. Remove the action for the given ``old_shortcuts`` from the ``shortcut_map`` to ensure its up-to-dateness.
**Note**: The new action's shortcuts **must** be assigned to the given ``action`` **before** calling this **Note**: The new action's shortcuts **must** be assigned to the given ``action`` **before** calling this
method. method.
``action`` :param action: The action whose shortcuts are supposed to be updated in the ``shortcut_map``.
The action whose shortcuts are supposed to be updated in the ``shortcut_map``. :param old_shortcuts: A list of unicode key sequences.
``old_shortcuts``
A list of unicode keysequences.
""" """
for old_shortcut in old_shortcuts: for old_shortcut in old_shortcuts:
# Remove action from the list of actions which are using this shortcut. # Remove action from the list of actions which are using this shortcut.
@ -388,11 +373,8 @@ class ActionList(object):
""" """
Checks if the given ``action`` may use its assigned shortcut(s) or not. Returns ``True`` or ``False. Checks if the given ``action`` may use its assigned shortcut(s) or not. Returns ``True`` or ``False.
``existing_actions`` :param existing_actions: A list of actions which already use a particular shortcut.
A list of actions which already use a particular shortcut. :param action: The action which wants to use a particular shortcut.
``action``
The action which wants to use a particular shortcut.
""" """
global_context = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] global_context = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]
affected_actions = [] affected_actions = []

View File

@ -52,8 +52,7 @@ class LanguageManager(object):
""" """
Set up a translator to use in this instance of OpenLP Set up a translator to use in this instance of OpenLP
``language`` :param language: The language to load into the translator
The language to load into the translator
""" """
if LanguageManager.auto_language: if LanguageManager.auto_language:
language = QtCore.QLocale.system().name() language = QtCore.QLocale.system().name()
@ -85,8 +84,7 @@ class LanguageManager(object):
""" """
Load the language name from a language file Load the language name from a language file
``qm_file`` :param qm_file: The file to obtain the name from
The file to obtain the name from
""" """
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
translator.load(qm_file) translator.load(qm_file)
@ -110,11 +108,8 @@ class LanguageManager(object):
""" """
Set the language to translate OpenLP into Set the language to translate OpenLP into
``action`` :param action: The language menu option
The language menu option :param message: Display the message option
``message``
Display the message option
""" """
language = 'en' language = 'en'
if action: if action:

View File

@ -140,7 +140,7 @@ class AlertsPlugin(Plugin):
self.weight = -3 self.weight = -3
self.icon_path = ':/plugins/plugin_alerts.png' self.icon_path = ':/plugins/plugin_alerts.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.alerts_manager = AlertsManager(self) AlertsManager(self)
self.manager = Manager('alerts', init_schema) self.manager = Manager('alerts', init_schema)
self.alert_form = AlertForm(self) self.alert_form = AlertForm(self)

View File

@ -33,10 +33,10 @@ displaying of alerts.
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, translate from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, translate
class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject): class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties):
""" """
AlertsManager manages the settings of Alerts. AlertsManager manages the settings of Alerts.
""" """
@ -98,23 +98,3 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject):
self.killTimer(self.timer_id) self.killTimer(self.timer_id)
self.timer_id = 0 self.timer_id = 0
self.generate_alert() self.generate_alert()
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -136,8 +136,7 @@ class BiblePlugin(Plugin):
""" """
Give the bible plugin the opportunity to add items to the **Tools** menu. Give the bible plugin the opportunity to add items to the **Tools** menu.
``tools_menu`` :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
The actual **Tools** menu item, so that your actions can use it as their parent.
""" """
log.debug('add tools menu') log.debug('add tools menu')
self.tools_upgrade_item = create_action( self.tools_upgrade_item = create_action(

View File

@ -67,14 +67,9 @@ class BibleImportForm(OpenLPWizard):
""" """
Instantiate the wizard, and run any extra setup we need to. Instantiate the wizard, and run any extra setup we need to.
``parent`` :param parent: The QWidget-derived parent of the wizard.
The QWidget-derived parent of the wizard. :param manager: The Bible manager.
:param bible_plugin: The Bible plugin.
``manager``
The Bible manager.
``bible_plugin``
The Bible plugin.
""" """
self.manager = manager self.manager = manager
self.web_bible_list = {} self.web_bible_list = {}

View File

@ -57,14 +57,9 @@ class BibleUpgradeForm(OpenLPWizard):
""" """
Instantiate the wizard, and run any extra setup we need to. Instantiate the wizard, and run any extra setup we need to.
``parent`` :param parent: The QWidget-derived parent of the wizard.
The QWidget-derived parent of the wizard. :param manager: The Bible manager.
:param bible_plugin: The Bible plugin.
``manager``
The Bible manager.
``bible_plugin``
The Bible plugin.
""" """
self.manager = manager self.manager = manager
self.media_item = bible_plugin.media_item self.media_item = bible_plugin.media_item

View File

@ -33,7 +33,7 @@ import re
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, UiStrings, translate from openlp.core.common import RegistryProperties, UiStrings, translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from .editbibledialog import Ui_EditBibleDialog from .editbibledialog import Ui_EditBibleDialog
from openlp.plugins.bibles.lib import BibleStrings from openlp.plugins.bibles.lib import BibleStrings
@ -41,7 +41,8 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties):
""" """
Class to manage the editing of a bible Class to manage the editing of a bible
""" """
@ -57,12 +58,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
self.setupUi(self) self.setupUi(self)
self.manager = manager self.manager = manager
def loadBible(self, bible): def load_bible(self, bible):
""" """
Loads a bible. Loads a bible.
``bible`` ``bible``
The name of the bible.
:param bible: The name of the bible.
""" """
log.debug('Load Bible') log.debug('Load Bible')
self.bible = bible self.bible = bible
@ -73,18 +75,20 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if book_name_language and book_name_language.value != 'None': if book_name_language and book_name_language.value != 'None':
self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1) self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
self.books = {} self.books = {}
self.webbible = self.manager.get_meta_data(self.bible, 'download_source') self.web_bible = self.manager.get_meta_data(self.bible, 'download_source')
if self.webbible: if self.web_bible:
self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm', self.book_name_notice.setText(
translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to customize the Book Names.')) 'This is a Web Download Bible.\nIt is not possible to customize the Book Names.'))
self.scroll_area.hide() self.scroll_area.hide()
else: else:
self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm', self.book_name_notice.setText(
'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, ' translate('BiblesPlugin.EditBibleForm',
'if "Global settings" is selected, on the Bible page in Configure OpenLP.')) 'To use the customized book names, "Bible language" must be selected on the Meta Data tab '
'or, if "Global settings" is selected, on the Bible page in Configure OpenLP.'))
for book in BiblesResourcesDB.get_books(): for book in BiblesResourcesDB.get_books():
self.books[book['abbreviation']] = self.manager.get_book_by_id(self.bible, book['id']) self.books[book['abbreviation']] = self.manager.get_book_by_id(self.bible, book['id'])
if self.books[book['abbreviation']] and not self.webbible: if self.books[book['abbreviation']] and not self.web_bible:
self.book_name_edit[book['abbreviation']].setText(self.books[book['abbreviation']].name) self.book_name_edit[book['abbreviation']].setText(self.books[book['abbreviation']].name)
else: else:
# It is necessary to remove the Widget otherwise there still # It is necessary to remove the Widget otherwise there still
@ -113,19 +117,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
book_name_language = self.language_selection_combo_box.currentIndex() - 1 book_name_language = self.language_selection_combo_box.currentIndex() - 1
if book_name_language == -1: if book_name_language == -1:
book_name_language = None book_name_language = None
if not self.validateMeta(version, copyright): if not self.validate_meta(version, copyright):
return return
if not self.webbible: if not self.web_bible:
custom_names = {} custom_names = {}
for abbr, book in self.books.items(): for abbr, book in self.books.items():
if book: if book:
custom_names[abbr] = self.book_name_edit[abbr].text() custom_names[abbr] = self.book_name_edit[abbr].text()
if book.name != custom_names[abbr]: if book.name != custom_names[abbr]:
if not self.validateBook(custom_names[abbr], abbr): if not self.validate_book(custom_names[abbr], abbr):
return return
self.application.set_busy_cursor() self.application.set_busy_cursor()
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language) self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
if not self.webbible: if not self.web_bible:
for abbr, book in self.books.items(): for abbr, book in self.books.items():
if book: if book:
if book.name != custom_names[abbr]: if book.name != custom_names[abbr]:
@ -135,44 +139,49 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
self.application.set_normal_cursor() self.application.set_normal_cursor()
QtGui.QDialog.accept(self) QtGui.QDialog.accept(self)
def validateMeta(self, name, copyright): def validate_meta(self, name, copyright):
""" """
Validate the Meta before saving. Validate the Meta before saving.
""" """
if not name: if not name:
self.version_name_edit.setFocus() self.version_name_edit.setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(
UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.')) translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.'))
return False return False
elif not copyright: elif not copyright:
self.copyright_edit.setFocus() self.copyright_edit.setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(
UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', translate('BiblesPlugin.BibleEditForm',
'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.')) 'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked '
'as such.'))
return False return False
elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, 'name').value != \ elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, 'name').value != name:
name:
self.version_name_edit.setFocus() self.version_name_edit.setFocus()
critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'), critical_error_message_box(
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import ' translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import '
'a different Bible or first delete the existing one.')) 'a different Bible or first delete the existing one.'))
return False return False
return True return True
def validateBook(self, new_book_name, abbreviation): def validate_book(self, new_book_name, abbreviation):
""" """
Validate a book. Validate a book.
""" """
book_regex = re.compile('[\d]*[^\d]+$') book_regex = re.compile('[\d]*[^\d]+$')
if not new_book_name: if not new_book_name:
self.book_name_edit[abbreviation].setFocus() self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(
UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') %
self.book_names[abbreviation]) self.book_names[abbreviation])
return False return False
elif not book_regex.match(new_book_name): elif not book_regex.match(new_book_name):
self.book_name_edit[abbreviation].setFocus() self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(
UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', translate('BiblesPlugin.BibleEditForm',
'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe ' 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe '
'followed by one or more non-numeric characters.') % new_book_name) 'followed by one or more non-numeric characters.') % new_book_name)
@ -189,17 +198,3 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
% new_book_name) % new_book_name)
return False return False
return True return True
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, Table, or_, types, func
from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm import class_mapper, mapper, relation
from sqlalchemy.orm.exc import UnmappedClassError from sqlalchemy.orm.exc import UnmappedClassError
from openlp.core.common import Registry, AppLocation, translate from openlp.core.common import Registry, RegistryProperties, AppLocation, translate
from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.db import BaseModel, init_db, Manager
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.utils import clean_filename from openlp.core.utils import clean_filename
@ -74,8 +74,7 @@ def init_schema(url):
""" """
Setup a bible database connection and initialise the database schema. Setup a bible database connection and initialise the database schema.
``url`` :param url: The database to setup.
The database to setup.
""" """
session, metadata = init_db(url) session, metadata = init_db(url)
@ -116,7 +115,7 @@ def init_schema(url):
return session return session
class BibleDB(QtCore.QObject, Manager): class BibleDB(QtCore.QObject, Manager, RegistryProperties):
""" """
This class represents a database-bound Bible. It is used as a base class for all the custom importers, so that This class represents a database-bound Bible. It is used as a base class for all the custom importers, so that
the can implement their own import methods, but benefit from the database methods in here via inheritance, the can implement their own import methods, but benefit from the database methods in here via inheritance,
@ -501,20 +500,6 @@ class BibleDB(QtCore.QObject, Manager):
verses = self.session.query(Verse).all() verses = self.session.query(Verse).all()
log.debug(verses) log.debug(verses)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)
class BiblesResourcesDB(QtCore.QObject, Manager): class BiblesResourcesDB(QtCore.QObject, Manager):
""" """
@ -725,9 +710,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
@staticmethod @staticmethod
def get_webbibles(source): def get_webbibles(source):
""" """
Return the bibles a webbible provide for download. Return the bibles a web_bible provide for download.
:param source: The source of the webbible. :param source: The source of the web_bible.
""" """
log.debug('BiblesResourcesDB.get_webbibles("%s")', source) log.debug('BiblesResourcesDB.get_webbibles("%s")', source)
if not isinstance(source, str): if not isinstance(source, str):
@ -749,10 +734,10 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
@staticmethod @staticmethod
def get_webbible(abbreviation, source): def get_webbible(abbreviation, source):
""" """
Return the bibles a webbible provide for download. Return the bibles a web_bible provide for download.
:param abbreviation: The abbreviation of the webbible. :param abbreviation: The abbreviation of the web_bible.
:param source: The source of the webbible. :param source: The source of the web_bible.
""" """
log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source) log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source)
if not isinstance(abbreviation, str): if not isinstance(abbreviation, str):

View File

@ -29,7 +29,6 @@
""" """
The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. The :mod:`http` module enables OpenLP to retrieve scripture from bible websites.
""" """
import os
import logging import logging
import re import re
import socket import socket
@ -38,7 +37,7 @@ from html.parser import HTMLParseError
from bs4 import BeautifulSoup, NavigableString, Tag from bs4 import BeautifulSoup, NavigableString, Tag
from openlp.core.common import Registry, translate from openlp.core.common import Registry, RegistryProperties, translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.utils import get_web_page from openlp.core.utils import get_web_page
from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib import SearchResults
@ -61,7 +60,7 @@ VERSE_NUMBER_REGEX = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class BGExtract(object): class BGExtract(RegistryProperties):
""" """
Extract verses from BibleGateway Extract verses from BibleGateway
""" """
@ -285,22 +284,8 @@ class BGExtract(object):
books.append(book.contents[0]) books.append(book.contents[0])
return books return books
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application) class BSExtract(RegistryProperties):
class BSExtract(object):
""" """
Extract verses from Bibleserver.com Extract verses from Bibleserver.com
""" """
@ -359,22 +344,8 @@ class BSExtract(object):
content = content.find_all('li') content = content.find_all('li')
return [book.contents[0].contents[0] for book in content if len(book.contents[0].contents)] return [book.contents[0].contents[0] for book in content if len(book.contents[0].contents)]
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application) class CWExtract(RegistryProperties):
class CWExtract(object):
""" """
Extract verses from CrossWalk/BibleStudyTools Extract verses from CrossWalk/BibleStudyTools
""" """
@ -457,22 +428,8 @@ class CWExtract(object):
books.append(book.contents[0]) books.append(book.contents[0])
return books return books
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application) class HTTPBible(BibleDB, RegistryProperties):
class HTTPBible(BibleDB):
log.info('%s HTTPBible loaded', __name__) log.info('%s HTTPBible loaded', __name__)
def __init__(self, parent, **kwargs): def __init__(self, parent, **kwargs):
@ -647,20 +604,6 @@ class HTTPBible(BibleDB):
log.debug('HTTPBible.get_verse_count("%s", %s)', book_id, chapter) log.debug('HTTPBible.get_verse_count("%s", %s)', book_id, chapter)
return BiblesResourcesDB.get_verse_count(book_id, chapter) return BiblesResourcesDB.get_verse_count(book_id, chapter)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)
def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None): def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None):
""" """
@ -698,8 +641,7 @@ def send_error_message(error_type):
""" """
Send a standard error message informing the user of an issue. Send a standard error message informing the user of an issue.
``error_type`` :param error_type: The type of error that occurred for the issue.
The type of error that occured for the issue.
""" """
if error_type == 'download': if error_type == 'download':
critical_error_message_box( critical_error_message_box(

View File

@ -30,7 +30,7 @@
import logging import logging
import os import os
from openlp.core.common import Registry, AppLocation, Settings, translate from openlp.core.common import RegistryProperties, AppLocation, Settings, translate
from openlp.core.utils import delete_file from openlp.core.utils import delete_file
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
@ -84,7 +84,7 @@ class BibleFormat(object):
] ]
class BibleManager(object): class BibleManager(RegistryProperties):
""" """
The Bible manager which holds and manages all the Bibles. The Bible manager which holds and manages all the Bibles.
""" """
@ -405,15 +405,4 @@ class BibleManager(object):
for bible in self.db_cache: for bible in self.db_cache:
self.db_cache[bible].finalise() self.db_cache[bible].finalise()
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
__all__ = ['BibleFormat'] __all__ = ['BibleFormat']

View File

@ -475,7 +475,7 @@ class BibleMediaItem(MediaManagerItem):
bible = self.advancedVersionComboBox.currentText() bible = self.advancedVersionComboBox.currentText()
if bible: if bible:
self.edit_bible_form = EditBibleForm(self, self.main_window, self.plugin.manager) self.edit_bible_form = EditBibleForm(self, self.main_window, self.plugin.manager)
self.edit_bible_form.loadBible(bible) self.edit_bible_form.load_bible(bible)
if self.edit_bible_form.exec_(): if self.edit_bible_form.exec_():
self.reload_bibles() self.reload_bibles()

View File

@ -83,14 +83,10 @@ class CustomPlugin(Plugin):
def rename_theme(self, old_theme, new_theme): def rename_theme(self, old_theme, new_theme):
""" """
Renames a theme the custom plugin is using making the plugin use the Renames a theme the custom plugin is using making the plugin use the new name.
new name.
``oldTheme`` :param old_theme: The name of the theme the plugin should stop using.
The name of the theme the plugin should stop using. :param new_theme: The new name the plugin should now use.
``newTheme``
The new name the plugin should now use.
""" """
customs_using_theme = self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == old_theme) customs_using_theme = self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == old_theme)
for custom in customs_using_theme: for custom in customs_using_theme:

View File

@ -127,8 +127,7 @@ class CustomXMLParser(object):
""" """
Set up our custom XML parser. Set up our custom XML parser.
``xml`` :param xml: The XML of the custom to be parsed.
The XML of the custom to be parsed.
""" """
self.custom_xml = None self.custom_xml = None
if xml[:5] == '<?xml': if xml[:5] == '<?xml':
@ -140,8 +139,7 @@ class CustomXMLParser(object):
def get_verses(self): def get_verses(self):
""" """
Iterates through the verses in the XML and returns a list of verses Iterates through the verses in the XML and returns a list of verses and their attributes.
and their attributes.
""" """
xml_iter = self.custom_xml.getiterator() xml_iter = self.custom_xml.getiterator()
verse_list = [] verse_list = []

View File

@ -60,8 +60,7 @@ def init_schema(url):
""" """
Setup the custom database connection and initialise the database schema Setup the custom database connection and initialise the database schema
``url`` :param url: The database to setup
The database to setup
""" """
session, metadata = init_db(url) session, metadata = init_db(url)

View File

@ -41,8 +41,7 @@ class Ui_ChooseGroupDialog(object):
""" """
Set up the UI. Set up the UI.
``choose_group_dialog`` :param choose_group_dialog: The form object (not the class).
The form object (not the class).
""" """
choose_group_dialog.setObjectName('choose_group_dialog') choose_group_dialog.setObjectName('choose_group_dialog')
choose_group_dialog.resize(399, 119) choose_group_dialog.resize(399, 119)
@ -84,8 +83,7 @@ class Ui_ChooseGroupDialog(object):
""" """
Translate the UI on the fly. Translate the UI on the fly.
``choose_group_dialog`` :param choose_group_dialog: The form object (not the class).
The form object (not the class).
""" """
choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Select Image Group')) choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Select Image Group'))
self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm', 'Add images to group:')) self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm', 'Add images to group:'))

View File

@ -47,8 +47,7 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog):
""" """
Show the form Show the form
``selected_group`` :param selected_group: The ID of the group that should be selected by default when showing the dialog.
The ID of the group that should be selected by default when showing the dialog.
""" """
self.new_group_edit.clear() self.new_group_edit.clear()
if selected_group is not None: if selected_group is not None:

View File

@ -84,8 +84,7 @@ class ImagePlugin(Plugin):
""" """
Upgrade the settings of this plugin. Upgrade the settings of this plugin.
``settings`` :param settings: The Settings object containing the old settings.
The Settings object containing the old settings.
""" """
files_from_config = settings.get_files_from_config(self) files_from_config = settings.get_files_from_config(self)
if files_from_config: if files_from_config:
@ -124,13 +123,3 @@ class ImagePlugin(Plugin):
log.info('Images config_update') log.info('Images config_update')
background = QtGui.QColor(Settings().value(self.settings_section + '/background color')) background = QtGui.QColor(Settings().value(self.settings_section + '/background color'))
self.image_manager.update_images_border(ImageSource.ImagePlugin, background) self.image_manager.update_images_border(ImageSource.ImagePlugin, background)
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)

View File

@ -54,9 +54,7 @@ def init_schema(url):
""" """
Setup the images database connection and initialise the database schema. Setup the images database connection and initialise the database schema.
``url`` :param url: The database to setup
The database to setup
The images database contains the following tables: The images database contains the following tables:
* image_groups * image_groups

View File

@ -32,7 +32,8 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, UiStrings,\
translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, ServiceItem, ServiceItemContext, \ from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, ServiceItem, ServiceItemContext, \
build_icon, check_item_selected build_icon, check_item_selected
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
@ -51,7 +52,7 @@ DVD_ICON = build_icon(':/media/media_video.png')
ERROR_ICON = build_icon(':/general/general_delete.png') ERROR_ICON = build_icon(':/general/general_delete.png')
class MediaMediaItem(MediaManagerItem): class MediaMediaItem(MediaManagerItem, RegistryProperties):
""" """
This is the custom media manager item for Media Slides. This is the custom media manager item for Media Slides.
""" """

View File

@ -31,7 +31,7 @@ import logging
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.common import Registry, translate from openlp.core.common import translate
from openlp.core.lib import Plugin, StringContent, build_icon from openlp.core.lib import Plugin, StringContent, build_icon
from openlp.plugins.media.lib import MediaMediaItem, MediaTab from openlp.plugins.media.lib import MediaMediaItem, MediaTab
@ -120,13 +120,3 @@ class MediaPlugin(Plugin):
Add html code to htmlbuilder. Add html code to htmlbuilder.
""" """
return self.media_controller.get_media_display_html() return self.media_controller.get_media_display_html()
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, '_media_controller'):
self._media_controller = Registry().get('media_controller')
return self._media_controller
media_controller = property(_get_media_controller)

View File

@ -218,8 +218,7 @@ class PresentationDocument(object):
""" """
Jumps directly to the requested slide. Jumps directly to the requested slide.
``slide_no`` :param slide_no: The slide to jump to, starting at 1
The slide to jump to, starting at 1
""" """
pass pass
@ -250,8 +249,8 @@ class PresentationDocument(object):
""" """
Returns an image path containing a preview for the requested slide Returns an image path containing a preview for the requested slide
``slide_no`` :param slide_no: The slide an image is required for, starting at 1
The slide an image is required for, starting at 1 :param check_exists:
""" """
path = os.path.join(self.get_thumbnail_folder(), self.controller.thumbnail_prefix + str(slide_no) + '.png') path = os.path.join(self.get_thumbnail_folder(), self.controller.thumbnail_prefix + str(slide_no) + '.png')
if os.path.isfile(path) or not check_exists: if os.path.isfile(path) or not check_exists:
@ -470,17 +469,6 @@ class PresentationController(object):
def close_presentation(self): def close_presentation(self):
pass pass
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
class TextType(object): class TextType(object):
""" """
Type Enumeration for Types of Text to request Type Enumeration for Types of Text to request
@ -488,3 +476,4 @@ class TextType(object):
Title = 0 Title = 0
SlideText = 1 SlideText = 1
Notes = 2 Notes = 2

View File

@ -124,7 +124,7 @@ from urllib.parse import urlparse, parse_qs
from mako.template import Template from mako.template import Template
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.common import Registry, AppLocation, Settings, translate from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate
from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -139,7 +139,7 @@ FILE_TYPES = {
} }
class HttpRouter(object): class HttpRouter(RegistryProperties):
""" """
This code is called by the HttpServer upon a request and it processes it based on the routing table. This code is called by the HttpServer upon a request and it processes it based on the routing table.
This code is stateless and is created on each request. This code is stateless and is created on each request.
@ -209,11 +209,8 @@ class HttpRouter(object):
""" """
Invoke the route function passing the relevant values Invoke the route function passing the relevant values
``function`` :param function: The function to be called.
The function to be calledL. :param args: Any passed data.
``*args``
Any passed data.
""" """
response = function['function'](*args) response = function['function'](*args)
if response: if response:
@ -224,11 +221,8 @@ class HttpRouter(object):
""" """
Common function to process HTTP requests Common function to process HTTP requests
``url_path`` :param url_path: The requested URL.
The requested URL. :param args: Any passed data.
``*args``
Any passed data.
""" """
self.request_data = None self.request_data = None
url_path_split = urlparse(url_path) url_path_split = urlparse(url_path)
@ -381,8 +375,7 @@ class HttpRouter(object):
def get_content_type(self, file_name): def get_content_type(self, file_name):
""" """
Examines the extension of the file and determines Examines the extension of the file and determines what the content_type should be, defaults to text/plain
what the content_type should be, defaults to text/plain
Returns the extension and the content_type Returns the extension and the content_type
""" """
content_type = 'text/plain' content_type = 'text/plain'
@ -463,8 +456,7 @@ class HttpRouter(object):
Hide or show the display screen. Hide or show the display screen.
This is a cross Thread call and UI is updated so Events need to be used. This is a cross Thread call and UI is updated so Events need to be used.
``action`` :param action: This is the action, either ``hide`` or ``show``.
This is the action, either ``hide`` or ``show``.
""" """
self.live_controller.emit(QtCore.SIGNAL('slidecontroller_toggle_display'), action) self.live_controller.emit(QtCore.SIGNAL('slidecontroller_toggle_display'), action)
self.do_json_header() self.do_json_header()
@ -532,11 +524,8 @@ class HttpRouter(object):
""" """
Perform an action on the slide controller. Perform an action on the slide controller.
``display_type`` :param display_type: This is the type of slide controller, either ``preview`` or ``live``.
This is the type of slide controller, either ``preview`` or ``live``. :param action: The action to perform.
``action``
The action to perform.
""" """
event = 'slidecontroller_%s_%s' % (display_type, action) event = 'slidecontroller_%s_%s' % (display_type, action)
if self.request_data: if self.request_data:
@ -557,8 +546,6 @@ class HttpRouter(object):
""" """
Handles requests for service items in the service manager Handles requests for service items in the service manager
``action``
The action to perform.
""" """
self.do_json_header() self.do_json_header()
return json.dumps({'results': {'items': self._get_service_items()}}).encode() return json.dumps({'results': {'items': self._get_service_items()}}).encode()
@ -567,8 +554,7 @@ class HttpRouter(object):
""" """
Handles requests for service items in the service manager Handles requests for service items in the service manager
``action`` :param action: The action to perform.
The action to perform.
""" """
event = 'servicemanager_%s_item' % action event = 'servicemanager_%s_item' % action
if self.request_data: if self.request_data:
@ -586,9 +572,7 @@ class HttpRouter(object):
""" """
Return plugin related information, based on the action. Return plugin related information, based on the action.
``action`` :param action: The action to perform. If *search* return a list of plugin names which support search.
The action to perform. If *search* return a list of plugin names
which support search.
""" """
if action == 'search': if action == 'search':
searches = [] searches = []
@ -602,8 +586,7 @@ class HttpRouter(object):
""" """
Return a list of items that match the search text. Return a list of items that match the search text.
``plugin`` :param plugin_name: The plugin name to search in.
The plugin name to search in.
""" """
try: try:
text = json.loads(self.request_data)['request']['text'] text = json.loads(self.request_data)['request']['text']
@ -645,52 +628,3 @@ class HttpRouter(object):
plugin.media_item.emit(QtCore.SIGNAL('%s_add_to_service' % plugin_name), [item_id, True]) plugin.media_item.emit(QtCore.SIGNAL('%s_add_to_service' % plugin_name), [item_id, True])
self.do_http_success() self.do_http_success()
def _get_service_manager(self):
"""
Adds the service manager to the class dynamically
"""
if not hasattr(self, '_service_manager'):
self._service_manager = Registry().get('service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_live_controller(self):
"""
Adds the live controller to the class dynamically
"""
if not hasattr(self, '_live_controller'):
self._live_controller = Registry().get('live_controller')
return self._live_controller
live_controller = property(_get_live_controller)
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_alerts_manager(self):
"""
Adds the alerts manager to the class dynamically
"""
if not hasattr(self, '_alerts_manager'):
self._alerts_manager = Registry().get('alerts_manager')
return self._alerts_manager
alerts_manager = property(_get_alerts_manager)
def _get_image_manager(self):
"""
Adds the image manager to the class dynamically
"""
if not hasattr(self, '_image_manager'):
self._image_manager = Registry().get('image_manager')
return self._image_manager
image_manager = property(_get_image_manager)

View File

@ -83,8 +83,7 @@ class HttpThread(QtCore.QThread):
""" """
Constructor for the thread class. Constructor for the thread class.
``server`` :param server: The http server class.
The http server class.
""" """
super(HttpThread, self).__init__(None) super(HttpThread, self).__init__(None)
self.http_server = server self.http_server = server

View File

@ -177,14 +177,13 @@ class RemoteTab(SettingsTab):
self.live_url_label.setText(translate('RemotePlugin.RemoteTab', 'Live view URL:')) self.live_url_label.setText(translate('RemotePlugin.RemoteTab', 'Live view URL:'))
self.twelve_hour_check_box.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format')) self.twelve_hour_check_box.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format'))
self.android_app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Android App')) self.android_app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Android App'))
self.qr_description_label.setText(translate('RemotePlugin.RemoteTab', self.qr_description_label.setText(
'Scan the QR code or click <a href="https://play.google.com/store/' translate('RemotePlugin.RemoteTab', 'Scan the QR code or click <a href="https://play.google.com/store/'
'apps/details?id=org.openlp.android">download</a> to install the ' 'apps/details?id=org.openlp.android">download</a> to install the Android app from Google Play.'))
'Android app from Google Play.'))
self.https_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'HTTPS Server')) self.https_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'HTTPS Server'))
self.https_error_label.setText(translate('RemotePlugin.RemoteTab', self.https_error_label.setText(
'Could not find an SSL certificate. The HTTPS server will not be available unless an SSL certificate ' translate('RemotePlugin.RemoteTab', 'Could not find an SSL certificate. The HTTPS server will not be '
'is found. Please see the manual for more information.')) 'available unless an SSL certificate is found. Please see the manual for more information.'))
self.https_port_label.setText(self.port_label.text()) self.https_port_label.setText(self.port_label.text())
self.remote_https_url_label.setText(self.remote_url_label.text()) self.remote_https_url_label.setText(self.remote_url_label.text())
self.stage_https_url_label.setText(self.stage_url_label.text()) self.stage_https_url_label.setText(self.stage_url_label.text())
@ -290,4 +289,3 @@ class RemoteTab(SettingsTab):
Invert the HTTP group box based on Https group settings Invert the HTTP group box based on Https group settings
""" """
self.http_settings_group_box.setEnabled(not self.https_settings_group_box.isChecked()) self.http_settings_group_box.setEnabled(not self.https_settings_group_box.isChecked())

View File

@ -52,8 +52,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
""" """
Execute the dialog. Execute the dialog.
``clear`` :param clear: Clear the form fields before displaying the dialog.
Clear the form fields before displaying the dialog.
""" """
if clear: if clear:
self.first_name_edit.clear() self.first_name_edit.clear()
@ -69,8 +68,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
When the first name is edited and the setting to automatically create a display name is True, then try to create When the first name is edited and the setting to automatically create a display name is True, then try to create
a display name from the first and last names. a display name from the first and last names.
``display_name`` :param display_name: The text from the first_name_edit widget.
The text from the first_name_edit widget.
""" """
if not self.auto_display_name: if not self.auto_display_name:
return return
@ -85,8 +83,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
When the last name is edited and the setting to automatically create a display name is True, then try to create When the last name is edited and the setting to automatically create a display name is True, then try to create
a display name from the first and last names. a display name from the first and last names.
``display_name`` :param display_name: The text from the last_name_edit widget.
The text from the last_name_edit widget.
""" """
if not self.auto_display_name: if not self.auto_display_name:
return return

View File

@ -35,7 +35,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, translate from openlp.core.common import Registry, RegistryProperties, translate
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib import delete_song from openlp.plugins.songs.lib import delete_song
from openlp.plugins.songs.lib.db import Song, MediaFile from openlp.plugins.songs.lib.db import Song, MediaFile
@ -45,7 +45,7 @@ from openlp.plugins.songs.lib.songcompare import songs_probably_equal
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class DuplicateSongRemovalForm(OpenLPWizard): class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties):
""" """
This is the Duplicate Song Removal Wizard. It provides functionality to search for and remove duplicate songs This is the Duplicate Song Removal Wizard. It provides functionality to search for and remove duplicate songs
in the database. in the database.
@ -328,28 +328,3 @@ class DuplicateSongRemovalForm(OpenLPWizard):
self.button(QtGui.QWizard.FinishButton).setEnabled(True) self.button(QtGui.QWizard.FinishButton).setEnabled(True)
self.button(QtGui.QWizard.NextButton).hide() self.button(QtGui.QWizard.NextButton).hide()
self.button(QtGui.QWizard.CancelButton).hide() self.button(QtGui.QWizard.CancelButton).hide()
def _get_main_window(self):
"""
Adds the main window to the class dynamically.
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -334,11 +334,8 @@ def create_combo_box(parent, name):
""" """
Utility method to generate a standard combo box for this dialog. Utility method to generate a standard combo box for this dialog.
``parent`` :param parent: The parent widget for this combo box.
The parent widget for this combo box. :param name: The object name
``name``
The object name.
""" """
combo_box = QtGui.QComboBox(parent) combo_box = QtGui.QComboBox(parent)
combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)

View File

@ -38,7 +38,7 @@ import shutil
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, UiStrings, check_directory_exists, translate from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, translate
from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib import VerseType, clean_song
@ -52,7 +52,7 @@ from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
""" """
Class to manage the editing of a song Class to manage the editing of a song
""" """
@ -956,23 +956,3 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
clean_song(self.manager, self.song) clean_song(self.manager, self.song)
self.manager.save_object(self.song) self.manager.save_object(self.song)
self.media_item.auto_select_id = self.song.id self.media_item.auto_select_id = self.song.id
def _get_plugin_manager(self):
"""
Adds the plugin manager to the class dynamically
"""
if not hasattr(self, '_plugin_manager'):
self._plugin_manager = Registry().get('plugin_manager')
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, '_theme_manager'):
self._theme_manager = Registry().get('theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -35,7 +35,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.common import RegistryProperties, Settings, UiStrings, translate
from openlp.core.lib import FileDialog from openlp.core.lib import FileDialog
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
@ -44,7 +44,7 @@ from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SongImportForm(OpenLPWizard): class SongImportForm(OpenLPWizard, RegistryProperties):
""" """
This is the Song Import Wizard, which allows easy importing of Songs This is the Song Import Wizard, which allows easy importing of Songs
into OpenLP from other formats like OpenLyrics, OpenSong and CCLI. into OpenLP from other formats like OpenLyrics, OpenSong and CCLI.
@ -480,26 +480,6 @@ class SongImportForm(OpenLPWizard):
self.format_widgets[this_format]['import_widget'] = import_widget self.format_widgets[this_format]['import_widget'] = import_widget
return import_widget return import_widget
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)
class SongImportSourcePage(QtGui.QWizardPage): class SongImportSourcePage(QtGui.QWizardPage):
""" """

View File

@ -32,7 +32,7 @@ import os
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from sqlalchemy.sql import and_ from sqlalchemy.sql import and_
from openlp.core.common import Registry, UiStrings, translate from openlp.core.common import Registry, RegistryProperties, UiStrings, translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.songs.forms.authorsform import AuthorsForm from openlp.plugins.songs.forms.authorsform import AuthorsForm
from openlp.plugins.songs.forms.topicsform import TopicsForm from openlp.plugins.songs.forms.topicsform import TopicsForm
@ -43,7 +43,7 @@ from .songmaintenancedialog import Ui_SongMaintenanceDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryProperties):
""" """
Class documentation goes here. Class documentation goes here.
""" """
@ -82,8 +82,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
""" """
Show the dialog. Show the dialog.
``from_song_edit``
Indicates if the maintenance dialog has been opened from song edit :param from_song_edit: Indicates if the maintenance dialog has been opened from song edit
or from the media manager. Defaults to **False**. or from the media manager. Defaults to **False**.
""" """
self.from_song_edit = from_song_edit self.from_song_edit = from_song_edit
@ -532,17 +532,3 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
else: else:
delete_button.setEnabled(True) delete_button.setEnabled(True)
edit_button.setEnabled(True) edit_button.setEnabled(True)
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -58,11 +58,8 @@ class SongReviewWidget(QtGui.QWidget):
def __init__(self, parent, song): def __init__(self, parent, song):
""" """
``parent`` :param parent: The QWidget-derived parent of the wizard.
The QWidget-derived parent of the wizard. :param song: The Song which this SongReviewWidget should represent.
``song``
The Song which this SongReviewWidget should represent.
""" """
super(SongReviewWidget, self).__init__(parent) super(SongReviewWidget, self).__init__(parent)
self.song = song self.song = song

View File

@ -92,9 +92,7 @@ def init_schema(url):
""" """
Setup the songs database connection and initialise the database schema. Setup the songs database connection and initialise the database schema.
``url`` :param url: The database to setup
The database to setup
The song database contains the following tables: The song database contains the following tables:
* authors * authors

View File

@ -211,8 +211,7 @@ class FoilPresenter(object):
""" """
Create and save a song from Foilpresenter format xml to the database. Create and save a song from Foilpresenter format xml to the database.
``xml`` :param xml: The XML to parse (unicode).
The XML to parse (unicode).
""" """
# No xml get out of here. # No xml get out of here.
if not xml: if not xml:

View File

@ -361,11 +361,8 @@ class SongFormat(object):
""" """
Return requested song format attribute(s). Return requested song format attribute(s).
``format`` :param format: A song format from SongFormat.
A song format from SongFormat. :param attributes: Zero or more song format attributes from SongFormat.
``*attributes``
Zero or more song format attributes from SongFormat.
Return type depends on number of supplied attributes: Return type depends on number of supplied attributes:

View File

@ -65,8 +65,7 @@ class OpenLPSongImport(SongImport):
""" """
Run the import for an OpenLP version 2 song database. Run the import for an OpenLP version 2 song database.
``progress_dialog`` :param progress_dialog: The QProgressDialog used when importing songs from the FRW.
The QProgressDialog used when importing songs from the FRW.
""" """
class OldAuthor(BaseModel): class OldAuthor(BaseModel):

View File

@ -35,14 +35,14 @@ import os
from lxml import etree from lxml import etree
from openlp.core.common import Registry, check_directory_exists, translate from openlp.core.common import RegistryProperties, check_directory_exists, translate
from openlp.core.utils import clean_filename from openlp.core.utils import clean_filename
from openlp.plugins.songs.lib.xml import OpenLyrics from openlp.plugins.songs.lib.xml import OpenLyrics
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class OpenLyricsExport(object): class OpenLyricsExport(RegistryProperties):
""" """
This provides the Openlyrics export. This provides the Openlyrics export.
""" """
@ -82,16 +82,3 @@ class OpenLyricsExport(object):
pretty_print=True) pretty_print=True)
return True return True
def _get_application(self):
"""
Adds the openlp to the class dynamically.
Windows needs to access the application in a dynamic manner.
"""
if os.name == 'nt':
return Registry().get('application')
else:
if not hasattr(self, '_application'):
self._application = Registry().get('application')
return self._application
application = property(_get_application)

View File

@ -29,12 +29,12 @@
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.common import Registry, translate from openlp.core.common import RegistryProperties, translate
from openlp.plugins.songusage.lib.db import SongUsageItem from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedeletedialog import Ui_SongUsageDeleteDialog from .songusagedeletedialog import Ui_SongUsageDeleteDialog
class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryProperties):
""" """
Class documentation goes here. Class documentation goes here.
""" """
@ -71,13 +71,3 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self.accept() self.accept()
else: else:
self.reject() self.reject()
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -33,14 +33,14 @@ import os
from PyQt4 import QtGui from PyQt4 import QtGui
from sqlalchemy.sql import and_ from sqlalchemy.sql import and_
from openlp.core.common import Registry, Settings, check_directory_exists, translate from openlp.core.common import RegistryProperties, Settings, check_directory_exists, translate
from openlp.plugins.songusage.lib.db import SongUsageItem from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedetaildialog import Ui_SongUsageDetailDialog from .songusagedetaildialog import Ui_SongUsageDetailDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryProperties):
""" """
Class documentation goes here. Class documentation goes here.
""" """
@ -118,13 +118,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
if file_handle: if file_handle:
file_handle.close() file_handle.close()
self.close() self.close()
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, '_main_window'):
self._main_window = Registry().get('main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -41,8 +41,7 @@ def try_int(s):
Convert string s to an integer if possible. Fail silently and return Convert string s to an integer if possible. Fail silently and return
the string as-is if it isn't an integer. the string as-is if it isn't an integer.
``s`` :param s: The string to try to convert.
The string to try to convert.
""" """
try: try:
return int(s) return int(s)
@ -54,8 +53,7 @@ def natural_sort_key(s):
""" """
Return a tuple by which s is sorted. Return a tuple by which s is sorted.
``s`` :param s: A string value from the list we want to sort.
A string value from the list we want to sort.
""" """
return list(map(try_int, SPLIT_ALPHA_DIGITS.findall(s))) return list(map(try_int, SPLIT_ALPHA_DIGITS.findall(s)))
@ -64,11 +62,8 @@ def natural_compare(a, b):
""" """
Compare two strings naturally and return the result. Compare two strings naturally and return the result.
``a`` :param a: A string to compare.
A string to compare. :param b: A string to compare.
``b``
A string to compare.
""" """
return cmp(natural_sort_key(a), natural_sort_key(b)) return cmp(natural_sort_key(a), natural_sort_key(b))

View File

@ -1,4 +1,31 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A 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 this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
""" """
Base directory for tests Base directory for tests
""" """

View File

@ -41,17 +41,23 @@ class TestRegistryProperties(TestCase, RegistryProperties):
""" """
def setUp(self): def setUp(self):
""" """
Create the UI Create the Register
""" """
Registry.create() Registry.create()
def no_application_test(self): def no_application_test(self):
"""
Test property if no registry value assigned
"""
# GIVEN an Empty Registry # GIVEN an Empty Registry
# WHEN there is no Application # WHEN there is no Application
# THEN the application should be none # THEN the application should be none
self.assertEquals(self.application, None, 'The application value should be None') self.assertEquals(self.application, None, 'The application value should be None')
def application_test(self): def application_test(self):
"""
Test property if registry value assigned
"""
# GIVEN an Empty Registry # GIVEN an Empty Registry
application = MagicMock() application = MagicMock()
# WHEN the application is registered # WHEN the application is registered

View File

@ -29,16 +29,13 @@
""" """
Package to test the openlp.core.lib.settings package. Package to test the openlp.core.lib.settings package.
""" """
import os
from tempfile import mkstemp
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.common import Settings from openlp.core.common import Settings
from tests.helpers.testmixin import TestMixin
class TestSettings(TestCase): class TestSettings(TestCase, TestMixin):
""" """
Test the functions in the Settings module Test the functions in the Settings module
""" """
@ -46,18 +43,14 @@ class TestSettings(TestCase):
""" """
Create the UI Create the UI
""" """
Settings.setDefaultFormat(Settings.IniFormat) self.get_application()
self.fd, self.ini_file = mkstemp('.ini') self.build_settings()
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
def tearDown(self): def tearDown(self):
""" """
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
del self.application self.destroy_settings()
os.close(self.fd)
os.unlink(Settings().fileName())
def settings_basic_test(self): def settings_basic_test(self):
""" """

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A 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 this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.lib package.
"""

View File

@ -7,6 +7,7 @@ from openlp.core.common import UiStrings
from openlp.core.lib.filedialog import FileDialog from openlp.core.lib.filedialog import FileDialog
from tests.functional import MagicMock, patch from tests.functional import MagicMock, patch
class TestFileDialog(TestCase): class TestFileDialog(TestCase):
""" """
Test the functions in the :mod:`filedialog` module. Test the functions in the :mod:`filedialog` module.
@ -46,7 +47,7 @@ class TestFileDialog(TestCase):
def returned_file_list_test(self): def returned_file_list_test(self):
""" """
Test that FileDialog.getOpenFileNames handles a list of files properly when QFileList.getOpenFileNames Test that FileDialog.getOpenFileNames handles a list of files properly when QFileList.getOpenFileNames
returns a good file name, a urlencoded file name and a non-existing file returns a good file name, a url encoded file name and a non-existing file
""" """
self.mocked_os.rest() self.mocked_os.rest()
self.mocked_qt_gui.reset() self.mocked_qt_gui.reset()
@ -62,7 +63,7 @@ class TestFileDialog(TestCase):
result = FileDialog.getOpenFileNames(self.mocked_parent) result = FileDialog.getOpenFileNames(self.mocked_parent)
# THEN: os.path.exists should have been called with known args. QmessageBox.information should have been # THEN: os.path.exists should have been called with known args. QmessageBox.information should have been
# called. The returned result should corrilate with the input. # called. The returned result should correlate with the input.
self.mocked_os.path.exists.assert_callde_with('/Valid File') self.mocked_os.path.exists.assert_callde_with('/Valid File')
self.mocked_os.path.exists.assert_callde_with('/url%20encoded%20file%20%231') self.mocked_os.path.exists.assert_callde_with('/url%20encoded%20file%20%231')
self.mocked_os.path.exists.assert_callde_with('/url encoded file #1') self.mocked_os.path.exists.assert_callde_with('/url encoded file #1')

View File

@ -36,18 +36,19 @@ from PyQt4 import QtGui
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.core.lib import ImageManager, ScreenList from openlp.core.lib import ImageManager, ScreenList
from tests.helpers.testmixin import TestMixin
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
class TestImageManager(TestCase): class TestImageManager(TestCase, TestMixin):
def setUp(self): def setUp(self):
""" """
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication.instance() self.get_application()
ScreenList.create(self.app.desktop()) ScreenList.create(self.app.desktop())
self.image_manager = ImageManager() self.image_manager = ImageManager()

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A 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 this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################

View File

@ -29,17 +29,16 @@
""" """
Package to test the openlp.core.utils.actions package. Package to test the openlp.core.utils.actions package.
""" """
import os
from tempfile import mkstemp
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from openlp.core.common import Settings from openlp.core.common import Settings
from openlp.core.utils import ActionList from openlp.core.utils import ActionList
from tests.helpers.testmixin import TestMixin
class TestActionList(TestCase): class TestActionList(TestCase, TestMixin):
""" """
Test the ActionList class Test the ActionList class
""" """
@ -49,10 +48,8 @@ class TestActionList(TestCase):
Prepare the tests Prepare the tests
""" """
self.action_list = ActionList.get_instance() self.action_list = ActionList.get_instance()
Settings.setDefaultFormat(Settings.IniFormat) self.build_settings()
self.settings = Settings() self.settings = Settings()
self.fd, self.ini_file = mkstemp('.ini')
self.settings.set_filename(self.ini_file)
self.settings.beginGroup('shortcuts') self.settings.beginGroup('shortcuts')
def tearDown(self): def tearDown(self):
@ -60,8 +57,7 @@ class TestActionList(TestCase):
Clean up Clean up
""" """
self.settings.endGroup() self.settings.endGroup()
os.close(self.fd) self.destroy_settings()
os.unlink(Settings().fileName())
def test_add_action_same_parent(self): def test_add_action_same_parent(self):
""" """

View File

@ -1 +1,28 @@
__author__ = 'raoul' # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A 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 this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################

View File

@ -26,3 +26,4 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################

Some files were not shown because too many files have changed in this diff Show More