forked from openlp/openlp
HEAD
This commit is contained in:
commit
74fc1d3988
@ -43,7 +43,7 @@ from traceback import format_exception
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, ScreenList, UiStrings, Registry, check_directory_exists
|
||||
from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||
@ -150,16 +150,10 @@ class OpenLP(QtGui.QApplication):
|
||||
update_check = Settings().value(u'general/update check')
|
||||
if update_check:
|
||||
VersionThread(self.main_window).start()
|
||||
Receiver.send_message(u'live_display_blank_check')
|
||||
self.main_window.is_display_blank()
|
||||
self.main_window.app_startup()
|
||||
return self.exec_()
|
||||
|
||||
def close_splash_screen(self):
|
||||
"""
|
||||
Close the splash screen when requested.
|
||||
"""
|
||||
self.splash.close()
|
||||
|
||||
def is_already_running(self):
|
||||
"""
|
||||
Look to see if OpenLP is already running and ask if a 2nd copy
|
||||
@ -203,6 +197,7 @@ class OpenLP(QtGui.QApplication):
|
||||
"""
|
||||
Wrapper to make ProcessEvents visible and named correctly
|
||||
"""
|
||||
log.debug(u'processing event flush')
|
||||
self.processEvents()
|
||||
|
||||
def set_busy_cursor(self):
|
||||
|
@ -30,6 +30,7 @@
|
||||
The :mod:`lib` module contains most of the components and libraries that make
|
||||
OpenLP work.
|
||||
"""
|
||||
from distutils.version import LooseVersion
|
||||
import logging
|
||||
import os
|
||||
|
||||
@ -366,28 +367,27 @@ def create_separated_list(stringlist):
|
||||
``stringlist``
|
||||
List of unicode strings
|
||||
"""
|
||||
if Qt.PYQT_VERSION_STR >= u'4.9' and Qt.qVersion() >= u'4.8':
|
||||
if LooseVersion(Qt.PYQT_VERSION_STR) >= LooseVersion(u'4.9') and \
|
||||
LooseVersion(Qt.qVersion()) >= LooseVersion(u'4.8'):
|
||||
return QtCore.QLocale().createSeparatedList(stringlist)
|
||||
if not stringlist:
|
||||
return u''
|
||||
elif len(stringlist) == 1:
|
||||
return stringlist[0]
|
||||
elif len(stringlist) == 2:
|
||||
return translate('OpenLP.core.lib', '%1 and %2',
|
||||
return translate('OpenLP.core.lib', '%s and %s',
|
||||
'Locale list separator: 2 items') % (stringlist[0], stringlist[1])
|
||||
else:
|
||||
merged = translate('OpenLP.core.lib', '%1, and %2',
|
||||
merged = translate('OpenLP.core.lib', '%s, and %s',
|
||||
u'Locale list separator: end') % (stringlist[-2], stringlist[-1])
|
||||
for index in reversed(range(1, len(stringlist) - 2)):
|
||||
merged = translate('OpenLP.core.lib', '%1, %2',
|
||||
u'Locale list separator: middle') % (stringlist[index], merged)
|
||||
return translate('OpenLP.core.lib', '%1, %2',
|
||||
u'Locale list separator: start') % (stringlist[0], merged)
|
||||
merged = translate('OpenLP.core.lib', '%s, %s',
|
||||
u'Locale list separator: middle') % (stringlist[index], merged)
|
||||
return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged)
|
||||
|
||||
|
||||
from registry import Registry
|
||||
from uistrings import UiStrings
|
||||
from eventreceiver import Receiver
|
||||
from screen import ScreenList
|
||||
from settings import Settings
|
||||
from listwidgetwithdnd import ListWidgetWithDnD
|
||||
|
@ -1,253 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2013 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2013 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
Provide event handling code for OpenLP
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EventReceiver(QtCore.QObject):
|
||||
"""
|
||||
Class to allow events to be passed from different parts of the system. This
|
||||
is a private class and should not be used directly but rather via the
|
||||
Receiver class.
|
||||
|
||||
**Mainwindow related and generic signals**
|
||||
|
||||
``mainwindow_status_text``
|
||||
Changes the bottom status bar text on the mainwindow.
|
||||
|
||||
``openlp_error_message``
|
||||
Displays a standalone Error Message.
|
||||
|
||||
``openlp_information_message``
|
||||
Displays a standalone Information Message.
|
||||
|
||||
``openlp_version_check``
|
||||
Version has changed so pop up window.
|
||||
|
||||
``openlp_stop_wizard``
|
||||
Stops a wizard before completion.
|
||||
|
||||
**Setting related signals**
|
||||
|
||||
``config_updated``
|
||||
Informs components that the config has changed.
|
||||
|
||||
``config_screen_changed``
|
||||
The display monitor has been changed.
|
||||
|
||||
**Slidecontroller signals**
|
||||
|
||||
``slidecontroller_{live|preview}_next``
|
||||
Moves to the next slide.
|
||||
|
||||
``slidecontroller_{live|preview}_next_noloop``
|
||||
Moves to the next slide without auto advance.
|
||||
|
||||
``slidecontroller_{live|preview}_previous``
|
||||
Moves to the previous slide.
|
||||
|
||||
``slidecontroller_{live|preview}_previous_noloop``
|
||||
Moves to the previous slide, without auto advance.
|
||||
|
||||
``slidecontroller_{live|preview}_set``
|
||||
Moves to a specific slide, by index.
|
||||
|
||||
``slidecontroller_{live|preview}_started``
|
||||
Broadcasts that an item has been made live/previewed.
|
||||
|
||||
``slidecontroller_{live|preview}_change``
|
||||
Informs the slidecontroller that a slide change has occurred and to
|
||||
update itself.
|
||||
|
||||
``slidecontroller_{live|preview}_changed``
|
||||
Broadcasts that the slidecontroller has changed the current slide.
|
||||
|
||||
``slidecontroller_{live|preview}_blank``
|
||||
Request that the output screen is blanked.
|
||||
|
||||
``slidecontroller_{live|preview}_unblank``
|
||||
Request that the output screen is unblanked.
|
||||
|
||||
``slidecontroller_live_spin_delay``
|
||||
Pushes out the loop delay.
|
||||
|
||||
``slidecontroller_update_slide_limits``
|
||||
Updates the slide_limits variable from the saved settings.
|
||||
|
||||
``slidecontroller_live_stop_loop``
|
||||
Stop the loop on the main display.
|
||||
|
||||
**Display signals**
|
||||
|
||||
``update_display_css``
|
||||
CSS has been updated which needs to be changed on the main display.
|
||||
|
||||
**Live Display signals**
|
||||
|
||||
``live_display_hide``
|
||||
Hide the live display.
|
||||
|
||||
``live_display_show``
|
||||
Return the live display.
|
||||
|
||||
``live_display_active``
|
||||
The live display has been made active.
|
||||
|
||||
``live_display_blank_check``
|
||||
Check to see if the blank display message is required.
|
||||
|
||||
**Theme related singlas**
|
||||
|
||||
``theme_update_list``
|
||||
send out message with new themes.
|
||||
|
||||
``theme_update_global``
|
||||
Tell the components we have a new global theme.
|
||||
|
||||
**Plugin specific signals**
|
||||
|
||||
``{plugin}_start``
|
||||
Requests a plugin to start a external program. Path and file have to
|
||||
be provided in the message.
|
||||
|
||||
``{plugin}_first``
|
||||
Requests a plugin to handle a first event.
|
||||
|
||||
``{plugin}_previous``
|
||||
Requests a plugin to handle a previous event.
|
||||
|
||||
``{plugin}_next``
|
||||
Requests a plugin to handle a next event.
|
||||
|
||||
``{plugin}_last``
|
||||
Requests a plugin to handle a last event.
|
||||
|
||||
``{plugin}_slide``
|
||||
Requests a plugin to handle a go to specific slide event.
|
||||
|
||||
``{plugin}_stop``
|
||||
Requests a plugin to handle a stop event.
|
||||
|
||||
``{plugin}_blank``
|
||||
Requests a plugin to handle a blank screen event.
|
||||
|
||||
``{plugin}_unblank``
|
||||
Requests a plugin to handle an unblank screen event.
|
||||
|
||||
``{plugin}_load_list``
|
||||
Tells the the plugin to reload the media manager list.
|
||||
|
||||
``{plugin}_preview``
|
||||
Tells the plugin it's item can be previewed.
|
||||
|
||||
``{plugin}_add_service_item``
|
||||
Ask the plugin to push the selected items to the service item.
|
||||
|
||||
``{plugin}_service_load``
|
||||
Ask the plugin to process an individual service item after it has been
|
||||
loaded.
|
||||
|
||||
``{plugin}_config_updated``
|
||||
The config has changed so tell the plugin about it.
|
||||
|
||||
``alerts_text``
|
||||
Displays an alert message.
|
||||
|
||||
``bibles_nobook``
|
||||
Attempt to find book resulted in no match.
|
||||
|
||||
``remotes_poll_request``
|
||||
Waits for openlp to do something "interesting" and sends a
|
||||
``remotes_poll_response`` signal when it does.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialise the event receiver, calling the parent constructor.
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
|
||||
def send_message(self, event, msg=None):
|
||||
"""
|
||||
Emit a Qt signal.
|
||||
|
||||
``event``
|
||||
The event to that was sent.
|
||||
|
||||
``msg``
|
||||
Defaults to *None*. The message to send with the event.
|
||||
"""
|
||||
log.debug(u'Event %s passed with payload %s' % (event, msg))
|
||||
self.emit(QtCore.SIGNAL(event), msg)
|
||||
|
||||
|
||||
class Receiver(object):
|
||||
"""
|
||||
Class to allow events to be passed from different parts of the system. This
|
||||
is a static wrapper around the ``EventReceiver`` class. As there is only
|
||||
one instance of it in the system the Qt4 signal/slot architecture can send
|
||||
messages across the system.
|
||||
|
||||
To send a message:
|
||||
``Receiver.send_message(u'<<Message ID>>', data)``
|
||||
|
||||
To receive a Message
|
||||
``QtCore.QObject.connect(
|
||||
Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'<<Message ID>>'),
|
||||
<<ACTION>>
|
||||
)``
|
||||
"""
|
||||
__eventreceiver__ = EventReceiver()
|
||||
|
||||
@staticmethod
|
||||
def send_message(event, msg=None):
|
||||
"""
|
||||
Sends a message to the messaging system.
|
||||
|
||||
``event``
|
||||
The event to send.
|
||||
|
||||
``msg``
|
||||
Defaults to *None*. The message to send with the event.
|
||||
"""
|
||||
Receiver.__eventreceiver__.send_message(event, msg)
|
||||
|
||||
@staticmethod
|
||||
def get_receiver():
|
||||
"""
|
||||
Get the global ``__eventreceiver__`` instance.
|
||||
"""
|
||||
return Receiver.__eventreceiver__
|
@ -36,8 +36,7 @@ from openlp.core.lib import Settings, translate
|
||||
|
||||
class FormattingTags(object):
|
||||
"""
|
||||
Static Class to HTML Tags to be access around the code the list is managed
|
||||
by the Options Tab.
|
||||
Static Class to HTML Tags to be access around the code the list is managed by the Options Tab.
|
||||
"""
|
||||
html_expands = []
|
||||
|
||||
@ -56,12 +55,11 @@ class FormattingTags(object):
|
||||
tags = []
|
||||
for tag in FormattingTags.html_expands:
|
||||
if not tag[u'protected'] and not tag.get(u'temporary'):
|
||||
# Using dict ensures that copy is made and encoding of values
|
||||
# a little later does not affect tags in the original list
|
||||
# Using dict ensures that copy is made and encoding of values a little later does not affect tags in
|
||||
# the original list
|
||||
tags.append(dict(tag))
|
||||
tag = tags[-1]
|
||||
# Remove key 'temporary' from tags.
|
||||
# It is not needed to be saved.
|
||||
# Remove key 'temporary' from tags. It is not needed to be saved.
|
||||
if u'temporary' in tag:
|
||||
del tag[u'temporary']
|
||||
for element in tag:
|
||||
@ -73,15 +71,12 @@ class FormattingTags(object):
|
||||
@staticmethod
|
||||
def load_tags():
|
||||
"""
|
||||
Load the Tags from store so can be used in the system or used to
|
||||
update the display.
|
||||
Load the Tags from store so can be used in the system or used to update the display.
|
||||
"""
|
||||
temporary_tags = [tag for tag in FormattingTags.html_expands
|
||||
if tag.get(u'temporary')]
|
||||
temporary_tags = [tag for tag in FormattingTags.html_expands if tag.get(u'temporary')]
|
||||
FormattingTags.html_expands = []
|
||||
base_tags = []
|
||||
# Append the base tags.
|
||||
# Hex Color tags from http://www.w3schools.com/html/html_colornames.asp
|
||||
base_tags.append({u'desc': translate('OpenLP.FormattingTags', 'Red'),
|
||||
u'start tag': u'{r}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:red">',
|
||||
@ -195,19 +190,17 @@ class FormattingTags(object):
|
||||
The end tag, e. g. ``{/r}``
|
||||
|
||||
* start html
|
||||
The start html tag. For instance ``<span style="
|
||||
-webkit-text-fill-color:red">``
|
||||
The start html tag. For instance ``<span style="-webkit-text-fill-color:red">``
|
||||
|
||||
* end html
|
||||
The end html tag. For example ``</span>``
|
||||
|
||||
* protected
|
||||
A boolean stating whether this is a build-in tag or not. Should be
|
||||
``True`` in most cases.
|
||||
A boolean stating whether this is a build-in tag or not. Should be ``True`` in most cases.
|
||||
|
||||
* temporary
|
||||
A temporary tag will not be saved, but is also considered when
|
||||
displaying text containing the tag. It has to be a ``boolean``.
|
||||
A temporary tag will not be saved, but is also considered when displaying text containing the tag. It has
|
||||
to be a ``boolean``.
|
||||
"""
|
||||
FormattingTags.html_expands.extend(tags)
|
||||
|
||||
|
@ -39,7 +39,7 @@ import Queue
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, Registry, ScreenList, resize_image, image_to_byte
|
||||
from openlp.core.lib import Registry, ScreenList, resize_image, image_to_byte
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -200,7 +200,7 @@ class ImageManager(QtCore.QObject):
|
||||
self.image_thread = ImageThread(self)
|
||||
self._conversion_queue = PriorityQueue()
|
||||
self.stop_manager = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.process_updates)
|
||||
Registry().register_function(u'config_updated', self.process_updates)
|
||||
|
||||
def update_display(self):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.lib import Registry
|
||||
|
||||
|
||||
class ListWidgetWithDnD(QtGui.QListWidget):
|
||||
@ -54,8 +54,7 @@ class ListWidgetWithDnD(QtGui.QListWidget):
|
||||
"""
|
||||
self.setAcceptDrops(True)
|
||||
self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText),
|
||||
self.parent().loadFile)
|
||||
Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().loadFile)
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
"""
|
||||
@ -112,6 +111,6 @@ class ListWidgetWithDnD(QtGui.QListWidget):
|
||||
listing = os.listdir(localFile)
|
||||
for file in listing:
|
||||
files.append(os.path.join(localFile, file))
|
||||
Receiver.send_message(u'%s_dnd' % self.mimeDataText, files)
|
||||
Registry().execute(u'%s_dnd' % self.mimeDataText, files)
|
||||
else:
|
||||
event.ignore()
|
||||
|
@ -35,7 +35,7 @@ import re
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \
|
||||
ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate
|
||||
from openlp.core.lib.searchedit import SearchEdit
|
||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||
@ -116,8 +116,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.setupUi()
|
||||
self.retranslateUi()
|
||||
self.autoSelectId = -1
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_service_load' % self.plugin.name),
|
||||
self.serviceLoad)
|
||||
Registry().register_function(u'%s_service_load' % self.plugin.name, self.serviceLoad)
|
||||
|
||||
def requiredIcons(self):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, Registry, UiStrings
|
||||
from openlp.core.lib import Settings, Registry, UiStrings
|
||||
from openlp.core.utils import get_application_version
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -171,10 +171,8 @@ class Plugin(QtCore.QObject):
|
||||
default_settings[u'%s/%s files' % (name, name)] = []
|
||||
# Add settings to the dict of all settings.
|
||||
Settings.extend_default_settings(default_settings)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||
self.processAddServiceEvent)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name),
|
||||
self.configUpdated)
|
||||
Registry().register_function(u'%s_add_service_item' % self.name, self.processAddServiceEvent)
|
||||
Registry().register_function(u'%s_config_updated' % self.name, self.config_update)
|
||||
|
||||
def checkPreConditions(self):
|
||||
"""
|
||||
@ -403,7 +401,7 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
return u''
|
||||
|
||||
def configUpdated(self):
|
||||
def config_update(self):
|
||||
"""
|
||||
The plugin's config has changed
|
||||
"""
|
||||
|
@ -35,6 +35,7 @@ import logging
|
||||
import imp
|
||||
|
||||
from openlp.core.lib import Plugin, PluginStatus, Registry
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -46,36 +47,28 @@ class PluginManager(object):
|
||||
"""
|
||||
log.info(u'Plugin manager loaded')
|
||||
|
||||
def __init__(self, plugin_dir):
|
||||
def __init__(self):
|
||||
"""
|
||||
The constructor for the plugin manager. Passes the controllers on to
|
||||
the plugins for them to interact with via their ServiceItems.
|
||||
|
||||
``plugin_dir``
|
||||
The directory to search for plugins.
|
||||
"""
|
||||
log.info(u'Plugin manager Initialising')
|
||||
Registry().register(u'plugin_manager', self)
|
||||
self.base_path = os.path.abspath(plugin_dir)
|
||||
self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))
|
||||
log.debug(u'Base path %s ', self.base_path)
|
||||
self.plugins = []
|
||||
log.info(u'Plugin manager Initialised')
|
||||
|
||||
def find_plugins(self, plugin_dir):
|
||||
def find_plugins(self):
|
||||
"""
|
||||
Scan the directory ``plugin_dir`` for objects inheriting from the
|
||||
``Plugin`` class.
|
||||
|
||||
``plugin_dir``
|
||||
The directory to scan.
|
||||
|
||||
Scan a directory for objects inheriting from the ``Plugin`` class.
|
||||
"""
|
||||
log.info(u'Finding plugins')
|
||||
start_depth = len(os.path.abspath(plugin_dir).split(os.sep))
|
||||
present_plugin_dir = os.path.join(plugin_dir, 'presentations')
|
||||
log.debug(u'finding plugins in %s at depth %d', unicode(plugin_dir), start_depth)
|
||||
for root, dirs, files in os.walk(plugin_dir):
|
||||
if sys.platform == 'darwin'and root.startswith(present_plugin_dir):
|
||||
start_depth = len(os.path.abspath(self.base_path).split(os.sep))
|
||||
present_plugin_dir = os.path.join(self.base_path, 'presentations')
|
||||
log.debug(u'finding plugins in %s at depth %d', unicode(self.base_path), start_depth)
|
||||
for root, dirs, files in os.walk(self.base_path):
|
||||
if sys.platform == 'darwin' and root.startswith(present_plugin_dir):
|
||||
# TODO Presentation plugin is not yet working on Mac OS X.
|
||||
# For now just ignore it. The following code will ignore files from the presentation plugin directory
|
||||
# and thereby never import the plugin.
|
||||
|
@ -59,15 +59,19 @@ class Registry(object):
|
||||
log.info(u'Registry Initialising')
|
||||
registry = cls()
|
||||
registry.service_list = {}
|
||||
registry.functions_list = {}
|
||||
registry.running_under_test = False
|
||||
# Allow the tests to remove Registry entries but not the live system
|
||||
if u'nosetest' in sys.argv[0]:
|
||||
if u'nose' in sys.argv[0]:
|
||||
registry.running_under_test = True
|
||||
return registry
|
||||
|
||||
def get(self, key):
|
||||
"""
|
||||
Extracts the registry value from the list based on the key passed in
|
||||
|
||||
``key``
|
||||
The service to be retrieved.
|
||||
"""
|
||||
if key in self.service_list:
|
||||
return self.service_list[key]
|
||||
@ -78,6 +82,12 @@ class Registry(object):
|
||||
def register(self, key, reference):
|
||||
"""
|
||||
Registers a component against a key.
|
||||
|
||||
``key``
|
||||
The service to be created this is usually a major class like "renderer" or "main_window" .
|
||||
|
||||
``reference``
|
||||
The service address to be saved.
|
||||
"""
|
||||
if key in self.service_list:
|
||||
log.error(u'Duplicate service exception %s' % key)
|
||||
@ -88,11 +98,73 @@ class Registry(object):
|
||||
def remove(self, key):
|
||||
"""
|
||||
Removes the registry value from the list based on the key passed in
|
||||
(Only valid and active for testing framework)
|
||||
(Only valid and active for testing framework).
|
||||
|
||||
``key``
|
||||
The service to be deleted.
|
||||
"""
|
||||
if self.running_under_test is False:
|
||||
log.error(u'Invalid Method call for key %s' % key)
|
||||
raise KeyError(u'Invalid Method call for key %s' % key)
|
||||
return
|
||||
if key in self.service_list:
|
||||
del self.service_list[key]
|
||||
|
||||
def register_function(self, event, function):
|
||||
"""
|
||||
Register an event and associated function to be called
|
||||
|
||||
``event``
|
||||
The function description like "config_updated" or "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 recipients.
|
||||
|
||||
``function``
|
||||
The function to be called when the event happens.
|
||||
"""
|
||||
if event in self.functions_list:
|
||||
self.functions_list[event].append(function)
|
||||
else:
|
||||
self.functions_list[event] = [function]
|
||||
|
||||
def remove_function(self, event, function):
|
||||
"""
|
||||
Remove an event and associated handler
|
||||
|
||||
``event``
|
||||
The function description..
|
||||
|
||||
``function``
|
||||
The function to be called when the event happens.
|
||||
"""
|
||||
if self.running_under_test is False:
|
||||
log.error(u'Invalid Method call for key %s' % event)
|
||||
raise KeyError(u'Invalid Method call for key %s' % event)
|
||||
if event in self.functions_list:
|
||||
self.functions_list[event].remove(function)
|
||||
|
||||
def execute(self, event, *args, **kwargs):
|
||||
"""
|
||||
Execute all the handlers associated with the event and return an array of results.
|
||||
|
||||
``event``
|
||||
The function to be processed
|
||||
|
||||
``*args``
|
||||
Parameters to be passed to the function.
|
||||
|
||||
``*kwargs``
|
||||
Parameters to be passed to the function.
|
||||
"""
|
||||
results = []
|
||||
if event in self.functions_list:
|
||||
for function in self.functions_list[event]:
|
||||
try:
|
||||
result = function(*args, **kwargs)
|
||||
if result:
|
||||
results.append(result)
|
||||
except TypeError:
|
||||
# Who has called me can help in debugging
|
||||
import inspect
|
||||
log.debug(inspect.currentframe().f_back.f_locals)
|
||||
log.exception(u'Exception for function %s', function)
|
||||
return results
|
||||
|
@ -31,8 +31,8 @@ import logging
|
||||
|
||||
from PyQt4 import QtGui, QtCore, QtWebKit
|
||||
|
||||
from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Receiver, Registry, ScreenList, \
|
||||
ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css
|
||||
from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Registry, ScreenList, ServiceItem, \
|
||||
expand_tags, build_lyrics_format_css, build_lyrics_outline_css
|
||||
from openlp.core.lib.theme import ThemeLevel
|
||||
from openlp.core.ui import MainDisplay
|
||||
|
||||
@ -80,7 +80,7 @@ class Renderer(object):
|
||||
self.display.setup()
|
||||
self._theme_dimensions = {}
|
||||
self._calculate_default()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme)
|
||||
Registry().register_function(u'theme_update_global', self.set_global_theme)
|
||||
self.web = QtWebKit.QWebView()
|
||||
self.web.setVisible(False)
|
||||
self.web_frame = self.web.page().mainFrame()
|
||||
@ -602,7 +602,7 @@ class Renderer(object):
|
||||
previous_raw = u''
|
||||
# Stop here as the theme line count was requested.
|
||||
if self.force_page:
|
||||
Receiver.send_message(u'theme_line_count', index + 1)
|
||||
Registry().execute(u'theme_line_count', index + 1)
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
@ -35,7 +35,7 @@ import copy
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib import Registry, translate
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -100,7 +100,7 @@ class ScreenList(object):
|
||||
if screen == self.override:
|
||||
self.override = copy.deepcopy(newScreen)
|
||||
self.set_override_display()
|
||||
Receiver.send_message(u'config_screen_changed')
|
||||
Registry().execute(u'config_screen_changed')
|
||||
break
|
||||
|
||||
def screen_count_changed(self, changed_screen=-1):
|
||||
@ -128,7 +128,7 @@ class ScreenList(object):
|
||||
# We do not want to send this message at start up.
|
||||
if changed_screen != -1:
|
||||
# Reload setting tabs to apply possible changes.
|
||||
Receiver.send_message(u'config_screen_changed')
|
||||
Registry().execute(u'config_screen_changed')
|
||||
|
||||
def get_screen_list(self):
|
||||
"""
|
||||
@ -244,7 +244,7 @@ class ScreenList(object):
|
||||
Loads the screen size and the monitor number from the settings.
|
||||
"""
|
||||
from openlp.core.lib import Settings
|
||||
# Add the screen settings to the settings dict. This has to be done here due to crycle dependency.
|
||||
# Add the screen settings to the settings dict. This has to be done here due to cyclic dependency.
|
||||
# Do not do this anywhere else.
|
||||
screen_settings = {
|
||||
u'general/x position': self.current[u'size'].x(),
|
||||
|
@ -634,7 +634,7 @@ class ServiceItem(object):
|
||||
"""
|
||||
self.is_valid = True
|
||||
for frame in self._raw_frames:
|
||||
if self.is_image() and not os.path.exists((frame[u'path'])):
|
||||
if self.is_image() and not os.path.exists(frame[u'path']):
|
||||
self.is_valid = False
|
||||
elif self.is_command():
|
||||
file_name = os.path.join(frame[u'path'], frame[u'title'])
|
||||
|
@ -140,6 +140,7 @@ class Settings(QtCore.QSettings):
|
||||
# circular dependency.
|
||||
u'general/display on monitor': True,
|
||||
u'general/override position': False,
|
||||
u'images/background color': u'#000000',
|
||||
u'media/players': u'webkit',
|
||||
u'media/override player': QtCore.Qt.Unchecked,
|
||||
u'players/background color': u'#000000',
|
||||
@ -259,6 +260,7 @@ class Settings(QtCore.QSettings):
|
||||
"""
|
||||
Settings.__default_settings__ = dict(default_values.items() + Settings.__default_settings__.items())
|
||||
|
||||
|
||||
@staticmethod
|
||||
def set_filename(ini_file):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, UiStrings, build_icon, translate
|
||||
from openlp.core.lib import Registry, UiStrings, build_icon, translate
|
||||
from openlp.core.utils.actions import ActionList
|
||||
|
||||
|
||||
@ -135,8 +135,7 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F
|
||||
return QtGui.QMessageBox.critical(parent, UiStrings().Error, message,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||
data = {u'message': message}
|
||||
data[u'title'] = title if title else UiStrings().Error
|
||||
return Receiver.send_message(u'openlp_error_message', data)
|
||||
return Registry().get(u'main_window').error_message(title if title else UiStrings().Error, message)
|
||||
|
||||
|
||||
def create_horizontal_adjusting_combo_box(parent, name):
|
||||
|
@ -36,7 +36,7 @@ import sys
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon
|
||||
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate, build_icon
|
||||
from openlp.core.utils import AppLocation, format_time, get_images_filter
|
||||
from openlp.core.lib import SlideLimits
|
||||
|
||||
@ -397,22 +397,19 @@ class AdvancedTab(SettingsTab):
|
||||
if not os.path.exists(self.current_data_path):
|
||||
log.error(u'Data path not found %s' % self.current_data_path)
|
||||
answer = QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.AdvancedTab',
|
||||
'Data Directory Error'),
|
||||
translate('OpenLP.AdvancedTab',
|
||||
'OpenLP data directory was not found\n\n%s\n\n'
|
||||
translate('OpenLP.AdvancedTab', 'Data Directory Error'),
|
||||
translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
|
||||
'This data directory was previously changed from the OpenLP '
|
||||
'default location. If the new location was on removable '
|
||||
'media, that media needs to be made available.\n\n'
|
||||
'Click "No" to stop loading OpenLP. allowing you to fix '
|
||||
'the the problem.\n\n'
|
||||
'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
|
||||
'Click "Yes" to reset the data directory to the default '
|
||||
'location.').replace('%s', self.current_data_path),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
log.info(u'User requested termination')
|
||||
Receiver.send_message(u'cleanup')
|
||||
self.main_window.clean_up()
|
||||
sys.exit()
|
||||
# Set data location to default.
|
||||
settings.remove(u'advanced/data path')
|
||||
@ -455,9 +452,9 @@ class AdvancedTab(SettingsTab):
|
||||
settings.setValue(u'slide limits', self.slide_limits)
|
||||
settings.endGroup()
|
||||
if self.display_changed:
|
||||
Receiver.send_message(u'config_screen_changed')
|
||||
Registry().execute(u'config_screen_changed')
|
||||
self.display_changed = False
|
||||
Receiver.send_message(u'slidecontroller_update_slide_limits')
|
||||
Registry().execute(u'slidecontroller_update_slide_limits')
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
@ -573,7 +570,7 @@ class AdvancedTab(SettingsTab):
|
||||
# Check if data already exists here.
|
||||
self.check_data_overwrite(new_data_path)
|
||||
# Save the new location.
|
||||
Receiver.send_message(u'set_new_data_path', new_data_path)
|
||||
self.main_window.set_new_data_path(new_data_path)
|
||||
self.new_data_directory_edit.setText(new_data_path)
|
||||
self.data_directory_cancel_button.show()
|
||||
|
||||
@ -594,7 +591,7 @@ class AdvancedTab(SettingsTab):
|
||||
return
|
||||
self.check_data_overwrite(new_data_path)
|
||||
# Save the new location.
|
||||
Receiver.send_message(u'set_new_data_path', new_data_path)
|
||||
self.main_window.set_new_data_path(new_data_path)
|
||||
self.new_data_directory_edit.setText(os.path.abspath(new_data_path))
|
||||
self.data_directory_cancel_button.show()
|
||||
else:
|
||||
@ -605,8 +602,7 @@ class AdvancedTab(SettingsTab):
|
||||
"""
|
||||
Copy existing data when you change your data directory.
|
||||
"""
|
||||
Receiver.send_message(u'set_copy_data',
|
||||
self.data_directory_copy_check_box.isChecked())
|
||||
self.main_window.set_copy_data(self.data_directory_copy_check_box.isChecked())
|
||||
if self.data_exists:
|
||||
if self.data_directory_copy_check_box.isChecked():
|
||||
self.new_data_directory_has_files_label.show()
|
||||
@ -645,8 +641,8 @@ class AdvancedTab(SettingsTab):
|
||||
"""
|
||||
self.new_data_directory_edit.clear()
|
||||
self.data_directory_copy_check_box.setChecked(False)
|
||||
Receiver.send_message(u'set_new_data_path', u'')
|
||||
Receiver.send_message(u'set_copy_data', False)
|
||||
self.main_window.set_new_data_path(None)
|
||||
self.main_window.set_copy_data(False)
|
||||
self.data_directory_copy_check_box.hide()
|
||||
self.data_directory_cancel_button.hide()
|
||||
self.new_data_directory_has_files_label.hide()
|
||||
|
@ -34,18 +34,18 @@ from PyQt4 import QtGui
|
||||
|
||||
from filerenamedialog import Ui_FileRenameDialog
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, Registry
|
||||
|
||||
|
||||
class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog):
|
||||
"""
|
||||
The file rename dialog
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
QtGui.QDialog.__init__(self, self.main_window)
|
||||
self.setupUi(self)
|
||||
|
||||
def exec_(self, copy=False):
|
||||
@ -56,4 +56,15 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog):
|
||||
self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Copy'))
|
||||
else:
|
||||
self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename'))
|
||||
self.fileNameEdit.setFocus()
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
def _get_main_window(self):
|
||||
"""
|
||||
Adds the main window to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_main_window'):
|
||||
self._main_window = Registry().get(u'main_window')
|
||||
return self._main_window
|
||||
|
||||
main_window = property(_get_main_window)
|
||||
|
@ -41,7 +41,7 @@ from ConfigParser import SafeConfigParser
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import PluginStatus, Receiver, Settings, Registry, build_icon, check_directory_exists, translate
|
||||
from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate
|
||||
from openlp.core.utils import AppLocation, get_web_page, get_filesystem_encoding
|
||||
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
|
||||
|
||||
@ -95,7 +95,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
if self.web_access:
|
||||
files = self.web_access.read()
|
||||
self.config.readfp(io.BytesIO(files))
|
||||
self.updateScreenListCombo()
|
||||
self.update_screen_list_combo()
|
||||
self.was_download_cancelled = False
|
||||
self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading %s...')
|
||||
QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'),
|
||||
@ -103,8 +103,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'),
|
||||
self.onNoInternetFinishButtonClicked)
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'),
|
||||
self.updateScreenListCombo)
|
||||
Registry().register_function(u'config_screen_changed', self.update_screen_list_combo)
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
@ -227,7 +226,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self._postWizard()
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
def updateScreenListCombo(self):
|
||||
def update_screen_list_combo(self):
|
||||
"""
|
||||
The user changed screen resolution or enabled/disabled more screens, so
|
||||
we need to update the combo box.
|
||||
@ -294,8 +293,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
item = self.themesListWidget.item(index)
|
||||
if item.data(QtCore.Qt.UserRole) == filename:
|
||||
break
|
||||
item.setIcon(build_icon(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp',
|
||||
screenshot)))
|
||||
item.setIcon(build_icon(os.path.join(unicode(gettempdir(),
|
||||
get_filesystem_encoding()), u'openlp', screenshot)))
|
||||
|
||||
def _getFileSize(self, url):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, SettingsTab, ScreenList, UiStrings, translate
|
||||
from openlp.core.lib import Registry, Settings, SettingsTab, ScreenList, UiStrings, translate
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -199,7 +199,7 @@ class GeneralTab(SettingsTab):
|
||||
QtCore.QObject.connect(self.customXValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
|
||||
QtCore.QObject.connect(self.monitorComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged)
|
||||
# Reload the tab, as the screen resolution/count may have changed.
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.load)
|
||||
Registry().register_function(u'config_screen_changed', self.load)
|
||||
# Remove for now
|
||||
self.usernameLabel.setVisible(False)
|
||||
self.usernameEdit.setVisible(False)
|
||||
@ -315,7 +315,7 @@ class GeneralTab(SettingsTab):
|
||||
Apply settings after settings tab has loaded and most of the
|
||||
system so must be delayed
|
||||
"""
|
||||
Receiver.send_message(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value())
|
||||
Registry().execute(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value())
|
||||
# Do not continue on start up.
|
||||
if not postUpdate:
|
||||
return
|
||||
@ -331,7 +331,7 @@ class GeneralTab(SettingsTab):
|
||||
else:
|
||||
self.screens.reset_current_display()
|
||||
if self.display_changed:
|
||||
Receiver.send_message(u'config_screen_changed')
|
||||
Registry().execute(u'config_screen_changed')
|
||||
self.display_changed = False
|
||||
|
||||
def onOverrideRadioButtonPressed(self, checked):
|
||||
|
@ -42,7 +42,7 @@ import sys
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Receiver, ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \
|
||||
from openlp.core.lib import ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \
|
||||
image_to_byte, translate
|
||||
from openlp.core.lib.theme import BackgroundType
|
||||
|
||||
@ -158,10 +158,10 @@ class MainDisplay(Display):
|
||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
self.setTransparency(False)
|
||||
if self.isLive:
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_show'), self.showDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_display_css'), self.cssChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged)
|
||||
Registry().register_function(u'live_display_hide', self.hide_display)
|
||||
Registry().register_function(u'live_display_show', self.show_display)
|
||||
Registry().register_function(u'update_display_css', self.css_changed)
|
||||
Registry().register_function(u'config_updated', self.config_changed)
|
||||
|
||||
def setTransparency(self, enabled):
|
||||
"""
|
||||
@ -174,13 +174,13 @@ class MainDisplay(Display):
|
||||
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled)
|
||||
self.repaint()
|
||||
|
||||
def cssChanged(self):
|
||||
def css_changed(self):
|
||||
"""
|
||||
We may need to rebuild the CSS on the live display.
|
||||
"""
|
||||
self.rebuildCSS = True
|
||||
|
||||
def configChanged(self):
|
||||
def config_changed(self):
|
||||
"""
|
||||
Call the plugins to rebuild the Live display CSS as the screen has
|
||||
not been rebuild on exit of config.
|
||||
@ -362,7 +362,7 @@ class MainDisplay(Display):
|
||||
# if was hidden keep it hidden
|
||||
if self.isLive:
|
||||
if self.hideMode:
|
||||
self.hideDisplay(self.hideMode)
|
||||
self.hide_display(self.hideMode)
|
||||
else:
|
||||
# Single screen active
|
||||
if self.screens.display_count == 1:
|
||||
@ -387,11 +387,11 @@ class MainDisplay(Display):
|
||||
if self.override:
|
||||
# We have an video override so allow it to be stopped.
|
||||
if u'video' in self.override:
|
||||
Receiver.send_message(u'video_background_replaced')
|
||||
Registry().execute(u'video_background_replaced')
|
||||
self.override = {}
|
||||
# We have a different theme.
|
||||
elif self.override[u'theme'] != serviceItem.themedata.background_filename:
|
||||
Receiver.send_message(u'live_theme_changed')
|
||||
Registry().execute(u'live_theme_changed')
|
||||
self.override = {}
|
||||
else:
|
||||
# replace the background
|
||||
@ -417,9 +417,9 @@ class MainDisplay(Display):
|
||||
# if was hidden keep it hidden
|
||||
if self.hideMode and self.isLive and not serviceItem.is_media():
|
||||
if Settings().value(u'general/auto unblank'):
|
||||
Receiver.send_message(u'slidecontroller_live_unblank')
|
||||
Registry().execute(u'slidecontroller_live_unblank')
|
||||
else:
|
||||
self.hideDisplay(self.hideMode)
|
||||
self.hide_display(self.hideMode)
|
||||
self.__hideMouse()
|
||||
|
||||
def footer(self, text):
|
||||
@ -430,12 +430,12 @@ class MainDisplay(Display):
|
||||
js = u'show_footer(\'' + text.replace(u'\\', u'\\\\').replace(u'\'', u'\\\'') + u'\')'
|
||||
self.frame.evaluateJavaScript(js)
|
||||
|
||||
def hideDisplay(self, mode=HideMode.Screen):
|
||||
def hide_display(self, mode=HideMode.Screen):
|
||||
"""
|
||||
Hide the display by making all layers transparent
|
||||
Store the images so they can be replaced when required
|
||||
"""
|
||||
log.debug(u'hideDisplay mode = %d', mode)
|
||||
log.debug(u'hide_display mode = %d', mode)
|
||||
if self.screens.display_count == 1:
|
||||
# Only make visible if setting enabled.
|
||||
if not Settings().value(u'general/display on monitor'):
|
||||
@ -453,13 +453,13 @@ class MainDisplay(Display):
|
||||
self.webView.setVisible(True)
|
||||
self.hideMode = mode
|
||||
|
||||
def showDisplay(self):
|
||||
def show_display(self):
|
||||
"""
|
||||
Show the stored layers so the screen reappears as it was
|
||||
originally.
|
||||
Make the stored images None to release memory.
|
||||
"""
|
||||
log.debug(u'showDisplay')
|
||||
log.debug(u'show_display')
|
||||
if self.screens.display_count == 1:
|
||||
# Only make visible if setting enabled.
|
||||
if not Settings().value(u'general/display on monitor'):
|
||||
@ -470,7 +470,7 @@ class MainDisplay(Display):
|
||||
self.hideMode = None
|
||||
# Trigger actions when display is active again.
|
||||
if self.isLive:
|
||||
Receiver.send_message(u'live_display_active')
|
||||
Registry().execute(u'live_display_active')
|
||||
|
||||
def __hideMouse(self):
|
||||
"""
|
||||
|
@ -41,7 +41,7 @@ from datetime import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, Receiver, ImageManager, PluginStatus, Registry, \
|
||||
from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, Registry, \
|
||||
Settings, ScreenList, build_icon, check_directory_exists, translate
|
||||
from openlp.core.lib.ui import UiStrings, create_action
|
||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
|
||||
@ -484,9 +484,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.formattingTagForm = FormattingTagForm(self)
|
||||
self.shortcutForm = ShortcutListForm(self)
|
||||
self.recentFiles = []
|
||||
self.timer_id = 0
|
||||
self.timer_version_id = 0
|
||||
# Set up the path with plugins
|
||||
plugin_path = AppLocation.get_directory(AppLocation.PluginsDir)
|
||||
self.plugin_manager = PluginManager(plugin_path)
|
||||
self.plugin_manager = PluginManager()
|
||||
self.imageManager = ImageManager()
|
||||
# Set up the interface
|
||||
self.setupUi(self)
|
||||
@ -497,8 +498,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# Once settings are loaded update the menu with the recent files.
|
||||
self.updateRecentFilesMenu()
|
||||
self.pluginForm = PluginForm(self)
|
||||
self.newDataPath = u''
|
||||
self.copyData = False
|
||||
self.new_data_path = None
|
||||
self.copy_data = False
|
||||
# Set up signals and slots
|
||||
QtCore.QObject.connect(self.importThemeItem, QtCore.SIGNAL(u'triggered()'),
|
||||
self.themeManagerContents.on_import_theme)
|
||||
@ -528,30 +529,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.QObject.connect(self.modeDefaultItem, QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked)
|
||||
QtCore.QObject.connect(self.modeSetupItem, QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked)
|
||||
QtCore.QObject.connect(self.modeLiveItem, QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mainwindow_status_text'),
|
||||
self.showStatusMessage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up)
|
||||
# Media Manager
|
||||
QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
|
||||
self.application.set_busy_cursor()
|
||||
# Simple message boxes
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'),
|
||||
self.onInformationMessage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_copy_data'), self.setCopyData)
|
||||
# warning cyclic dependency
|
||||
# renderer needs to call ThemeManager and
|
||||
# ThemeManager needs to call Renderer
|
||||
Registry().register_function(u'theme_update_global', self.default_theme_changed)
|
||||
Registry().register_function(u'openlp_version_check', self.version_notice)
|
||||
Registry().register_function(u'config_screen_changed', self.screen_changed)
|
||||
self.renderer = Renderer()
|
||||
# Define the media Dock Manager
|
||||
self.mediaDockManager = MediaDockManager(self.mediaToolBox)
|
||||
log.info(u'Load Plugins')
|
||||
self.plugin_manager.find_plugins(plugin_path)
|
||||
self.plugin_manager.find_plugins()
|
||||
# hook methods have to happen after find_plugins. Find plugins needs
|
||||
# the controllers hence the hooks have moved from setupUI() to here
|
||||
# Find and insert settings tabs
|
||||
@ -582,8 +571,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# Once all components are initialised load the Themes
|
||||
log.info(u'Load Themes')
|
||||
self.themeManagerContents.load_themes(True)
|
||||
# Hide/show the theme combobox on the service manager
|
||||
self.serviceManagerContents.theme_change()
|
||||
# Reset the cursor
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
@ -603,16 +590,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
if widget:
|
||||
widget.onFocus()
|
||||
|
||||
def versionNotice(self, version):
|
||||
def version_notice(self, version):
|
||||
"""
|
||||
Notifies the user that a newer version of OpenLP is available.
|
||||
Triggered by delay thread.
|
||||
Triggered by delay thread and cannot display popup.
|
||||
"""
|
||||
log.debug(u'version_notice')
|
||||
version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are '
|
||||
'currently running version %s). \n\nYou can download the latest version from http://openlp.org/.')
|
||||
QtGui.QMessageBox.question(self,
|
||||
translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
||||
version_text % (version, get_application_version()[u'full']))
|
||||
self.version_text = version_text % (version, get_application_version()[u'full'])
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
@ -632,6 +618,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.serviceManagerContents.load_file(filename)
|
||||
elif Settings().value(self.generalSettingsSection + u'/auto open'):
|
||||
self.serviceManagerContents.load_Last_file()
|
||||
self.timer_version_id = self.startTimer(1000)
|
||||
view_mode = Settings().value(u'%s/view mode' % self.generalSettingsSection)
|
||||
if view_mode == u'default':
|
||||
self.modeDefaultItem.setChecked(True)
|
||||
@ -701,13 +688,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.themeManagerContents.config_updated()
|
||||
self.themeManagerContents.load_themes(True)
|
||||
Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme)
|
||||
Registry().execute(u'theme_update_global', self.themeManagerContents.global_theme)
|
||||
# Check if any Bibles downloaded. If there are, they will be
|
||||
# processed.
|
||||
Receiver.send_message(u'bibles_load_list', True)
|
||||
Registry().execute(u'bibles_load_list', True)
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
def blankCheck(self):
|
||||
def is_display_blank(self):
|
||||
"""
|
||||
Check and display message if screen blank on setup.
|
||||
"""
|
||||
@ -718,26 +705,44 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
|
||||
translate('OpenLP.MainWindow', 'The Main Display has been blanked out'))
|
||||
|
||||
def onErrorMessage(self, data):
|
||||
def error_message(self, title, message):
|
||||
"""
|
||||
Display an error message
|
||||
"""
|
||||
self.application.close_splash_screen()
|
||||
QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
|
||||
|
||||
def warning_message(self, message):
|
||||
``title``
|
||||
The title of the warning box.
|
||||
|
||||
``message``
|
||||
The message to be displayed.
|
||||
"""
|
||||
self.application.splash.close()
|
||||
QtGui.QMessageBox.critical(self, title, message)
|
||||
|
||||
def warning_message(self, title, message):
|
||||
"""
|
||||
Display a warning message
|
||||
"""
|
||||
self.application.close_splash_screen()
|
||||
QtGui.QMessageBox.warning(self, message[u'title'], message[u'message'])
|
||||
|
||||
def onInformationMessage(self, data):
|
||||
``title``
|
||||
The title of the warning box.
|
||||
|
||||
``message``
|
||||
The message to be displayed.
|
||||
"""
|
||||
self.application.splash.close()
|
||||
QtGui.QMessageBox.warning(self, title, message)
|
||||
|
||||
def information_message(self, title, message):
|
||||
"""
|
||||
Display an informational message
|
||||
|
||||
``title``
|
||||
The title of the warning box.
|
||||
|
||||
``message``
|
||||
The message to be displayed.
|
||||
"""
|
||||
self.application.close_splash_screen()
|
||||
QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
|
||||
self.application.splash.close()
|
||||
QtGui.QMessageBox.information(self, title, message)
|
||||
|
||||
def onHelpWebSiteClicked(self):
|
||||
"""
|
||||
@ -1003,12 +1008,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.setPreviewPanelVisibility(preview)
|
||||
self.setLivePanelVisibility(live)
|
||||
|
||||
def screenChanged(self):
|
||||
def screen_changed(self):
|
||||
"""
|
||||
The screen has changed so we have to update components such as the
|
||||
renderer.
|
||||
"""
|
||||
log.debug(u'screenChanged')
|
||||
log.debug(u'screen_changed')
|
||||
self.application.set_busy_cursor()
|
||||
self.imageManager.update_display()
|
||||
self.renderer.update_display()
|
||||
@ -1081,14 +1086,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# Save settings
|
||||
self.save_settings()
|
||||
# Check if we need to change the data directory
|
||||
if self.newDataPath:
|
||||
if self.new_data_path:
|
||||
self.changeDataDirectory()
|
||||
# Close down the display
|
||||
if self.liveController.display:
|
||||
self.liveController.display.close()
|
||||
self.liveController.display = None
|
||||
# Allow the main process to exit
|
||||
#self.application = None
|
||||
|
||||
def serviceChanged(self, reset=False, serviceName=None):
|
||||
"""
|
||||
@ -1129,13 +1132,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
title = u'%s - %s' % (self.mainTitle, fileName)
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def showStatusMessage(self, message):
|
||||
def show_status_message(self, message):
|
||||
"""
|
||||
Show a message in the status bar
|
||||
"""
|
||||
self.statusBar.showMessage(message)
|
||||
|
||||
def defaultThemeChanged(self, theme):
|
||||
def default_theme_changed(self, theme):
|
||||
"""
|
||||
Update the default theme indicator in the status bar
|
||||
"""
|
||||
@ -1338,34 +1341,45 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.timer_id = 0
|
||||
self.loadProgressBar.hide()
|
||||
self.application.process_events()
|
||||
if event.timerId() == self.timer_version_id:
|
||||
self.timer_version_id = 0
|
||||
# Has the thread passed some data to be displayed so display it and stop all waiting
|
||||
if hasattr(self, u'version_text'):
|
||||
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
||||
self.version_text)
|
||||
else:
|
||||
# the thread has not confirmed it is running or it has not yet sent any data so lets keep waiting
|
||||
if not hasattr(self,u'version_update_running') or self.version_update_running:
|
||||
self.timer_version_id = self.startTimer(1000)
|
||||
self.application.process_events()
|
||||
|
||||
def setNewDataPath(self, new_data_path):
|
||||
def set_new_data_path(self, new_data_path):
|
||||
"""
|
||||
Set the new data path
|
||||
"""
|
||||
self.newDataPath = new_data_path
|
||||
self.new_data_path = new_data_path
|
||||
|
||||
def setCopyData(self, copy_data):
|
||||
def set_copy_data(self, copy_data):
|
||||
"""
|
||||
Set the flag to copy the data
|
||||
"""
|
||||
self.copyData = copy_data
|
||||
self.copy_data = copy_data
|
||||
|
||||
def changeDataDirectory(self):
|
||||
"""
|
||||
Change the data directory.
|
||||
"""
|
||||
log.info(u'Changing data path to %s' % self.newDataPath)
|
||||
log.info(u'Changing data path to %s' % self.new_data_path)
|
||||
old_data_path = unicode(AppLocation.get_data_path())
|
||||
# Copy OpenLP data to new location if requested.
|
||||
self.application.set_busy_cursor()
|
||||
if self.copyData:
|
||||
if self.copy_data:
|
||||
log.info(u'Copying data to new path')
|
||||
try:
|
||||
self.showStatusMessage(
|
||||
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s '
|
||||
'- Please wait for copy to finish').replace('%s', self.newDataPath))
|
||||
dir_util.copy_tree(old_data_path, self.newDataPath)
|
||||
'- Please wait for copy to finish').replace('%s', self.new_data_path))
|
||||
dir_util.copy_tree(old_data_path, self.new_data_path)
|
||||
log.info(u'Copy sucessful')
|
||||
except (IOError, os.error, DistutilsFileError), why:
|
||||
self.application.set_normal_cursor()
|
||||
@ -1379,9 +1393,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
log.info(u'No data copy requested')
|
||||
# Change the location of data directory in config file.
|
||||
settings = QtCore.QSettings()
|
||||
settings.setValue(u'advanced/data path', self.newDataPath)
|
||||
settings.setValue(u'advanced/data path', self.new_data_path)
|
||||
# Check if the new data path is our default.
|
||||
if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir):
|
||||
if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir):
|
||||
settings.remove(u'advanced/data path')
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
|
@ -35,7 +35,7 @@ import os
|
||||
import datetime
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, Receiver, Settings, Registry, UiStrings, translate
|
||||
from openlp.core.lib import OpenLPToolbar, Settings, Registry, UiStrings, translate
|
||||
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.mediaplayer import MediaPlayer
|
||||
@ -107,21 +107,19 @@ class MediaController(object):
|
||||
self.timer.setInterval(200)
|
||||
# Signals
|
||||
self.timer.timeout.connect(self.media_state)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'seekSlider'), self.media_seek_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'volumeSlider'), self.media_volume_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_blank'), self.media_blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_unblank'), self.media_unblank)
|
||||
Registry().register_function(u'playbackPlay', self.media_play_msg)
|
||||
Registry().register_function(u'playbackPause', self.media_pause_msg)
|
||||
Registry().register_function(u'playbackStop', self.media_stop_msg)
|
||||
Registry().register_function(u'seekSlider', self.media_seek_msg)
|
||||
Registry().register_function(u'volumeSlider', self.media_volume_msg)
|
||||
Registry().register_function(u'media_hide', self.media_hide)
|
||||
Registry().register_function(u'media_blank', self.media_blank)
|
||||
Registry().register_function(u'media_unblank', self.media_unblank)
|
||||
# Signals for background video
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_unblank'), self.media_unblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'),
|
||||
self._set_active_players)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'),
|
||||
self._generate_extensions_lists)
|
||||
Registry().register_function(u'songs_hide', self.media_hide)
|
||||
Registry().register_function(u'songs_unblank', self.media_unblank)
|
||||
Registry().register_function(u'mediaitem_media_rebuild', self._set_active_players)
|
||||
Registry().register_function(u'mediaitem_suffixes', self._generate_extensions_lists)
|
||||
|
||||
def _set_active_players(self):
|
||||
"""
|
||||
@ -694,7 +692,7 @@ class MediaController(object):
|
||||
hide_mode = msg[2]
|
||||
if not isLive:
|
||||
return
|
||||
Receiver.send_message(u'live_display_hide', hide_mode)
|
||||
Registry().execute(u'live_display_hide', hide_mode)
|
||||
controller = self.mainWindow.liveController
|
||||
display = self._define_display(controller)
|
||||
if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing:
|
||||
@ -709,7 +707,7 @@ class MediaController(object):
|
||||
First element is not relevant in this context
|
||||
Second element is the boolean for Live indication
|
||||
"""
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Registry().execute(u'live_display_show')
|
||||
isLive = msg[1]
|
||||
if not isLive:
|
||||
return
|
||||
|
@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab fo
|
||||
"""
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate
|
||||
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
|
||||
from openlp.core.lib.ui import create_button
|
||||
from openlp.core.ui.media import get_media_players, set_media_players
|
||||
|
||||
@ -229,8 +229,8 @@ class PlayerTab(SettingsTab):
|
||||
player_string_changed = True
|
||||
if player_string_changed:
|
||||
self.service_manager.reset_supported_suffixes()
|
||||
Receiver.send_message(u'mediaitem_media_rebuild')
|
||||
Receiver.send_message(u'config_screen_changed')
|
||||
Registry().execute(u'mediaitem_media_rebuild')
|
||||
Registry().execute(u'config_screen_changed')
|
||||
|
||||
def postSetUp(self, postUpdate=False):
|
||||
"""
|
||||
|
@ -36,7 +36,7 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from lxml import html
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, UiStrings, Registry, translate, get_text_file_string
|
||||
from openlp.core.lib import Settings, UiStrings, Registry, translate, get_text_file_string
|
||||
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
@ -408,7 +408,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
return
|
||||
for item in self.service_manager.serviceItems:
|
||||
# Trigger Audit requests
|
||||
Receiver.send_message(u'print_service_started', [item[u'service_item']])
|
||||
Registry().register_function(u'print_service_started', [item[u'service_item']])
|
||||
|
||||
def _get_service_manager(self):
|
||||
"""
|
||||
|
@ -42,7 +42,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, ItemCapabilities, Settings, PluginStatus, Registry, \
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, Settings, PluginStatus, Registry, \
|
||||
UiStrings, build_icon, translate, str_to_bool, check_directory_exists
|
||||
from openlp.core.lib.theme import ThemeLevel
|
||||
from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box
|
||||
@ -210,11 +210,10 @@ class ServiceManagerDialog(object):
|
||||
self.collapsed)
|
||||
QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'),
|
||||
self.expanded)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'),
|
||||
self.regenerate_service_Items)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change)
|
||||
Registry().register_function(u'theme_update_list', self.update_theme_list)
|
||||
Registry().register_function(u'config_updated', self.config_updated)
|
||||
Registry().register_function(u'config_screen_changed', self.regenerate_service_Items)
|
||||
Registry().register_function(u'theme_update_global', self.theme_change)
|
||||
# Last little bits of setting up
|
||||
self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme')
|
||||
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
||||
@ -555,10 +554,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
zip_file.write(audio_from, audio_to.encode(u'utf-8'))
|
||||
except IOError:
|
||||
log.exception(u'Failed to save service to disk: %s', temp_file_name)
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'),
|
||||
u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
|
||||
})
|
||||
self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'),
|
||||
translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
|
||||
)
|
||||
success = False
|
||||
finally:
|
||||
if zip_file:
|
||||
@ -613,10 +611,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
zip_file.writestr(service_file_name.encode(u'utf-8'), service_content)
|
||||
except IOError:
|
||||
log.exception(u'Failed to save service to disk: %s', temp_file_name)
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'),
|
||||
u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
|
||||
})
|
||||
self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'),
|
||||
translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
|
||||
)
|
||||
success = False
|
||||
finally:
|
||||
if zip_file:
|
||||
@ -736,7 +733,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
service_item.validate_item(self.suffixes)
|
||||
self.load_item_unique_identifier = 0
|
||||
if service_item.is_capable(ItemCapabilities.OnLoadUpdate):
|
||||
Receiver.send_message(u'%s_service_load' % service_item.name.lower(), service_item)
|
||||
Registry().execute(u'%s_service_load' % service_item.name.lower(), service_item)
|
||||
# if the item has been processed
|
||||
if service_item.unique_identifier == self.load_item_unique_identifier:
|
||||
service_item.edit_id = int(self.load_item_edit_id)
|
||||
@ -1237,13 +1234,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
"""
|
||||
Set the theme for the current service.
|
||||
"""
|
||||
log.debug(u'ontheme_combo_box_selected')
|
||||
log.debug(u'on_theme_combo_box_selected')
|
||||
self.service_theme = self.theme_combo_box.currentText()
|
||||
self.renderer.set_service_theme(self.service_theme)
|
||||
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme)
|
||||
self.regenerate_service_Items(True)
|
||||
|
||||
def theme_change(self):
|
||||
def theme_change(self, global_theme):
|
||||
"""
|
||||
The theme may have changed in the settings dialog so make
|
||||
sure the theme combo box is in the correct state.
|
||||
@ -1439,7 +1436,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
Saves the current text item as a custom slide
|
||||
"""
|
||||
item = self.find_service_item()[0]
|
||||
Receiver.send_message(u'custom_create_from_service', self.service_items[item][u'service_item'])
|
||||
Registry().execute(u'custom_create_from_service', self.service_items[item][u'service_item'])
|
||||
|
||||
def find_service_item(self):
|
||||
"""
|
||||
@ -1526,7 +1523,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
replace = True
|
||||
else:
|
||||
self.drop_position = self._get_parent_item_data(item)
|
||||
Receiver.send_message(u'%s_add_service_item' % plugin, replace)
|
||||
Registry().execute(u'%s_add_service_item' % plugin, replace)
|
||||
|
||||
def update_theme_list(self, theme_list):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, PluginStatus, Registry, build_icon
|
||||
from openlp.core.lib import PluginStatus, Registry, build_icon
|
||||
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
|
||||
from openlp.core.ui.media import PlayerTab
|
||||
from settingsdialog import Ui_SettingsDialog
|
||||
@ -107,7 +107,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
for tabIndex in range(self.stackedLayout.count()):
|
||||
self.stackedLayout.widget(tabIndex).save()
|
||||
# Must go after all settings are save
|
||||
Receiver.send_message(u'config_updated')
|
||||
Registry().execute(u'config_updated')
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
|
@ -438,12 +438,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
||||
if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
|
||||
is_valid = False
|
||||
if not is_valid:
|
||||
self.main_window.warning_message( {
|
||||
u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
|
||||
u'message': translate('OpenLP.ShortcutListDialog',
|
||||
'The shortcut "%s" is already assigned to another action, '
|
||||
'please use a different shortcut.') % key_sequence.toString()
|
||||
})
|
||||
self.main_window.warning_message( translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
|
||||
translate('OpenLP.ShortcutListDialog',
|
||||
'The shortcut "%s" is already assigned to another action, please use a different shortcut.') %
|
||||
key_sequence.toString()
|
||||
)
|
||||
return is_valid
|
||||
|
||||
def _actionShortcuts(self, action):
|
||||
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`slidecontroller` module contains argubly the most important part of OpenLP - the slide controller
|
||||
The :mod:`slidecontroller` module contains the most important part of OpenLP - the slide controller
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
@ -36,7 +36,7 @@ from collections import deque
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \
|
||||
from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \
|
||||
ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate
|
||||
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
|
||||
from openlp.core.lib.ui import create_action
|
||||
@ -66,7 +66,7 @@ class DisplayController(QtGui.QWidget):
|
||||
"""
|
||||
sender = self.sender().objectName() if self.sender().objectName() else self.sender().text()
|
||||
controller = self
|
||||
Receiver.send_message('%s' % sender, [controller, args])
|
||||
Registry().execute('%s' % sender, [controller, args])
|
||||
|
||||
|
||||
class SlideController(DisplayController):
|
||||
@ -107,7 +107,7 @@ class SlideController(DisplayController):
|
||||
self.selectedRow = 0
|
||||
self.serviceItem = None
|
||||
self.slide_limits = None
|
||||
self.updateSlideLimits()
|
||||
self.update_slide_limits()
|
||||
self.panel = QtGui.QWidget(parent.controlSplitter)
|
||||
self.slideList = {}
|
||||
# Layout for holding panel
|
||||
@ -169,13 +169,13 @@ class SlideController(DisplayController):
|
||||
text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
|
||||
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut,
|
||||
category=self.category, triggers=self.onSlideSelectedPrevious)
|
||||
category=self.category, triggers=self.on_slide_selected_previous)
|
||||
self.toolbar.addAction(self.previousItem)
|
||||
self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
|
||||
text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Move to next.'),
|
||||
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut,
|
||||
category=self.category, triggers=self.onSlideSelectedNextAction)
|
||||
category=self.category, triggers=self.on_slide_selected_next_action)
|
||||
self.toolbar.addAction(self.nextItem)
|
||||
self.toolbar.addSeparator()
|
||||
self.controllerType = DisplayControllerType.Preview
|
||||
@ -362,10 +362,8 @@ class SlideController(DisplayController):
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
|
||||
if self.isLive:
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_spin_delay'), self.receiveSpinDelay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_toggle_display'), self.toggleDisplay)
|
||||
Registry().register_function(u'slidecontroller_live_spin_delay', self.receive_spin_delay)
|
||||
Registry().register_function(u'slidecontroller_toggle_display', self.toggle_display)
|
||||
self.toolbar.setWidgetVisible(self.loopList, False)
|
||||
self.toolbar.setWidgetVisible(self.wideMenu, False)
|
||||
else:
|
||||
@ -377,22 +375,14 @@ class SlideController(DisplayController):
|
||||
self.__addActionsToWidget(self.previewListWidget)
|
||||
else:
|
||||
self.previewListWidget.addActions([self.nextItem, self.previousItem])
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.typePrefix), self.onSlideSelectedNext)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.typePrefix), self.onSlideSelectedPrevious)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.typePrefix), self.onSlideChange)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_set' % self.typePrefix), self.onSlideSelectedIndex)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_blank' % self.typePrefix), self.onSlideBlank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), self.onSlideUnblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_update_slide_limits'), self.updateSlideLimits)
|
||||
Registry().register_function(u'slidecontroller_%s_stop_loop' % self.typePrefix, self.on_stop_loop)
|
||||
Registry().register_function(u'slidecontroller_%s_next' % self.typePrefix, self.on_slide_selected_next)
|
||||
Registry().register_function(u'slidecontroller_%s_previous' % self.typePrefix, self.on_slide_selected_previous)
|
||||
Registry().register_function(u'slidecontroller_%s_change' % self.typePrefix, self.on_slide_change)
|
||||
Registry().register_function(u'slidecontroller_%s_set' % self.typePrefix, self.on_slide_selected_index)
|
||||
Registry().register_function(u'slidecontroller_%s_blank' % self.typePrefix, self.on_slide_blank)
|
||||
Registry().register_function(u'slidecontroller_%s_unblank' % self.typePrefix, self.on_slide_unblank)
|
||||
Registry().register_function(u'slidecontroller_update_slide_limits', self.update_slide_limits)
|
||||
|
||||
def _slideShortcutActivated(self):
|
||||
"""
|
||||
@ -479,7 +469,7 @@ class SlideController(DisplayController):
|
||||
self.display.setVisible(False)
|
||||
self.media_controller.media_stop(self)
|
||||
|
||||
def toggleDisplay(self, action):
|
||||
def toggle_display(self, action):
|
||||
"""
|
||||
Toggle the display settings triggered from remote messages.
|
||||
"""
|
||||
@ -618,13 +608,13 @@ class SlideController(DisplayController):
|
||||
self.__updatePreviewSelection(slide_no)
|
||||
self.slideSelected()
|
||||
|
||||
def receiveSpinDelay(self, value):
|
||||
def receive_spin_delay(self, value):
|
||||
"""
|
||||
Adjusts the value of the ``delaySpinBox`` to the given one.
|
||||
"""
|
||||
self.delaySpinBox.setValue(int(value))
|
||||
|
||||
def updateSlideLimits(self):
|
||||
def update_slide_limits(self):
|
||||
"""
|
||||
Updates the Slide Limits variable from the settings.
|
||||
"""
|
||||
@ -750,14 +740,13 @@ class SlideController(DisplayController):
|
||||
Display the slide number passed
|
||||
"""
|
||||
log.debug(u'processManagerItem live = %s' % self.isLive)
|
||||
self.onStopLoop()
|
||||
self.on_stop_loop()
|
||||
old_item = self.serviceItem
|
||||
# take a copy not a link to the servicemanager copy.
|
||||
self.serviceItem = copy.copy(serviceItem)
|
||||
if old_item and self.isLive and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
|
||||
self._resetBlank()
|
||||
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
|
||||
[serviceItem, self.isLive, self.hideMode(), slideno])
|
||||
Registry().execute(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, self.hideMode(), slideno])
|
||||
self.slideList = {}
|
||||
width = self.parent().controlSplitter.sizes()[self.split]
|
||||
self.previewListWidget.clear()
|
||||
@ -853,10 +842,10 @@ class SlideController(DisplayController):
|
||||
# However opening a new item of the same type will automatically
|
||||
# close the previous, so make sure we don't close the new one.
|
||||
if old_item.is_command() and not serviceItem.is_command():
|
||||
Receiver.send_message(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive])
|
||||
Registry().execute(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive])
|
||||
if old_item.is_media() and not serviceItem.is_media():
|
||||
self.onMediaClose()
|
||||
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem])
|
||||
Registry().execute(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem])
|
||||
|
||||
def __updatePreviewSelection(self, slideno):
|
||||
"""
|
||||
@ -869,7 +858,7 @@ class SlideController(DisplayController):
|
||||
self.__checkUpdateSelectedSlide(slideno)
|
||||
|
||||
# Screen event methods
|
||||
def onSlideSelectedIndex(self, message):
|
||||
def on_slide_selected_index(self, message):
|
||||
"""
|
||||
Go to the requested slide
|
||||
"""
|
||||
@ -877,7 +866,7 @@ class SlideController(DisplayController):
|
||||
if not self.serviceItem:
|
||||
return
|
||||
if self.serviceItem.is_command():
|
||||
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index])
|
||||
Registry().execute(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index])
|
||||
self.updatePreview()
|
||||
else:
|
||||
self.__checkUpdateSelectedSlide(index)
|
||||
@ -898,17 +887,17 @@ class SlideController(DisplayController):
|
||||
elif display_type == u'blanked':
|
||||
self.onBlankDisplay(True)
|
||||
else:
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Registry().execute(u'live_display_show')
|
||||
else:
|
||||
self.liveEscape()
|
||||
|
||||
def onSlideBlank(self):
|
||||
def on_slide_blank(self):
|
||||
"""
|
||||
Handle the slidecontroller blank event
|
||||
"""
|
||||
self.onBlankDisplay(True)
|
||||
|
||||
def onSlideUnblank(self):
|
||||
def on_slide_unblank(self):
|
||||
"""
|
||||
Handle the slidecontroller unblank event
|
||||
"""
|
||||
@ -980,18 +969,18 @@ class SlideController(DisplayController):
|
||||
if self.serviceItem is not None:
|
||||
if hide_mode:
|
||||
if not self.serviceItem.is_command():
|
||||
Receiver.send_message(u'live_display_hide', hide_mode)
|
||||
Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(),
|
||||
Registry().execute(u'live_display_hide', hide_mode)
|
||||
Registry().execute(u'%s_blank' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive, hide_mode])
|
||||
else:
|
||||
if not self.serviceItem.is_command():
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'live_display_show')
|
||||
Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if hide_mode:
|
||||
Receiver.send_message(u'live_display_hide', hide_mode)
|
||||
Registry().execute(u'live_display_hide', hide_mode)
|
||||
else:
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Registry().execute(u'live_display_show')
|
||||
|
||||
def hidePlugin(self, hide):
|
||||
"""
|
||||
@ -1000,17 +989,17 @@ class SlideController(DisplayController):
|
||||
log.debug(u'hidePlugin %s ', hide)
|
||||
if self.serviceItem is not None:
|
||||
if hide:
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'live_display_hide', HideMode.Screen)
|
||||
Registry().execute(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if not self.serviceItem.is_command():
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'live_display_show')
|
||||
Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if hide:
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Registry().execute(u'live_display_hide', HideMode.Screen)
|
||||
else:
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Registry().execute(u'live_display_show')
|
||||
|
||||
def onSlideSelected(self):
|
||||
"""
|
||||
@ -1028,7 +1017,7 @@ class SlideController(DisplayController):
|
||||
if -1 < row < self.previewListWidget.rowCount():
|
||||
if self.serviceItem.is_command():
|
||||
if self.isLive and not start:
|
||||
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
|
||||
Registry().execute(u'%s_slide' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive, row])
|
||||
else:
|
||||
to_display = self.serviceItem.get_rendered_frame(row)
|
||||
@ -1044,16 +1033,16 @@ class SlideController(DisplayController):
|
||||
self.updatePreview()
|
||||
self.selectedRow = row
|
||||
self.__checkUpdateSelectedSlide(row)
|
||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row)
|
||||
Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row)
|
||||
self.display.setFocus()
|
||||
|
||||
def onSlideChange(self, row):
|
||||
def on_slide_change(self, row):
|
||||
"""
|
||||
The slide has been changed. Update the slidecontroller accordingly
|
||||
"""
|
||||
self.__checkUpdateSelectedSlide(row)
|
||||
self.updatePreview()
|
||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row)
|
||||
Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row)
|
||||
|
||||
def updatePreview(self):
|
||||
"""
|
||||
@ -1079,20 +1068,20 @@ class SlideController(DisplayController):
|
||||
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
self.slidePreview.setPixmap(winimg)
|
||||
|
||||
def onSlideSelectedNextAction(self, checked):
|
||||
def on_slide_selected_next_action(self, checked):
|
||||
"""
|
||||
Wrapper function from create_action so we can throw away the
|
||||
incorrect parameter
|
||||
"""
|
||||
self.onSlideSelectedNext()
|
||||
self.on_slide_selected_next()
|
||||
|
||||
def onSlideSelectedNext(self, wrap=None):
|
||||
def on_slide_selected_next(self, wrap=None):
|
||||
"""
|
||||
Go to the next slide.
|
||||
"""
|
||||
if not self.serviceItem:
|
||||
return
|
||||
Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
if self.serviceItem.is_command() and self.isLive:
|
||||
self.updatePreview()
|
||||
else:
|
||||
@ -1113,13 +1102,13 @@ class SlideController(DisplayController):
|
||||
self.__checkUpdateSelectedSlide(row)
|
||||
self.slideSelected()
|
||||
|
||||
def onSlideSelectedPrevious(self):
|
||||
def on_slide_selected_previous(self):
|
||||
"""
|
||||
Go to the previous slide.
|
||||
"""
|
||||
if not self.serviceItem:
|
||||
return
|
||||
Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
if self.serviceItem.is_command() and self.isLive:
|
||||
self.updatePreview()
|
||||
else:
|
||||
@ -1152,7 +1141,7 @@ class SlideController(DisplayController):
|
||||
if hide_mode is None and (self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked()):
|
||||
self.onStartLoop()
|
||||
else:
|
||||
self.onStopLoop()
|
||||
self.on_stop_loop()
|
||||
|
||||
def onStartLoop(self):
|
||||
"""
|
||||
@ -1161,7 +1150,7 @@ class SlideController(DisplayController):
|
||||
if self.previewListWidget.rowCount() > 1:
|
||||
self.timer_id = self.startTimer(int(self.delaySpinBox.value()) * 1000)
|
||||
|
||||
def onStopLoop(self):
|
||||
def on_stop_loop(self):
|
||||
"""
|
||||
Stop the timer loop running
|
||||
"""
|
||||
@ -1233,7 +1222,7 @@ class SlideController(DisplayController):
|
||||
If the timer event is for this window select next slide
|
||||
"""
|
||||
if event.timerId() == self.timer_id:
|
||||
self.onSlideSelectedNext(self.playSlidesLoop.isChecked())
|
||||
self.on_slide_selected_next(self.playSlidesLoop.isChecked())
|
||||
|
||||
def onEditSong(self):
|
||||
"""
|
||||
@ -1259,7 +1248,7 @@ class SlideController(DisplayController):
|
||||
# Live and Preview have issues if we have video or presentations
|
||||
# playing in both at the same time.
|
||||
if self.serviceItem.is_command():
|
||||
Receiver.send_message(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
Registry().execute(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
if self.serviceItem.is_media():
|
||||
self.onMediaClose()
|
||||
self.onGoLive()
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, UiStrings, Registry, translate
|
||||
from openlp.core.lib import UiStrings, Registry, translate
|
||||
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.ui import ThemeLayoutForm
|
||||
@ -88,7 +88,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onFooterPositionCheckBoxStateChanged)
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_line_count'), self.updateLinesText)
|
||||
Registry().register_function(u'theme_line_count', self.updateLinesText)
|
||||
QtCore.QObject.connect(self.mainSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
|
||||
QtCore.QObject.connect(self.lineSpacingSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
|
||||
QtCore.QObject.connect(self.outlineSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
|
||||
|
@ -38,7 +38,7 @@ import re
|
||||
from xml.etree.ElementTree import ElementTree, XML
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import ImageSource, OpenLPToolbar, Receiver, Registry, SettingsManager, Settings, UiStrings, \
|
||||
from openlp.core.lib import ImageSource, OpenLPToolbar, Registry, SettingsManager, Settings, UiStrings, \
|
||||
get_text_file_string, build_icon, translate, check_item_selected, check_directory_exists, create_thumb, \
|
||||
validate_thumb
|
||||
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, BackgroundGradientType
|
||||
@ -62,7 +62,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
Registry().register(u'theme_manager', self)
|
||||
self.settingsSection = u'themes'
|
||||
self.themeForm = ThemeForm(self)
|
||||
self.fileRenameForm = FileRenameForm(self)
|
||||
self.fileRenameForm = FileRenameForm()
|
||||
# start with the layout
|
||||
self.layout = QtGui.QVBoxLayout(self)
|
||||
self.layout.setSpacing(0)
|
||||
@ -125,18 +125,17 @@ class ThemeManager(QtGui.QWidget):
|
||||
self.global_action = create_widget_action(self.menu,
|
||||
text=translate('OpenLP.ThemeManager', 'Set As &Global Default'),
|
||||
icon=u':/general/general_export.png',
|
||||
triggers=self.changeGlobalFromScreen)
|
||||
triggers=self.change_global_from_screen)
|
||||
self.exportAction = create_widget_action(self.menu,
|
||||
text=translate('OpenLP.ThemeManager', '&Export Theme'),
|
||||
icon=u':/general/general_export.png', triggers=self.on_export_theme)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.theme_list_widget,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen)
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.change_global_from_screen)
|
||||
QtCore.QObject.connect(self.theme_list_widget,
|
||||
QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'theme_update_global'), self.change_global_from_tab)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
||||
Registry().register_function(u'theme_update_global', self.change_global_from_tab)
|
||||
Registry().register_function(u'config_updated', self.config_updated)
|
||||
# Variables
|
||||
self.theme_list = []
|
||||
self.path = AppLocation.get_section_data_path(self.settingsSection)
|
||||
@ -166,6 +165,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
Triggered when Config dialog is updated.
|
||||
"""
|
||||
log.debug(u'config_updated')
|
||||
self.global_theme = Settings().value(self.settingsSection + u'/global theme')
|
||||
|
||||
def check_list_state(self, item):
|
||||
@ -215,15 +215,14 @@ class ThemeManager(QtGui.QWidget):
|
||||
if theme_name == new_name:
|
||||
name = translate('OpenLP.ThemeManager', '%s (default)') % new_name
|
||||
self.theme_list_widget.item(count).setText(name)
|
||||
self.deleteToolbarAction.setVisible(
|
||||
item not in self.theme_list_widget.selectedItems())
|
||||
self.deleteToolbarAction.setVisible(item not in self.theme_list_widget.selectedItems())
|
||||
|
||||
def changeGlobalFromScreen(self, index=-1):
|
||||
def change_global_from_screen(self, index=-1):
|
||||
"""
|
||||
Change the global theme when a theme is double clicked upon in the
|
||||
Theme Manager list
|
||||
"""
|
||||
log.debug(u'changeGlobalFromScreen %s', index)
|
||||
log.debug(u'change_global_from_screen %s', index)
|
||||
selected_row = self.theme_list_widget.currentRow()
|
||||
for count in range(0, self.theme_list_widget.count()):
|
||||
item = self.theme_list_widget.item(count)
|
||||
@ -237,7 +236,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme
|
||||
self.theme_list_widget.item(count).setText(name)
|
||||
Settings().setValue(self.settingsSection + u'/global theme', self.global_theme)
|
||||
Receiver.send_message(u'theme_update_global', self.global_theme)
|
||||
Registry().execute(u'theme_update_global', self.global_theme)
|
||||
self._push_themes()
|
||||
|
||||
def onAddTheme(self):
|
||||
@ -464,12 +463,13 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
Notify listeners that the theme list has been updated
|
||||
"""
|
||||
Receiver.send_message(u'theme_update_list', self.get_themes())
|
||||
Registry().execute(u'theme_update_list', self.get_themes())
|
||||
|
||||
def get_themes(self):
|
||||
"""
|
||||
Return the list of loaded themes
|
||||
"""
|
||||
log.debug(u'get themes')
|
||||
return self.theme_list
|
||||
|
||||
def get_theme_data(self, theme_name):
|
||||
@ -479,7 +479,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
``theme_name``
|
||||
Name of the theme to load from file
|
||||
"""
|
||||
log.debug(u'getthemedata for theme %s', theme_name)
|
||||
log.debug(u'get theme data for theme %s', theme_name)
|
||||
xml_file = os.path.join(self.path, unicode(theme_name), unicode(theme_name) + u'.xml')
|
||||
xml = get_text_file_string(xml_file)
|
||||
if not xml:
|
||||
@ -687,6 +687,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
Called to update the themes' preview images.
|
||||
"""
|
||||
log.debug('update_preview_images')
|
||||
self.main_window.displayProgressBar(len(self.theme_list))
|
||||
for theme in self.theme_list:
|
||||
self.main_window.incrementProgressBar()
|
||||
|
@ -31,7 +31,7 @@ The Themes configuration tab
|
||||
"""
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate
|
||||
from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate
|
||||
from openlp.core.lib.theme import ThemeLevel
|
||||
from openlp.core.lib.ui import find_and_set_in_combo_box
|
||||
|
||||
@ -104,7 +104,7 @@ class ThemesTab(SettingsTab):
|
||||
QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onGlobalLevelButtonClicked)
|
||||
QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
|
||||
Registry().register_function(u'theme_update_list', self.update_theme_list)
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
@ -153,13 +153,13 @@ class ThemesTab(SettingsTab):
|
||||
settings.endGroup()
|
||||
self.renderer.set_global_theme(self.global_theme)
|
||||
self.renderer.set_theme_level(self.theme_level)
|
||||
Receiver.send_message(u'theme_update_global', self.global_theme)
|
||||
Registry().execute(u'theme_update_global', self.global_theme)
|
||||
|
||||
def postSetUp(self):
|
||||
"""
|
||||
After setting things up...
|
||||
"""
|
||||
Receiver.send_message(u'theme_update_global', self.global_theme)
|
||||
Registry().execute(u'theme_update_global', self.global_theme)
|
||||
|
||||
def onSongLevelButtonClicked(self):
|
||||
"""
|
||||
@ -187,7 +187,7 @@ class ThemesTab(SettingsTab):
|
||||
self.renderer.set_global_theme(self.global_theme)
|
||||
self.__previewGlobalTheme()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
def update_theme_list(self, theme_list):
|
||||
"""
|
||||
Called from ThemeManager when the Themes have changed.
|
||||
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Registry, Settings, UiStrings, build_icon, translate
|
||||
from openlp.core.lib import Registry, Settings, UiStrings, build_icon, translate
|
||||
from openlp.core.lib.ui import add_welcome_page
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -173,7 +173,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
"""
|
||||
log.debug(u'Wizard cancelled by user.')
|
||||
if self.currentPage() == self.progressPage:
|
||||
Receiver.send_message(u'openlp_stop_wizard')
|
||||
Registry().execute(u'openlp_stop_wizard')
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
|
||||
def onCurrentIdChanged(self, pageId):
|
||||
|
@ -51,7 +51,7 @@ if sys.platform != u'win32' and sys.platform != u'darwin':
|
||||
XDG_BASE_AVAILABLE = False
|
||||
|
||||
import openlp
|
||||
from openlp.core.lib import Receiver, translate, check_directory_exists
|
||||
from openlp.core.lib import translate, check_directory_exists
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
APPLICATION_VERSION = {}
|
||||
@ -72,11 +72,11 @@ class VersionThread(QtCore.QThread):
|
||||
Run the thread.
|
||||
"""
|
||||
self.sleep(1)
|
||||
log.debug(u'Version thread - run')
|
||||
app_version = get_application_version()
|
||||
version = check_latest_version(app_version)
|
||||
if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])):
|
||||
Receiver.send_message(u'openlp_version_check', u'%s' % version)
|
||||
|
||||
Registry().execute(u'openlp_version_check', u'%s' % version)
|
||||
|
||||
class AppLocation(object):
|
||||
"""
|
||||
@ -288,6 +288,8 @@ def check_latest_version(current_version):
|
||||
this_test = datetime.now().date()
|
||||
settings.setValue(u'last version test', this_test)
|
||||
settings.endGroup()
|
||||
# Tell the main window whether there will ever be data to display
|
||||
Registry().get(u'main_window').version_update_running = last_test != this_test
|
||||
if last_test != this_test:
|
||||
if current_version[u'build']:
|
||||
req = urllib2.Request(u'http://www.openlp.org/files/nightly_version.txt')
|
||||
|
@ -199,7 +199,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
||||
self.parameterEdit.setFocus()
|
||||
return False
|
||||
text = text.replace(u'<>', self.parameterEdit.text())
|
||||
self.plugin.alertsmanager.displayAlert(text)
|
||||
self.plugin.alertsmanager.display_alert(text)
|
||||
return True
|
||||
|
||||
def onCurrentRowChanged(self, row):
|
||||
|
@ -35,10 +35,12 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib import Registry, translate
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AlertsManager(QtCore.QObject):
|
||||
"""
|
||||
AlertsManager manages the settings of Alerts.
|
||||
@ -49,19 +51,19 @@ class AlertsManager(QtCore.QObject):
|
||||
QtCore.QObject.__init__(self, parent)
|
||||
self.screen = None
|
||||
self.timer_id = 0
|
||||
self.alertList = []
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_active'), self.generateAlert)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alerts_text'), self.onAlertText)
|
||||
self.alert_list = []
|
||||
Registry().register_function(u'live_display_active', self.generate_alert)
|
||||
Registry().register_function(u'alerts_text', self.alert_text)
|
||||
|
||||
def onAlertText(self, message):
|
||||
def alert_text(self, message):
|
||||
"""
|
||||
Called via a alerts_text event. Message is single element array
|
||||
containing text
|
||||
"""
|
||||
if message:
|
||||
self.displayAlert(message[0])
|
||||
self.display_alert(message[0])
|
||||
|
||||
def displayAlert(self, text=u''):
|
||||
def display_alert(self, text=u''):
|
||||
"""
|
||||
Called from the Alert Tab to display an alert
|
||||
|
||||
@ -70,24 +72,24 @@ class AlertsManager(QtCore.QObject):
|
||||
"""
|
||||
log.debug(u'display alert called %s' % text)
|
||||
if text:
|
||||
self.alertList.append(text)
|
||||
self.alert_list.append(text)
|
||||
if self.timer_id != 0:
|
||||
Receiver.send_message(u'mainwindow_status_text',
|
||||
self.main_window.show_status_message(
|
||||
translate('AlertsPlugin.AlertsManager', 'Alert message created and displayed.'))
|
||||
return
|
||||
Receiver.send_message(u'mainwindow_status_text', u'')
|
||||
self.generateAlert()
|
||||
self.main_window.show_status_message(u'')
|
||||
self.generate_alert()
|
||||
|
||||
def generateAlert(self):
|
||||
def generate_alert(self):
|
||||
"""
|
||||
Format and request the Alert and start the timer
|
||||
"""
|
||||
log.debug(u'Generate Alert called')
|
||||
if not self.alertList:
|
||||
if not self.alert_list:
|
||||
return
|
||||
text = self.alertList.pop(0)
|
||||
text = self.alert_list.pop(0)
|
||||
alertTab = self.parent().settingsTab
|
||||
self.parent().liveController.display.alert(text, alertTab.location)
|
||||
self.live_controller.display.alert(text, alertTab.location)
|
||||
# Check to see if we have a timer running.
|
||||
if self.timer_id == 0:
|
||||
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
|
||||
@ -103,7 +105,27 @@ class AlertsManager(QtCore.QObject):
|
||||
log.debug(u'timer event')
|
||||
if event.timerId() == self.timer_id:
|
||||
alertTab = self.parent().settingsTab
|
||||
self.parent().liveController.display.alert(u'', alertTab.location)
|
||||
self.live_controller.display.alert(u'', alertTab.location)
|
||||
self.killTimer(self.timer_id)
|
||||
self.timer_id = 0
|
||||
self.generateAlert()
|
||||
self.generate_alert()
|
||||
|
||||
def _get_live_controller(self):
|
||||
"""
|
||||
Adds the live controller to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_live_controller'):
|
||||
self._live_controller = Registry().get(u'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, u'_main_window'):
|
||||
self._main_window = Registry().get(u'main_window')
|
||||
return self._main_window
|
||||
|
||||
main_window = property(_get_main_window)
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate
|
||||
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
|
||||
from openlp.core.lib.ui import create_valign_selection_widgets
|
||||
|
||||
class AlertsTab(SettingsTab):
|
||||
@ -174,7 +174,7 @@ class AlertsTab(SettingsTab):
|
||||
settings.setValue(u'location', self.location)
|
||||
settings.endGroup()
|
||||
if self.changed:
|
||||
Receiver.send_message(u'update_display_css')
|
||||
Registry().execute(u'update_display_css')
|
||||
self.changed = False
|
||||
|
||||
def updateDisplay(self):
|
||||
|
@ -36,7 +36,7 @@ from tempfile import gettempdir
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, UiStrings, translate, check_directory_exists
|
||||
from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||
from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding
|
||||
@ -82,7 +82,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
Set up the UI for the bible wizard.
|
||||
"""
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
Registry().execute(u'openlp_stop_wizard', self.stop_import)
|
||||
|
||||
def stop_import(self):
|
||||
"""
|
||||
|
@ -31,7 +31,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, SettingsTab, Settings, UiStrings, translate
|
||||
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
|
||||
from openlp.core.lib.ui import find_and_set_in_combo_box
|
||||
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \
|
||||
get_reference_separator, LanguageSelection
|
||||
@ -168,7 +168,7 @@ class BiblesTab(SettingsTab):
|
||||
self.onEndSeparatorLineEditEdited)
|
||||
QtCore.QObject.connect(self.endSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
|
||||
self.onEndSeparatorLineEditFinished)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
|
||||
Registry().register_function(u'theme_update_list', self.update_theme_list)
|
||||
QtCore.QObject.connect(self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'),
|
||||
self.onLanguageSelectionComboBoxChanged)
|
||||
|
||||
@ -406,10 +406,10 @@ class BiblesTab(SettingsTab):
|
||||
else:
|
||||
settings.remove(u'end separator')
|
||||
update_reference_separators()
|
||||
Receiver.send_message(u'bibles_load_list')
|
||||
Registry().execute(u'bibles_load_list')
|
||||
settings.endGroup()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
def update_theme_list(self, theme_list):
|
||||
"""
|
||||
Called from ThemeManager when the Themes have changed.
|
||||
|
||||
|
@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, Table, or_, types, func
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.lib import Receiver, Registry, translate
|
||||
from openlp.core.lib import Registry, translate
|
||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.utils import AppLocation, clean_filename
|
||||
@ -160,7 +160,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
if u'path' in kwargs:
|
||||
self.path = kwargs[u'path']
|
||||
self.wizard = None
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
Registry().execute(u'openlp_stop_wizard', self.stop_import)
|
||||
|
||||
def stop_import(self):
|
||||
"""
|
||||
|
@ -234,10 +234,8 @@ class BGExtract(object):
|
||||
soup = get_soup_for_bible_ref(
|
||||
u'http://www.biblegateway.com/passage/?%s' % url_params,
|
||||
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='', cleaner=cleaner)
|
||||
self.application.process_events()
|
||||
if not soup:
|
||||
return None
|
||||
self.application.process_events()
|
||||
div = soup.find('div', 'result-text-style-normal')
|
||||
self._clean_soup(div)
|
||||
span_list = div.findAll('span', 'text')
|
||||
@ -296,6 +294,16 @@ class BGExtract(object):
|
||||
books.append(book.contents[0])
|
||||
return books
|
||||
|
||||
def _get_application(self):
|
||||
"""
|
||||
Adds the openlp to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_application'):
|
||||
self._application = Registry().get(u'application')
|
||||
return self._application
|
||||
|
||||
application = property(_get_application)
|
||||
|
||||
|
||||
class BSExtract(object):
|
||||
"""
|
||||
@ -457,6 +465,16 @@ class CWExtract(object):
|
||||
books.append(book.contents[0])
|
||||
return books
|
||||
|
||||
def _get_application(self):
|
||||
"""
|
||||
Adds the openlp to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_application'):
|
||||
self._application = Registry().get(u'application')
|
||||
return self._application
|
||||
|
||||
application = property(_get_application)
|
||||
|
||||
|
||||
class HTTPBible(BibleDB):
|
||||
log.info(u'%s HTTPBible loaded', __name__)
|
||||
|
@ -30,7 +30,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from openlp.core.lib import Receiver, SettingsManager, Settings, translate
|
||||
from openlp.core.lib import Registry, SettingsManager, Settings, translate
|
||||
from openlp.core.utils import AppLocation, delete_file
|
||||
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
||||
@ -304,12 +304,12 @@ class BibleManager(object):
|
||||
log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext)
|
||||
if not bible:
|
||||
if show_error:
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
||||
u'message': translate('BiblesPlugin.BibleManager',
|
||||
self.main_window.information_message(
|
||||
translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
||||
translate('BiblesPlugin.BibleManager',
|
||||
'There are no Bibles currently installed. Please use the '
|
||||
'Import Wizard to install one or more Bibles.')
|
||||
})
|
||||
)
|
||||
return None
|
||||
language_selection = self.get_language_selection(bible)
|
||||
reflist = parse_reference(versetext, self.db_cache[bible],
|
||||
@ -322,14 +322,11 @@ class BibleManager(object):
|
||||
u'verse': get_reference_separator(u'sep_v_display'),
|
||||
u'range': get_reference_separator(u'sep_r_display'),
|
||||
u'list': get_reference_separator(u'sep_l_display')}
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager',
|
||||
'Scripture Reference Error'),
|
||||
u'message': translate('BiblesPlugin.BibleManager',
|
||||
'Your scripture reference is either not supported by '
|
||||
self.main_window.information_message(
|
||||
translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'),
|
||||
translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by '
|
||||
'OpenLP or is invalid. Please make sure your reference '
|
||||
'conforms to one of the following patterns or consult the '
|
||||
'manual:\n\n'
|
||||
'conforms to one of the following patterns or consult the manual:\n\n'
|
||||
'Book Chapter\n'
|
||||
'Book Chapter%(range)sChapter\n'
|
||||
'Book Chapter%(verse)sVerse%(range)sVerse\n'
|
||||
@ -339,9 +336,8 @@ class BibleManager(object):
|
||||
'%(verse)sVerse%(range)sVerse\n'
|
||||
'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse',
|
||||
'Please pay attention to the appended "s" of the wildcards '
|
||||
'and refrain from translating the words inside the '
|
||||
'names in the brackets.') % reference_seperators
|
||||
})
|
||||
'and refrain from translating the words inside the names in the brackets.') % reference_seperators
|
||||
)
|
||||
return None
|
||||
|
||||
def get_language_selection(self, bible):
|
||||
@ -380,36 +376,33 @@ class BibleManager(object):
|
||||
"""
|
||||
log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
|
||||
if not bible:
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
||||
u'message': translate('BiblesPlugin.BibleManager',
|
||||
'There are no Bibles currently installed. Please use the '
|
||||
'Import Wizard to install one or more Bibles.')
|
||||
})
|
||||
self.main_window.information_message(
|
||||
translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
||||
translate('BiblesPlugin.BibleManager',
|
||||
'There are no Bibles currently installed. Please use the Import Wizard to install one or more'
|
||||
' Bibles.')
|
||||
)
|
||||
return None
|
||||
# Check if the bible or second_bible is a web bible.
|
||||
webbible = self.db_cache[bible].get_object(BibleMeta,
|
||||
u'download_source')
|
||||
webbible = self.db_cache[bible].get_object(BibleMeta, u'download_source')
|
||||
second_webbible = u''
|
||||
if second_bible:
|
||||
second_webbible = self.db_cache[second_bible].get_object(BibleMeta,
|
||||
u'download_source')
|
||||
second_webbible = self.db_cache[second_bible].get_object(BibleMeta, u'download_source')
|
||||
if webbible or second_webbible:
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'),
|
||||
u'message': translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.')
|
||||
})
|
||||
self.main_window.information_message(
|
||||
translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'),
|
||||
translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.')
|
||||
)
|
||||
return None
|
||||
if text:
|
||||
return self.db_cache[bible].verse_search(text)
|
||||
else:
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'),
|
||||
u'message': translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\n'
|
||||
'You can separate different keywords by a space to '
|
||||
'search for all of your keywords and you can separate '
|
||||
self.main_window.information_message(
|
||||
translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'),
|
||||
translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\nYou can separate '
|
||||
'different keywords by a space to search for all of your keywords and you can separate '
|
||||
'them by a comma to search for one of them.')
|
||||
})
|
||||
)
|
||||
return None
|
||||
|
||||
def save_meta_data(self, bible, version, copyright, permissions,
|
||||
@ -460,6 +453,16 @@ class BibleManager(object):
|
||||
for bible in self.db_cache:
|
||||
self.db_cache[bible].finalise()
|
||||
|
||||
def _get_main_window(self):
|
||||
"""
|
||||
Adds the main window to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_main_window'):
|
||||
self._main_window = Registry().get(u'main_window')
|
||||
return self._main_window
|
||||
|
||||
main_window = property(_get_main_window)
|
||||
|
||||
BibleFormat.set_availability(BibleFormat.OpenLP1, HAS_OPENLP1)
|
||||
|
||||
__all__ = [u'BibleFormat']
|
||||
|
@ -31,7 +31,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
|
||||
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
|
||||
create_separated_list, translate
|
||||
from openlp.core.lib.searchedit import SearchEdit
|
||||
from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \
|
||||
@ -70,7 +70,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.search_results = {}
|
||||
self.second_search_results = {}
|
||||
self.checkSearchResult()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
|
||||
Registry().register_function(u'bibles_load_list', self.reload_bibles)
|
||||
Registry().register_function(u'config_updated', self.config_update)
|
||||
|
||||
def __checkSecondBible(self, bible, second_bible):
|
||||
"""
|
||||
@ -246,7 +247,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
# Buttons
|
||||
QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton)
|
||||
QtCore.QObject.connect(self.quickSearchButton, QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
# Other stuff
|
||||
QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
|
||||
QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'),
|
||||
@ -258,8 +258,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
else:
|
||||
self.advancedBookComboBox.setFocus()
|
||||
|
||||
def configUpdated(self):
|
||||
log.debug(u'configUpdated')
|
||||
def config_update(self):
|
||||
log.debug(u'config_update')
|
||||
if Settings().value(self.settingsSection + u'/second bibles'):
|
||||
self.advancedSecondLabel.setVisible(True)
|
||||
self.advancedSecondComboBox.setVisible(True)
|
||||
@ -313,7 +313,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
translate('BiblesPlugin.MediaItem', 'Search Text...'))
|
||||
])
|
||||
self.quickSearchEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection))
|
||||
self.configUpdated()
|
||||
self.config_update()
|
||||
log.debug(u'bible manager initialise complete')
|
||||
|
||||
def loadBibles(self):
|
||||
@ -343,7 +343,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
bible = Settings().value(self.settingsSection + u'/quick bible')
|
||||
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
|
||||
|
||||
def reloadBibles(self, process=False):
|
||||
def reload_bibles(self, process=False):
|
||||
log.debug(u'Reloading Bibles')
|
||||
self.plugin.manager.reload_bibles()
|
||||
self.loadBibles()
|
||||
@ -471,7 +471,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.import_wizard = BibleImportForm(self, self.plugin.manager, self.plugin)
|
||||
# If the import was not cancelled then reload.
|
||||
if self.import_wizard.exec_():
|
||||
self.reloadBibles()
|
||||
self.reload_bibles()
|
||||
|
||||
def onEditClick(self):
|
||||
if self.quickTab.isVisible():
|
||||
@ -482,7 +482,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.editBibleForm = EditBibleForm(self, self.main_window, self.plugin.manager)
|
||||
self.editBibleForm.loadBible(bible)
|
||||
if self.editBibleForm.exec_():
|
||||
self.reloadBibles()
|
||||
self.reload_bibles()
|
||||
|
||||
def onDeleteClick(self):
|
||||
if self.quickTab.isVisible():
|
||||
@ -497,7 +497,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
||||
return
|
||||
self.plugin.manager.delete_bible(bible)
|
||||
self.reloadBibles()
|
||||
self.reload_bibles()
|
||||
|
||||
def onSearchTabBarCurrentChanged(self, index):
|
||||
if index == 0:
|
||||
|
@ -31,9 +31,8 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box, \
|
||||
find_and_set_in_combo_box
|
||||
from openlp.core.lib import Registry, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box
|
||||
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
|
||||
from openlp.plugins.custom.lib.db import CustomSlide
|
||||
from editcustomdialog import Ui_CustomEditDialog
|
||||
@ -65,9 +64,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
self.editAllButton.clicked.connect(self.on_edit_all_button_clicked)
|
||||
self.slideListView.currentRowChanged.connect(self.on_current_row_changed)
|
||||
self.slideListView.doubleClicked.connect(self.on_edit_button_clicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
Registry().register_function(u'theme_update_list', self.load_themes)
|
||||
|
||||
def loadThemes(self, theme_list):
|
||||
def load_themes(self, theme_list):
|
||||
"""
|
||||
Load a list of themes into the themes combo box.
|
||||
|
||||
@ -191,7 +190,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
"""
|
||||
log.debug(u'onPreview')
|
||||
if self.saveCustom():
|
||||
Receiver.send_message(u'custom_preview')
|
||||
Registry().execute(u'custom_preview')
|
||||
|
||||
def updateSlideList(self, slides, edit_all=False):
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import or_, func, and_
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, PluginStatus, \
|
||||
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, PluginStatus,\
|
||||
UiStrings, check_item_selected, translate
|
||||
from openlp.plugins.custom.forms import EditCustomForm
|
||||
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder
|
||||
@ -73,11 +73,10 @@ class CustomMediaItem(MediaManagerItem):
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
self.onSearchTextButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_create_from_service'),
|
||||
self.create_from_service_item)
|
||||
Registry().register_function(u'custom_load_list', self.loadList)
|
||||
Registry().register_function(u'custom_preview', self.onPreviewClick)
|
||||
Registry().register_function(u'config_updated', self.config_updated)
|
||||
Registry().register_function(u'custom_create_from_service', self.create_from_service_item)
|
||||
|
||||
def config_updated(self):
|
||||
self.add_custom_from_service = Settings().value(self.settingsSection + u'/add custom from service')
|
||||
@ -280,7 +279,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.plugin.manager.save_object(custom)
|
||||
self.onSearchTextButtonClicked()
|
||||
if item.name.lower() == u'custom':
|
||||
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False))
|
||||
Registry().execute(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False))
|
||||
|
||||
def onClearTextButtonClick(self):
|
||||
"""
|
||||
|
@ -27,17 +27,16 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, build_icon, translate
|
||||
from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, build_icon, translate
|
||||
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__default_settings__ = {
|
||||
u'images/background color': u'#000000',
|
||||
u'images/images files': []
|
||||
}
|
||||
|
||||
@ -50,7 +49,7 @@ class ImagePlugin(Plugin):
|
||||
self.weight = -7
|
||||
self.iconPath = u':/plugins/plugin_images.png'
|
||||
self.icon = build_icon(self.iconPath)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'image_updated'), self.image_updated)
|
||||
Registry().execute(u'image_updated', self.image_updated)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
|
||||
@ -98,4 +97,14 @@ class ImagePlugin(Plugin):
|
||||
last part of saving the config.
|
||||
"""
|
||||
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color'))
|
||||
self.liveController.imageManager.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, u'_image_manager'):
|
||||
self._image_manager = Registry().get(u'image_manager')
|
||||
return self._image_manager
|
||||
|
||||
image_manager = property(_get_image_manager)
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate
|
||||
from openlp.core.lib import SettingsTab, Registry, Settings, UiStrings, translate
|
||||
|
||||
class ImageTab(SettingsTab):
|
||||
"""
|
||||
@ -91,5 +91,5 @@ class ImageTab(SettingsTab):
|
||||
settings.setValue(u'background color', self.bg_color)
|
||||
settings.endGroup()
|
||||
if self.initial_color != self.bg_color:
|
||||
Receiver.send_message(u'image_updated')
|
||||
Registry().execute(u'image_updated')
|
||||
|
||||
|
@ -32,7 +32,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, ItemCapabilities, Receiver, SettingsManager, ServiceItemContext, \
|
||||
from openlp.core.lib import MediaManagerItem, ItemCapabilities, Registry, SettingsManager, ServiceItemContext, \
|
||||
Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, create_thumb, translate, \
|
||||
validate_thumb
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
@ -51,7 +51,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
MediaManagerItem.__init__(self, parent, plugin, icon)
|
||||
self.quickPreviewAllowed = True
|
||||
self.hasSearch = True
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
||||
Registry().register_function(u'live_theme_changed', self.live_theme_changed)
|
||||
# Allow DnD from the desktop
|
||||
self.listView.activateDnD()
|
||||
|
||||
@ -194,7 +194,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
self.live_controller.display.resetImage()
|
||||
|
||||
def liveThemeChanged(self):
|
||||
def live_theme_changed(self):
|
||||
"""
|
||||
Triggered by the change of theme in the slide controller
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Receiver, ServiceItem, ServiceItemContext, \
|
||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \
|
||||
Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||
from openlp.core.ui import DisplayController, Display, DisplayControllerType
|
||||
@ -71,10 +71,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()}
|
||||
self.displayController.previewDisplay.setup()
|
||||
self.media_controller.setup_display(self.displayController.previewDisplay, False)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'),
|
||||
self.videobackgroundReplaced)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.displaySetup)
|
||||
Registry().register_function(u'video_background_replaced', self.video_background_replaced)
|
||||
Registry().register_function(u'mediaitem_media_rebuild', self.rebuild_players)
|
||||
Registry().register_function(u'config_screen_changed', self.display_setup)
|
||||
# Allow DnD from the desktop
|
||||
self.listView.activateDnD()
|
||||
|
||||
@ -133,7 +132,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.media_controller.media_reset(self.live_controller)
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def videobackgroundReplaced(self):
|
||||
def video_background_replaced(self):
|
||||
"""
|
||||
Triggered by main display on change of serviceitem.
|
||||
"""
|
||||
@ -214,7 +213,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
u' '.join(self.media_controller.video_extensions_list),
|
||||
u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles)
|
||||
|
||||
def displaySetup(self):
|
||||
def display_setup(self):
|
||||
self.media_controller.setup_display(self.displayController.previewDisplay, False)
|
||||
|
||||
def populateDisplayTypes(self):
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate
|
||||
from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate
|
||||
|
||||
class MediaQCheckBox(QtGui.QCheckBox):
|
||||
"""
|
||||
@ -84,5 +84,5 @@ class MediaTab(SettingsTab):
|
||||
Settings().setValue(setting_key, self.autoStartCheckBox.checkState())
|
||||
if override_changed:
|
||||
self.parent.reset_supported_suffixes()
|
||||
Receiver.send_message(u'mediaitem_media_rebuild')
|
||||
Receiver.send_message(u'mediaitem_suffixes')
|
||||
Registry().execute(u'mediaitem_media_rebuild')
|
||||
Registry().execute(u'mediaitem_suffixes')
|
||||
|
@ -58,6 +58,7 @@ else:
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import ScreenList
|
||||
from openlp.core.utils import delete_file, get_uno_command, get_uno_instance
|
||||
from presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
@ -254,7 +255,7 @@ class ImpressDocument(PresentationDocument):
|
||||
window = self.document.getCurrentController().getFrame().getContainerWindow()
|
||||
window.setVisible(False)
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.Display = self.controller.plugin.renderer.screens.current[u'number'] + 1
|
||||
self.presentation.Display = ScreenList().current[u'number'] + 1
|
||||
self.control = None
|
||||
self.create_thumbnails()
|
||||
return True
|
||||
|
@ -32,7 +32,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
|
||||
from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
|
||||
build_icon, check_item_selected, create_thumb, translate, validate_thumb
|
||||
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||
from openlp.core.utils import locale_compare
|
||||
@ -60,9 +60,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.message_listener = MessageListener(self)
|
||||
self.hasSearch = True
|
||||
self.singleServiceItem = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'),
|
||||
self.populateDisplayTypes)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString)
|
||||
Registry().register_function(u'mediaitem_presentation_rebuild', self.populate_display_types)
|
||||
Registry().register_function(u'mediaitem_suffixes', self.build_file_mask_string)
|
||||
# Allow DnD from the desktop
|
||||
self.listView.activateDnD()
|
||||
|
||||
@ -74,7 +73,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic')
|
||||
self.displayTypeLabel.setText(translate('PresentationPlugin.MediaItem', 'Present using:'))
|
||||
|
||||
def buildFileMaskString(self):
|
||||
def build_file_mask_string(self):
|
||||
"""
|
||||
Build the list of file extensions to be used in the Open file dialog
|
||||
"""
|
||||
@ -122,9 +121,9 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.listView.setIconSize(QtCore.QSize(88, 50))
|
||||
files = Settings().value(self.settingsSection + u'/presentations files')
|
||||
self.loadList(files, True)
|
||||
self.populateDisplayTypes()
|
||||
self.populate_display_types()
|
||||
|
||||
def populateDisplayTypes(self):
|
||||
def populate_display_types(self):
|
||||
"""
|
||||
Load the combobox with the enabled presentation controllers,
|
||||
allowing user to select a specific app if settings allow
|
||||
|
@ -31,7 +31,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.lib import Registry
|
||||
from openlp.core.ui import HideMode
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -71,7 +71,7 @@ class Controller(object):
|
||||
self.hide_mode = hide_mode
|
||||
if self.is_live:
|
||||
if hide_mode == HideMode.Screen:
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Registry().execute(u'live_display_hide', HideMode.Screen)
|
||||
self.stop()
|
||||
elif hide_mode == HideMode.Theme:
|
||||
self.blank(hide_mode)
|
||||
@ -79,7 +79,7 @@ class Controller(object):
|
||||
self.blank(hide_mode)
|
||||
else:
|
||||
self.doc.start_presentation()
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Registry().execute(u'live_display_hide', HideMode.Screen)
|
||||
self.doc.slidenumber = 1
|
||||
if slide_no > 1:
|
||||
self.slide(slide_no)
|
||||
@ -236,7 +236,7 @@ class Controller(object):
|
||||
return
|
||||
if not self.doc.is_active():
|
||||
return
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Theme)
|
||||
Registry().execute(u'live_display_hide', HideMode.Theme)
|
||||
elif hide_mode == HideMode.Blank:
|
||||
if not self.activate():
|
||||
return
|
||||
@ -273,7 +273,7 @@ class Controller(object):
|
||||
if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number():
|
||||
self.doc.goto_slide(self.doc.slidenumber)
|
||||
self.doc.unblank_screen()
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Registry().execute(u'live_display_hide', HideMode.Screen)
|
||||
|
||||
def poll(self):
|
||||
if not self.doc:
|
||||
@ -294,16 +294,16 @@ class MessageListener(object):
|
||||
self.preview_handler = Controller(False)
|
||||
self.live_handler = Controller(True)
|
||||
# messages are sent from core.ui.slidecontroller
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_start'), self.startup)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_hide'), self.hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_first'), self.first)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_previous'), self.previous)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_next'), self.next)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_last'), self.last)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_slide'), self.slide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_blank'), self.blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
|
||||
Registry().register_function(u'presentations_start', self.startup)
|
||||
Registry().register_function(u'presentations_stop', self.shutdown)
|
||||
Registry().register_function(u'presentations_hide', self.hide)
|
||||
Registry().register_function(u'presentations_first', self.first)
|
||||
Registry().register_function(u'presentations_previous', self.previous)
|
||||
Registry().register_function(u'presentations_next', self.next)
|
||||
Registry().register_function(u'presentations_last', self.last)
|
||||
Registry().register_function(u'presentations_slide', self.slide)
|
||||
Registry().register_function(u'presentations_blank', self.blank)
|
||||
Registry().register_function(u'presentations_unblank', self.unblank)
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(500)
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout)
|
||||
|
@ -36,6 +36,7 @@ if os.name == u'nt':
|
||||
import win32ui
|
||||
import pywintypes
|
||||
|
||||
from openlp.core.lib import ScreenList
|
||||
from presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -252,8 +253,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
|
||||
except win32ui.error:
|
||||
dpi = 96
|
||||
renderer = self.controller.plugin.renderer
|
||||
rect = renderer.screens.current[u'size']
|
||||
rect = ScreenList().current[u'size']
|
||||
ppt_window = self.presentation.SlideShowSettings.Run()
|
||||
if not ppt_window:
|
||||
return
|
||||
|
@ -34,6 +34,7 @@ if os.name == u'nt':
|
||||
from ctypes import cdll
|
||||
from ctypes.wintypes import RECT
|
||||
|
||||
from openlp.core.lib import ScreenList
|
||||
from presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -83,7 +84,7 @@ class PptviewController(PresentationController):
|
||||
if self.process:
|
||||
return
|
||||
log.debug(u'start PPTView')
|
||||
dllpath = os.path.join(self.plugin_manager.basepath, u'presentations', u'lib', u'pptviewlib',
|
||||
dllpath = os.path.join(self.plugin_manager.base_path, u'presentations', u'lib', u'pptviewlib',
|
||||
u'pptviewlib.dll')
|
||||
self.process = cdll.LoadLibrary(dllpath)
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
@ -120,8 +121,7 @@ class PptviewDocument(PresentationDocument):
|
||||
PptView task started earlier.
|
||||
"""
|
||||
log.debug(u'LoadPresentation')
|
||||
renderer = self.controller.plugin.renderer
|
||||
rect = renderer.screens.current[u'size']
|
||||
rect = ScreenList().current[u'size']
|
||||
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
|
||||
filepath = str(self.filepath.replace(u'/', u'\\'))
|
||||
if not os.path.isdir(self.get_temp_folder()):
|
||||
|
@ -33,7 +33,7 @@ import shutil
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, Registry, Settings, check_directory_exists, create_thumb, validate_thumb
|
||||
from openlp.core.lib import Registry, Settings, check_directory_exists, create_thumb, validate_thumb
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -274,7 +274,7 @@ class PresentationDocument(object):
|
||||
prefix = u'live'
|
||||
else:
|
||||
prefix = u'preview'
|
||||
Receiver.send_message(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1)
|
||||
Registry().execute(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1)
|
||||
|
||||
def get_slide_text(self, slide_no):
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate
|
||||
from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate
|
||||
|
||||
class PresentationTab(SettingsTab):
|
||||
"""
|
||||
@ -130,8 +130,8 @@ class PresentationTab(SettingsTab):
|
||||
changed = True
|
||||
if changed:
|
||||
self.parent.reset_supported_suffixes()
|
||||
Receiver.send_message(u'mediaitem_presentation_rebuild')
|
||||
Receiver.send_message(u'mediaitem_suffixes')
|
||||
Registry().execute(u'mediaitem_presentation_rebuild')
|
||||
Registry().execute(u'mediaitem_suffixes')
|
||||
|
||||
def tabVisible(self):
|
||||
"""
|
||||
|
@ -37,8 +37,7 @@ from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.presentations.lib import PresentationController, \
|
||||
PresentationMediaItem, PresentationTab
|
||||
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -91,7 +90,7 @@ class PresentationPlugin(Plugin):
|
||||
except Exception:
|
||||
log.warn(u'Failed to start controller process')
|
||||
self.controllers[controller].available = False
|
||||
self.mediaItem.buildFileMaskString()
|
||||
self.mediaItem.build_file_mask_string()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
|
@ -123,7 +123,8 @@ import urlparse
|
||||
from PyQt4 import QtCore, QtNetwork
|
||||
from mako.template import Template
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, PluginStatus, StringContent
|
||||
from openlp.core.lib import Registry, Settings, PluginStatus, StringContent
|
||||
|
||||
from openlp.core.utils import AppLocation, translate
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -175,10 +176,8 @@ class HttpServer(object):
|
||||
address = Settings().value(self.plugin.settingsSection + u'/ip address')
|
||||
self.server = QtNetwork.QTcpServer()
|
||||
self.server.listen(QtNetwork.QHostAddress(address), port)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_changed'),
|
||||
self.slide_change)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.item_change)
|
||||
Registry().register_function(u'slidecontroller_live_changed', self.slide_change)
|
||||
Registry().register_function(u'slidecontroller_live_started', self.item_change)
|
||||
QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection)
|
||||
log.debug(u'TCP listening on port %d' % port)
|
||||
|
||||
@ -252,12 +251,11 @@ class HttpConnection(object):
|
||||
|
||||
def _get_service_items(self):
|
||||
service_items = []
|
||||
service_manager = self.parent.plugin.serviceManager
|
||||
if self.parent.current_item:
|
||||
current_unique_identifier = self.parent.current_item.unique_identifier
|
||||
else:
|
||||
current_unique_identifier = None
|
||||
for item in service_manager.serviceItems:
|
||||
for item in self.service_manager.serviceItems:
|
||||
service_item = item[u'service_item']
|
||||
service_items.append({
|
||||
u'id': unicode(service_item.unique_identifier),
|
||||
@ -388,13 +386,13 @@ class HttpConnection(object):
|
||||
Poll OpenLP to determine the current slide number and item name.
|
||||
"""
|
||||
result = {
|
||||
u'service': self.parent.plugin.serviceManager.service_id,
|
||||
u'service': self.service_manager.service_id,
|
||||
u'slide': self.parent.current_slide or 0,
|
||||
u'item': self.parent.current_item.unique_identifier if self.parent.current_item else u'',
|
||||
u'twelve':Settings().value(u'remotes/twelve hour'),
|
||||
u'blank': self.parent.plugin.liveController.blankScreen.isChecked(),
|
||||
u'theme': self.parent.plugin.liveController.themeScreen.isChecked(),
|
||||
u'display': self.parent.plugin.liveController.desktopScreen.isChecked()
|
||||
u'blank': self.live_controller.blankScreen.isChecked(),
|
||||
u'theme': self.live_controller.themeScreen.isChecked(),
|
||||
u'display': self.live_controller.desktopScreen.isChecked()
|
||||
}
|
||||
return HttpResponse(json.dumps({u'results': result}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
@ -406,7 +404,7 @@ class HttpConnection(object):
|
||||
``action``
|
||||
This is the action, either ``hide`` or ``show``.
|
||||
"""
|
||||
Receiver.send_message(u'slidecontroller_toggle_display', action)
|
||||
Registry().execute(u'slidecontroller_toggle_display', action)
|
||||
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
|
||||
@ -414,14 +412,14 @@ class HttpConnection(object):
|
||||
"""
|
||||
Send an alert.
|
||||
"""
|
||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name("alerts")
|
||||
plugin = self.plugin_manager.get_plugin_by_name("alerts")
|
||||
if plugin.status == PluginStatus.Active:
|
||||
try:
|
||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
text = urllib.unquote(text)
|
||||
Receiver.send_message(u'alerts_text', [text])
|
||||
Registry().execute(u'alerts_text', [text])
|
||||
success = True
|
||||
else:
|
||||
success = False
|
||||
@ -471,9 +469,9 @@ class HttpConnection(object):
|
||||
log.info(data)
|
||||
# This slot expects an int within a list.
|
||||
id = data[u'request'][u'id']
|
||||
Receiver.send_message(event, [id])
|
||||
Registry().execute(event, [id])
|
||||
else:
|
||||
Receiver.send_message(event)
|
||||
Registry().execute(event)
|
||||
json_data = {u'results': {u'success': True}}
|
||||
return HttpResponse(json.dumps(json_data),
|
||||
{u'Content-Type': u'application/json'})
|
||||
@ -490,9 +488,9 @@ class HttpConnection(object):
|
||||
data = json.loads(self.url_params[u'data'][0])
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
Receiver.send_message(event, data[u'request'][u'id'])
|
||||
Registry().execute(event, data[u'request'][u'id'])
|
||||
else:
|
||||
Receiver.send_message(event)
|
||||
Registry().execute(event)
|
||||
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
|
||||
@ -506,7 +504,7 @@ class HttpConnection(object):
|
||||
"""
|
||||
if action == u'search':
|
||||
searches = []
|
||||
for plugin in self.parent.plugin.pluginManager.plugins:
|
||||
for plugin in self.plugin_manager.plugins:
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])])
|
||||
return HttpResponse(
|
||||
@ -525,7 +523,7 @@ class HttpConnection(object):
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
text = urllib.unquote(text)
|
||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||
plugin = self.plugin_manager.get_plugin_by_name(type)
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
results = plugin.mediaItem.search(text, False)
|
||||
else:
|
||||
@ -541,7 +539,7 @@ class HttpConnection(object):
|
||||
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||
plugin = self.plugin_manager.get_plugin_by_name(type)
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||
plugin.mediaItem.goLive(id, remote=True)
|
||||
return HttpResponse(code=u'200 OK')
|
||||
@ -554,7 +552,7 @@ class HttpConnection(object):
|
||||
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||
plugin = self.plugin_manager.get_plugin_by_name(type)
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||
item_id = plugin.mediaItem.createItemFromId(id)
|
||||
plugin.mediaItem.addToService(item_id, remote=True)
|
||||
@ -585,3 +583,33 @@ class HttpConnection(object):
|
||||
self.socket.close()
|
||||
self.socket = None
|
||||
self.parent.close_connection(self)
|
||||
|
||||
def _get_service_manager(self):
|
||||
"""
|
||||
Adds the service manager to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_service_manager'):
|
||||
self._service_manager = Registry().get(u'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, u'_live_controller'):
|
||||
self._live_controller = Registry().get(u'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, u'_plugin_manager'):
|
||||
self._plugin_manager = Registry().get(u'plugin_manager')
|
||||
return self._plugin_manager
|
||||
|
||||
plugin_manager = property(_get_plugin_manager)
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui, QtNetwork
|
||||
|
||||
from openlp.core.lib import Settings, SettingsTab, Receiver, translate
|
||||
from openlp.core.lib import Registry, Settings, SettingsTab, translate
|
||||
|
||||
|
||||
ZERO_URL = u'0.0.0.0'
|
||||
@ -152,7 +152,7 @@ class RemoteTab(SettingsTab):
|
||||
Settings().setValue(self.settingsSection + u'/ip address', self.addressEdit.text())
|
||||
Settings().setValue(self.settingsSection + u'/twelve hour', self.twelveHour)
|
||||
if changed:
|
||||
Receiver.send_message(u'remotes_config_updated')
|
||||
Registry().register_function(u'remotes_config_updated')
|
||||
|
||||
def onTwelveHourCheckBoxChanged(self, check_state):
|
||||
self.twelveHour = False
|
||||
|
@ -95,7 +95,7 @@ class RemotesPlugin(Plugin):
|
||||
u'title': translate('RemotePlugin', 'Remote', 'container title')
|
||||
}
|
||||
|
||||
def configUpdated(self):
|
||||
def config_update(self):
|
||||
"""
|
||||
Called when Config is changed to restart the server on new address or
|
||||
port
|
||||
|
@ -38,8 +38,8 @@ import shutil
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import PluginStatus, Receiver, MediaType, Registry, UiStrings, translate, create_separated_list, \
|
||||
check_directory_exists
|
||||
from openlp.core.lib import Registry, PluginStatus, MediaType, translate, create_separated_list, \
|
||||
check_directory_exists, UiStrings
|
||||
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \
|
||||
find_and_set_in_combo_box
|
||||
from openlp.core.utils import AppLocation
|
||||
@ -95,7 +95,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.QObject.connect(self.audio_remove_button, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.audio_remove_all_button, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onAudioRemoveAllButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
Registry().register_function(u'theme_update_list', self.load_themes)
|
||||
self.previewButton = QtGui.QPushButton()
|
||||
self.previewButton.setObjectName(u'previewButton')
|
||||
self.previewButton.setText(UiStrings().SaveAndPreview)
|
||||
@ -114,6 +114,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.findVerseSplit = re.compile(u'---\[\]---\n', re.UNICODE)
|
||||
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""
|
||||
Reimplement the keyPressEvent to react on Return/Enter keys. When some combo boxes have focus we do not want
|
||||
dialog's default action be triggered but instead our own.
|
||||
|
||||
``event``
|
||||
A QtGui.QKeyEvent event.
|
||||
"""
|
||||
if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
|
||||
if self.authorsComboBox.hasFocus() and self.authorsComboBox.currentText():
|
||||
self.onAuthorAddButtonClicked()
|
||||
return
|
||||
if self.topicsComboBox.hasFocus() and self.topicsComboBox.currentText():
|
||||
self.onTopicAddButtonClicked()
|
||||
return
|
||||
QtGui.QDialog.keyPressEvent(self, event)
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Set up the form for when it is displayed.
|
||||
@ -167,7 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
combo.setItemData(row, object.id)
|
||||
set_case_insensitive_completer(cache, combo)
|
||||
|
||||
def loadThemes(self, theme_list):
|
||||
def load_themes(self, theme_list):
|
||||
"""
|
||||
Load the themes into a combobox.
|
||||
"""
|
||||
@ -697,7 +714,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
log.debug(u'onPreview')
|
||||
if button.objectName() == u'previewButton':
|
||||
self.saveSong(True)
|
||||
Receiver.send_message(u'songs_preview')
|
||||
Registry().execute(u'songs_preview')
|
||||
|
||||
def onAudioAddFromFileButtonClicked(self):
|
||||
"""
|
||||
|
@ -34,7 +34,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, UiStrings, create_separated_list, build_icon, translate
|
||||
from openlp.core.lib import Registry, UiStrings, create_separated_list, build_icon, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||
from openlp.plugins.songs.lib import natcmp
|
||||
@ -62,7 +62,7 @@ class SongExportForm(OpenLPWizard):
|
||||
"""
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard', u':/wizards/wizard_exportsong.bmp')
|
||||
self.stop_export_flag = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
|
||||
Registry().register_function(u'openlp_stop_wizard', self.stop_export)
|
||||
|
||||
def stop_export(self):
|
||||
"""
|
||||
|
@ -31,7 +31,7 @@ import logging
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from sqlalchemy.sql import and_
|
||||
|
||||
from openlp.core.lib import Receiver, UiStrings, translate
|
||||
from openlp.core.lib import Registry, UiStrings, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm
|
||||
from openlp.plugins.songs.lib.db import Author, Book, Topic, Song
|
||||
@ -284,7 +284,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(author):
|
||||
self.resetAuthors()
|
||||
if not self.fromSongEdit:
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Registry().execute(u'songs_load_list')
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.'))
|
||||
@ -379,7 +379,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
merge(dbObject)
|
||||
reset()
|
||||
if not self.fromSongEdit:
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Registry().execute(u'songs_load_list')
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
def mergeAuthors(self, oldAuthor):
|
||||
|
@ -95,7 +95,7 @@ class CCLIFileImport(SongImport):
|
||||
self.logError(filename,
|
||||
translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid extension.'))
|
||||
log.info(u'Extension %s is not valid', filename)
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
|
||||
def doImportUsrFile(self, textList):
|
||||
|
@ -90,7 +90,7 @@ class DreamBeamImport(SongImport):
|
||||
if isinstance(self.importSource, list):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
|
@ -58,7 +58,7 @@ class EasySlidesImport(SongImport):
|
||||
song_xml = objectify.fromstring(xml)
|
||||
self.importWizard.progressBar.setMaximum(len(song_xml.Item))
|
||||
for song in song_xml.Item:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self._parseSong(song)
|
||||
|
||||
|
@ -142,7 +142,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
rec_count = (rec_count + record_size) / record_size
|
||||
# Loop through each record within the current block
|
||||
for i in range(rec_count):
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
raw_record = db_file.read(record_size)
|
||||
self.fields = self.recordStruct.unpack(raw_record)
|
||||
@ -216,7 +216,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
if len(self.comments) > 5:
|
||||
self.comments += unicode(translate('SongsPlugin.EasyWorshipSongImport',
|
||||
'\n[above are Song Tags with notes imported from EasyWorship]'))
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
if not self.finish():
|
||||
self.logError(self.importSource)
|
||||
|
@ -124,7 +124,7 @@ class FoilPresenterImport(SongImport):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
for file_path in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.importWizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
|
@ -35,7 +35,7 @@ import shutil
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import or_
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \
|
||||
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \
|
||||
UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
|
||||
from openlp.core.lib.ui import create_widget_action
|
||||
from openlp.core.utils import AppLocation
|
||||
@ -99,9 +99,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
triggers=self.onSongMaintenanceClick)
|
||||
self.addSearchToToolBar()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick)
|
||||
Registry().register_function(u'songs_load_list', self.on_song_list_load)
|
||||
Registry().register_function(u'config_updated', self.config_update)
|
||||
Registry().register_function(u'songs_preview', self.onPreviewClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
self.onSearchTextButtonClicked)
|
||||
@ -115,7 +115,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
def onFocus(self):
|
||||
self.searchTextEdit.setFocus()
|
||||
|
||||
def configUpdated(self):
|
||||
def config_update(self):
|
||||
self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type')
|
||||
self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit')
|
||||
self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service',)
|
||||
@ -146,7 +146,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
UiStrings().Themes, UiStrings().SearchThemes)
|
||||
])
|
||||
self.searchTextEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection))
|
||||
self.configUpdated()
|
||||
self.config_update()
|
||||
|
||||
def onSearchTextButtonClicked(self):
|
||||
# Save the current search type to the configuration.
|
||||
@ -198,12 +198,12 @@ class SongMediaItem(MediaManagerItem):
|
||||
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'),
|
||||
Song.comments.like(u'%' + search_keywords.lower() + u'%')))
|
||||
|
||||
def onSongListLoad(self):
|
||||
def on_song_list_load(self):
|
||||
"""
|
||||
Handle the exit from the edit dialog and trigger remote updates
|
||||
of songs
|
||||
"""
|
||||
log.debug(u'onSongListLoad - start')
|
||||
log.debug(u'on_song_list_load - start')
|
||||
# Called to redisplay the song list screen edit from a search
|
||||
# or from the exit of the Song edit dialog. If remote editing is active
|
||||
# Trigger it and clean up so it will not update again.
|
||||
@ -212,7 +212,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
item = self.buildServiceItem(self.editItem)
|
||||
self.service_manager.replace_service_item(item)
|
||||
self.onSearchTextButtonClicked()
|
||||
log.debug(u'onSongListLoad - finished')
|
||||
log.debug(u'on_song_list_load - finished')
|
||||
|
||||
def displayResultsSong(self, searchresults):
|
||||
log.debug(u'display results Song')
|
||||
@ -293,7 +293,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.importWizard = SongImportForm(self, self.plugin)
|
||||
self.importWizard.exec_()
|
||||
# Run song load as list may have been cancelled but some songs loaded
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Registry().execute(u'songs_load_list')
|
||||
|
||||
def onExportClick(self):
|
||||
if not hasattr(self, u'exportWizard'):
|
||||
@ -324,7 +324,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.editSongForm.loadSong(song_id, preview)
|
||||
if self.editSongForm.exec_() == QtGui.QDialog.Accepted:
|
||||
self.autoSelectId = -1
|
||||
self.onSongListLoad()
|
||||
self.on_song_list_load()
|
||||
self.remoteSong = song_id
|
||||
self.remoteTriggered = True
|
||||
item = self.buildServiceItem(remote=True)
|
||||
@ -345,7 +345,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.editSongForm.loadSong(item_id, False)
|
||||
self.editSongForm.exec_()
|
||||
self.autoSelectId = -1
|
||||
self.onSongListLoad()
|
||||
self.on_song_list_load()
|
||||
self.editItem = None
|
||||
|
||||
def onDeleteClick(self):
|
||||
@ -397,7 +397,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
new_song.title = u'%s <%s>' % (new_song.title,
|
||||
translate('SongsPlugin.MediaItem', 'copy', 'For song cloning'))
|
||||
self.plugin.manager.save_object(new_song)
|
||||
self.onSongListLoad()
|
||||
self.on_song_list_load()
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||
remote=False, context=ServiceItemContext.Service):
|
||||
|
@ -66,7 +66,7 @@ class MediaShoutImport(SongImport):
|
||||
songs = cursor.fetchall()
|
||||
self.importWizard.progressBar.setMaximum(len(songs))
|
||||
for song in songs:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
cursor.execute(u'SELECT Type, Number, Text FROM Verses '
|
||||
u'WHERE Record = %s ORDER BY Type, Number' % song.Record)
|
||||
|
@ -110,7 +110,7 @@ class OpenLP1SongImport(SongImport):
|
||||
self.importWizard.progressBar.setMaximum(len(songs))
|
||||
for song in songs:
|
||||
self.setDefaults()
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
song_id = song[0]
|
||||
self.title = song[1]
|
||||
@ -131,13 +131,13 @@ class OpenLP1SongImport(SongImport):
|
||||
u'WHERE songid = %s' % song_id)
|
||||
author_ids = cursor.fetchall()
|
||||
for author_id in author_ids:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
for author in authors:
|
||||
if author[0] == author_id[0]:
|
||||
self.parseAuthor(author[1])
|
||||
break
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
if db_has_tracks:
|
||||
cursor.execute(u'-- types int, int')
|
||||
@ -146,14 +146,14 @@ class OpenLP1SongImport(SongImport):
|
||||
u'WHERE songid = %s ORDER BY listindex' % song_id)
|
||||
track_ids = cursor.fetchall()
|
||||
for track_id, listindex in track_ids:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
for track in tracks:
|
||||
if track[0] == track_id:
|
||||
media_file = self.expandMediaFile(track[1])
|
||||
self.addMediaFile(media_file, listindex)
|
||||
break
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
if not self.finish():
|
||||
self.logError(self.importSource)
|
||||
|
@ -225,6 +225,6 @@ class OpenLPSongImport(SongImport):
|
||||
progressDialog.setLabelText(WizardStrings.ImportingType % new_song.title)
|
||||
else:
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % new_song.title)
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
engine.dispose()
|
||||
|
@ -77,7 +77,7 @@ class OooImport(SongImport):
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
filename = unicode(filename)
|
||||
if os.path.isfile(filename):
|
||||
@ -189,7 +189,7 @@ class OooImport(SongImport):
|
||||
slides = doc.getDrawPages()
|
||||
text = u''
|
||||
for slide_no in range(slides.getCount()):
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
self.importWizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
slide = slides.getByIndex(slide_no)
|
||||
|
@ -63,7 +63,7 @@ class OpenLyricsImport(SongImport):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
for file_path in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
try:
|
||||
|
@ -113,7 +113,7 @@ class OpenSongImport(SongImport):
|
||||
def doImport(self):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
song_file = open(filename)
|
||||
self.doImportFile(song_file)
|
||||
|
@ -106,7 +106,7 @@ class PowerSongImport(SongImport):
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
parse_error = False
|
||||
|
@ -100,7 +100,7 @@ class SofImport(OooImport):
|
||||
try:
|
||||
paragraphs = self.document.getText().createEnumeration()
|
||||
while paragraphs.hasMoreElements():
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
paragraph = paragraphs.nextElement()
|
||||
if paragraph.supportsService("com.sun.star.text.Paragraph"):
|
||||
|
@ -109,7 +109,7 @@ class SongBeamerImport(SongImport):
|
||||
return
|
||||
for file in self.importSource:
|
||||
# TODO: check that it is a valid SongBeamer file
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
self.currentVerse = u''
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate, check_directory_exists
|
||||
from openlp.core.lib import Registry, translate, check_directory_exists
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.songs.lib import clean_song, VerseType
|
||||
@ -81,9 +81,9 @@ class SongImport(QtCore.QObject):
|
||||
log.debug(self.importSource)
|
||||
self.importWizard = None
|
||||
self.song = None
|
||||
self.stopImportFlag = False
|
||||
self.stop_import_flag = False
|
||||
self.setDefaults()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stopImport)
|
||||
Registry().register_function(u'openlp_stop_wizard', self.stop_import)
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
@ -133,12 +133,12 @@ class SongImport(QtCore.QObject):
|
||||
self.importWizard.errorSaveToButton.setVisible(True)
|
||||
self.importWizard.errorReportTextEdit.append(u'- %s (%s)' % (filepath, reason))
|
||||
|
||||
def stopImport(self):
|
||||
def stop_import(self):
|
||||
"""
|
||||
Sets the flag for importers to stop their import
|
||||
"""
|
||||
log.debug(u'Stopping songs import')
|
||||
self.stopImportFlag = True
|
||||
self.stop_import_flag = True
|
||||
|
||||
def register(self, import_wizard):
|
||||
self.importWizard = import_wizard
|
||||
|
@ -83,7 +83,7 @@ class SongProImport(SongImport):
|
||||
tag = u''
|
||||
text = u''
|
||||
for file_line in songs_file:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
file_line = unicode(file_line, u'cp1252')
|
||||
file_text = file_line.rstrip()
|
||||
|
@ -105,7 +105,7 @@ class SongShowPlusImport(SongImport):
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.sspVerseOrderList = []
|
||||
other_count = 0
|
||||
|
@ -66,7 +66,7 @@ class SundayPlusImport(SongImport):
|
||||
def doImport(self):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
song_file = open(filename)
|
||||
self.doImportFile(song_file)
|
||||
|
@ -108,7 +108,7 @@ class WowImport(SongImport):
|
||||
if isinstance(self.importSource, list):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for source in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
song_data = open(source, 'rb')
|
||||
|
@ -96,7 +96,7 @@ class ZionWorxImport(SongImport):
|
||||
log.info(u'%s records found in CSV file' % num_records)
|
||||
self.importWizard.progressBar.setMaximum(num_records)
|
||||
for index, record in enumerate(records, 1):
|
||||
if self.stopImportFlag:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
try:
|
||||
|
@ -29,10 +29,11 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib import Registry, translate
|
||||
from openlp.plugins.songusage.lib.db import SongUsageItem
|
||||
from songusagedeletedialog import Ui_SongUsageDeleteDialog
|
||||
|
||||
|
||||
class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
|
||||
"""
|
||||
Class documentation goes here.
|
||||
@ -57,11 +58,21 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
|
||||
if ret == QtGui.QMessageBox.Yes:
|
||||
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
|
||||
self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate)
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'),
|
||||
u'message': translate(
|
||||
'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ')}
|
||||
self.main_window.information_message(
|
||||
translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'),
|
||||
translate(
|
||||
'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ')
|
||||
)
|
||||
self.accept()
|
||||
else:
|
||||
self.reject()
|
||||
|
||||
def _get_main_window(self):
|
||||
"""
|
||||
Adds the main window to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_main_window'):
|
||||
self._main_window = Registry().get(u'main_window')
|
||||
return self._main_window
|
||||
|
||||
main_window = property(_get_main_window)
|
@ -33,7 +33,7 @@ import os
|
||||
from PyQt4 import QtGui
|
||||
from sqlalchemy.sql import and_
|
||||
|
||||
from openlp.core.lib import Receiver, Settings, translate, check_directory_exists
|
||||
from openlp.core.lib import Registry, Settings, translate, check_directory_exists
|
||||
from openlp.plugins.songusage.lib.db import SongUsageItem
|
||||
from songusagedetaildialog import Ui_SongUsageDetailDialog
|
||||
|
||||
@ -81,11 +81,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
|
||||
log.debug(u'accept')
|
||||
path = self.fileLineEdit.text()
|
||||
if not path:
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'),
|
||||
u'message': translate(
|
||||
'SongUsagePlugin.SongUsageDetailForm', 'You have not set a valid output location for your song usage '
|
||||
'report. Please select an existing path on your computer.')})
|
||||
self.main_window.error_message(
|
||||
translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'),
|
||||
translate('SongUsagePlugin.SongUsageDetailForm', 'You have not set a valid output location for your'
|
||||
' song usage report. Please select an existing path on your computer.')
|
||||
)
|
||||
return
|
||||
check_directory_exists(path)
|
||||
filename = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % (
|
||||
@ -108,13 +108,24 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
|
||||
instance.usagetime, instance.title, instance.copyright,
|
||||
instance.ccl_number, instance.authors, instance.plugin_name, instance.source)
|
||||
fileHandle.write(record.encode(u'utf-8'))
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
|
||||
u'message': translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
|
||||
'has been successfully created. ') % outname})
|
||||
self.main_window.information_message(
|
||||
translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
|
||||
translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
|
||||
'has been successfully created. ') % outname
|
||||
)
|
||||
except IOError:
|
||||
log.exception(u'Failed to write out song usage records')
|
||||
finally:
|
||||
if fileHandle:
|
||||
fileHandle.close()
|
||||
self.close()
|
||||
|
||||
def _get_main_window(self):
|
||||
"""
|
||||
Adds the main window to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_main_window'):
|
||||
self._main_window = Registry().get(u'main_window')
|
||||
return self._main_window
|
||||
|
||||
main_window = property(_get_main_window)
|
@ -32,7 +32,7 @@ from datetime import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, Receiver, Settings, StringContent, build_icon, translate
|
||||
from openlp.core.lib import Plugin, Registry, Settings, StringContent, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.utils.actions import ActionList
|
||||
@ -123,10 +123,8 @@ class SongUsagePlugin(Plugin):
|
||||
def initialise(self):
|
||||
log.info(u'SongUsage Initialising')
|
||||
Plugin.initialise(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.displaySongUsage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'print_service_started'),
|
||||
self.printSongUsage)
|
||||
Registry().register_function(u'slidecontroller_live_started', self.display_song_usage)
|
||||
Registry().register_function(u'print_service_started', self.print_song_usage)
|
||||
self.songUsageActive = Settings().value(self.settingsSection + u'/active')
|
||||
# Set the button and checkbox state
|
||||
self.setButtonState()
|
||||
@ -185,13 +183,13 @@ class SongUsagePlugin(Plugin):
|
||||
self.songUsageStatus.blockSignals(False)
|
||||
|
||||
|
||||
def displaySongUsage(self, item):
|
||||
def display_song_usage(self, item):
|
||||
"""
|
||||
Song Usage for which has been displayed
|
||||
"""
|
||||
self._add_song_usage(translate('SongUsagePlugin', 'display'), item)
|
||||
|
||||
def printSongUsage(self, item):
|
||||
def print_song_usage(self, item):
|
||||
"""
|
||||
Song Usage for which has been printed
|
||||
"""
|
||||
|
@ -40,7 +40,13 @@ import os
|
||||
import sys
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
is_win = sys.platform.startswith('win')
|
||||
# If we try to import uno before nose this will greate a warning. Just try to import nose first to supress the warning.
|
||||
try:
|
||||
import nose
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
IS_WIN = sys.platform.startswith('win')
|
||||
|
||||
VERS = {
|
||||
'Python': '2.6',
|
||||
@ -48,7 +54,7 @@ VERS = {
|
||||
'Qt4': '4.6',
|
||||
'sqlalchemy': '0.5',
|
||||
# pyenchant 1.6 required on Windows
|
||||
'enchant': '1.6' if is_win else '1.3'
|
||||
'enchant': '1.6' if IS_WIN else '1.3'
|
||||
}
|
||||
|
||||
# pywin32
|
||||
@ -84,7 +90,7 @@ OPTIONAL_MODULES = [
|
||||
('sqlite', ' (SQLite 2 support)'),
|
||||
('MySQLdb', ' (MySQL support)'),
|
||||
('psycopg2', ' (PostgreSQL support)'),
|
||||
('pytest', ' (testing framework)'),
|
||||
('nose', ' (testing framework)'),
|
||||
]
|
||||
|
||||
w = sys.stdout.write
|
||||
@ -176,7 +182,7 @@ def main():
|
||||
for m in OPTIONAL_MODULES:
|
||||
check_module(m[0], text=m[1])
|
||||
|
||||
if is_win:
|
||||
if IS_WIN:
|
||||
print('Checking for Windows specific modules...')
|
||||
for m in WIN32_MODULES:
|
||||
check_module(m)
|
||||
|
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Edwin Lunando, 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 #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
Configuration file for pytest framework.
|
||||
"""
|
||||
|
||||
from openlp.core import main as openlp_main
|
||||
|
||||
|
||||
# Test function argument to make openlp gui instance persistent for all tests.
|
||||
# All test cases have to access the same instance. To allow create multiple
|
||||
# instances it would be necessary use diffrent configuraion and data files.
|
||||
# Created instance will use your OpenLP settings.
|
||||
def pytest_funcarg__openlpapp(request):
|
||||
def setup():
|
||||
return openlp_main(['--testing'])
|
||||
def teardown(app):
|
||||
pass
|
||||
return request.cached_setup(setup=setup, teardown=teardown, scope='session')
|
13
tests/functional/__init__.py
Normal file
13
tests/functional/__init__.py
Normal file
@ -0,0 +1,13 @@
|
||||
import sip
|
||||
sip.setapi(u'QDate', 2)
|
||||
sip.setapi(u'QDateTime', 2)
|
||||
sip.setapi(u'QString', 2)
|
||||
sip.setapi(u'QTextStream', 2)
|
||||
sip.setapi(u'QTime', 2)
|
||||
sip.setapi(u'QUrl', 2)
|
||||
sip.setapi(u'QVariant', 2)
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication.
|
||||
application = QtGui.QApplication([])
|
78
tests/functional/openlp_core_lib/test_formattingtags.py
Normal file
78
tests/functional/openlp_core_lib/test_formattingtags.py
Normal file
@ -0,0 +1,78 @@
|
||||
"""
|
||||
Package to test the openlp.core.lib.formattingtags package.
|
||||
"""
|
||||
import copy
|
||||
from unittest import TestCase
|
||||
|
||||
from mock import patch
|
||||
|
||||
from openlp.core.lib import FormattingTags
|
||||
|
||||
|
||||
TAG = {
|
||||
u'end tag': '{/aa}',
|
||||
u'start html': '<span>',
|
||||
u'start tag': '{aa}',
|
||||
u'protected': False,
|
||||
u'end html': '</span>',
|
||||
u'desc': 'name'
|
||||
}
|
||||
|
||||
|
||||
class TestFormattingTags(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Clean up the FormattingTags class.
|
||||
"""
|
||||
FormattingTags.html_expands = []
|
||||
|
||||
def get_html_tags_no_user_tags_test(self):
|
||||
"""
|
||||
Test the FormattingTags class' get_html_tags static method.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.translate') as mocked_translate, \
|
||||
patch(u'openlp.core.lib.settings') as mocked_settings, \
|
||||
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
|
||||
# GIVEN: Our mocked modules and functions.
|
||||
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
|
||||
mocked_settings.value.return_value = u''
|
||||
mocked_cPickle.load.return_value = []
|
||||
|
||||
# WHEN: Get the display tags.
|
||||
FormattingTags.load_tags()
|
||||
old_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
|
||||
FormattingTags.load_tags()
|
||||
new_tags_list = FormattingTags.get_html_tags()
|
||||
|
||||
# THEN: Lists should be identically.
|
||||
assert old_tags_list == new_tags_list, u'The formatting tag lists should be identically.'
|
||||
|
||||
def get_html_tags_with_user_tags_test(self):
|
||||
"""
|
||||
Test the FormattingTags class' get_html_tags static method in combination with user tags.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.translate') as mocked_translate, \
|
||||
patch(u'openlp.core.lib.settings') as mocked_settings, \
|
||||
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
|
||||
# GIVEN: Our mocked modules and functions.
|
||||
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
|
||||
mocked_settings.value.return_value = u''
|
||||
mocked_cPickle.loads.side_effect = [[], [TAG]]
|
||||
|
||||
# WHEN: Get the display tags.
|
||||
FormattingTags.load_tags()
|
||||
old_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
|
||||
|
||||
# WHEN: Add our tag and get the tags again.
|
||||
FormattingTags.load_tags()
|
||||
FormattingTags.add_html_tags([TAG])
|
||||
new_tags_list = FormattingTags.get_html_tags()
|
||||
|
||||
# THEN: Lists should not be identically.
|
||||
assert old_tags_list != new_tags_list, u'The lists should be different.'
|
||||
|
||||
# THEN: Added tag and last tag should be the same.
|
||||
new_tag = new_tags_list.pop()
|
||||
assert TAG == new_tag, u'Tags should be identically.'
|
||||
|
50
tests/functional/openlp_core_lib/test_image_manager.py
Normal file
50
tests/functional/openlp_core_lib/test_image_manager.py
Normal file
@ -0,0 +1,50 @@
|
||||
"""
|
||||
Package to test the openlp.core.ui package.
|
||||
"""
|
||||
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Registry, ImageManager, ScreenList
|
||||
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
||||
|
||||
|
||||
class TestImageManager(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication.instance()
|
||||
ScreenList.create(self.app.desktop())
|
||||
self.image_manager = ImageManager()
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.app
|
||||
|
||||
def basic_image_manager_test(self):
|
||||
"""
|
||||
Test the Image Manager setup basic functionality
|
||||
"""
|
||||
# GIVEN: the an image add to the image manager
|
||||
self.image_manager.add_image(TEST_PATH, u'church.jpg', None)
|
||||
|
||||
# WHEN the image is retrieved
|
||||
image = self.image_manager.get_image(TEST_PATH, u'church.jpg')
|
||||
|
||||
# THEN returned record is a type of image
|
||||
self.assertEqual(isinstance(image, QtGui.QImage), True, u'The returned object should be a QImage')
|
||||
|
||||
# WHEN the image is retrieved has not been loaded
|
||||
# THEN a KeyError is thrown
|
||||
with self.assertRaises(KeyError) as context:
|
||||
self.image_manager.get_image(TEST_PATH, u'church1.jpg')
|
||||
self.assertNotEquals(context.exception[0], u'', u'KeyError exception should have been thrown for missing image')
|
@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from openlp.core.lib import str_to_bool, translate, check_directory_exists, get_text_file_string, build_icon, \
|
||||
image_to_byte, check_item_selected, validate_thumb
|
||||
image_to_byte, check_item_selected, validate_thumb, create_separated_list
|
||||
|
||||
class TestLib(TestCase):
|
||||
|
||||
@ -308,14 +308,14 @@ class TestLib(TestCase):
|
||||
file_path = u'path/to/file'
|
||||
thumb_path = u'path/to/thumb'
|
||||
mocked_os.path.exists.return_value = False
|
||||
|
||||
|
||||
# WHEN: we run the validate_thumb() function
|
||||
result = validate_thumb(file_path, thumb_path)
|
||||
|
||||
|
||||
# THEN: we should have called a few functions, and the result should be False
|
||||
mocked_os.path.exists.assert_called_with(thumb_path)
|
||||
assert result is False, u'The result should be False'
|
||||
|
||||
|
||||
def validate_thumb_file_exists_and_newer_test(self):
|
||||
"""
|
||||
Test the validate_thumb() function when the thumbnail exists and has a newer timestamp than the file
|
||||
@ -350,7 +350,7 @@ class TestLib(TestCase):
|
||||
thumb_mocked_stat.st_mtime = datetime.now() - timedelta(seconds=10)
|
||||
mocked_os.path.exists.return_value = True
|
||||
mocked_os.stat.side_effect = lambda fname: file_mocked_stat if fname == file_path else thumb_mocked_stat
|
||||
|
||||
|
||||
# WHEN: we run the validate_thumb() function
|
||||
result = validate_thumb(file_path, thumb_path)
|
||||
|
||||
@ -359,3 +359,90 @@ class TestLib(TestCase):
|
||||
mocked_os.stat.assert_any_call(file_path)
|
||||
mocked_os.stat.assert_any_call(thumb_path)
|
||||
assert result is False, u'The result should be False'
|
||||
|
||||
def create_separated_list_qlocate_test(self):
|
||||
"""
|
||||
Test the create_separated_list function using the Qt provided method.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.Qt') as mocked_qt, \
|
||||
patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList:
|
||||
# GIVEN: A list of strings and the mocked Qt module.
|
||||
mocked_qt.PYQT_VERSION_STR = u'4.9'
|
||||
mocked_qt.qVersion.return_value = u'4.8'
|
||||
mocked_createSeparatedList.return_value = u'Author 1, Author 2, and Author 3'
|
||||
string_list = [u'Author 1', u'Author 2', u'Author 3']
|
||||
|
||||
# WHEN: We get a string build from the entries it the list and a seperator.
|
||||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1, Author 2, and Author 3"
|
||||
assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \
|
||||
'Author 2, and Author 3\'.'
|
||||
|
||||
def create_separated_list_empty_list_test(self):
|
||||
"""
|
||||
Test the create_separated_list function with an empty list.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.Qt') as mocked_qt:
|
||||
# GIVEN: An empty list and the mocked Qt module.
|
||||
mocked_qt.PYQT_VERSION_STR = u'4.8'
|
||||
mocked_qt.qVersion.return_value = u'4.7'
|
||||
string_list = []
|
||||
|
||||
# WHEN: We get a string build from the entries it the list and a seperator.
|
||||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We shoud have an emptry string.
|
||||
assert string_result == u'', u'The string sould be empty.'
|
||||
|
||||
def create_separated_list_with_one_item_test(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list consisting of only one entry.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.Qt') as mocked_qt:
|
||||
# GIVEN: A list with a string and the mocked Qt module.
|
||||
mocked_qt.PYQT_VERSION_STR = u'4.8'
|
||||
mocked_qt.qVersion.return_value = u'4.7'
|
||||
string_list = [u'Author 1']
|
||||
|
||||
# WHEN: We get a string build from the entries it the list and a seperator.
|
||||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1"
|
||||
assert string_result == u'Author 1', u'The string should be u\'Author 1\'.'
|
||||
|
||||
def create_separated_list_with_two_items_test(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list of two entries.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate:
|
||||
# GIVEN: A list of strings and the mocked Qt module.
|
||||
mocked_qt.PYQT_VERSION_STR = u'4.8'
|
||||
mocked_qt.qVersion.return_value = u'4.7'
|
||||
mocked_translate.return_value = u'%s and %s'
|
||||
string_list = [u'Author 1', u'Author 2']
|
||||
|
||||
# WHEN: We get a string build from the entries it the list and a seperator.
|
||||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1 and Author 2"
|
||||
assert string_result == u'Author 1 and Author 2', u'The string should be u\'Author 1 and Author 2\'.'
|
||||
|
||||
def create_separated_list_with_three_items_test(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list of three items.
|
||||
"""
|
||||
with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate:
|
||||
# GIVEN: A list with a string and the mocked Qt module.
|
||||
mocked_qt.PYQT_VERSION_STR = u'4.8'
|
||||
mocked_qt.qVersion.return_value = u'4.7'
|
||||
# Always return the untranslated string.
|
||||
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
|
||||
string_list = [u'Author 1', u'Author 2', u'Author 3']
|
||||
|
||||
# WHEN: We get a string build from the entries it the list and a seperator.
|
||||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1, Author 2, and Author 3"
|
||||
assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \
|
||||
'Author 2, and Author 3\'.'
|
||||
|
@ -28,7 +28,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_media_manager()
|
||||
@ -45,7 +45,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_media_manager()
|
||||
@ -61,7 +61,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_settings_tabs()
|
||||
@ -79,7 +79,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_settings_form = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_settings_tabs()
|
||||
@ -98,7 +98,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_settings_tabs()
|
||||
@ -115,7 +115,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_settings_form = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_settings_tabs()
|
||||
@ -134,7 +134,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_import_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_import_menu()
|
||||
@ -152,7 +152,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_import_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_import_menu()
|
||||
@ -169,7 +169,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_export_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_export_menu()
|
||||
@ -187,7 +187,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_export_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_export_menu()
|
||||
@ -204,7 +204,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_tools_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_tools_menu()
|
||||
@ -222,7 +222,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_tools_menu = MagicMock()
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run hook_tools_menu()
|
||||
@ -239,7 +239,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_plugin.isActive.return_value = False
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run initialise_plugins()
|
||||
@ -257,7 +257,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_plugin.isActive.return_value = True
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run initialise_plugins()
|
||||
@ -275,7 +275,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_plugin.isActive.return_value = False
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
@ -293,7 +293,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_plugin.isActive.return_value = True
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
@ -310,7 +310,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.name = 'Mocked Plugin'
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
@ -326,7 +326,7 @@ class TestPluginManager(TestCase):
|
||||
# GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.name = 'Mocked Plugin'
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
@ -343,7 +343,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_plugin.isActive.return_value = False
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
@ -362,7 +362,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_plugin.isActive.return_value = True
|
||||
plugin_manager = PluginManager('')
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
|
||||
# WHEN: We run new_service_created()
|
||||
|
@ -13,12 +13,12 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..'
|
||||
|
||||
class TestRegistry(TestCase):
|
||||
|
||||
def registry_basic_test(self):
|
||||
def registry_service_test(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
# GIVEN: A new registry
|
||||
registry = Registry.create()
|
||||
Registry.create()
|
||||
|
||||
# WHEN: I add a component it should save it
|
||||
mock_1 = MagicMock()
|
||||
@ -48,3 +48,37 @@ class TestRegistry(TestCase):
|
||||
temp = Registry().get(u'test1')
|
||||
self.assertEqual(context.exception[0], u'Service test1 not found in list',
|
||||
u'KeyError exception should have been thrown for deleted service')
|
||||
|
||||
def registry_function_test(self):
|
||||
"""
|
||||
Test the registry function creation and their usages
|
||||
"""
|
||||
# GIVEN: An existing registry register a function
|
||||
Registry.create()
|
||||
Registry().register_function(u'test1', self.dummy_function_1)
|
||||
|
||||
# WHEN: I execute the function
|
||||
return_value = Registry().execute(u'test1')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value[0], u'function_1', u'A return value is provided and matches')
|
||||
|
||||
# WHEN: I execute the a function with the same reference and execute the function
|
||||
Registry().register_function(u'test1', self.dummy_function_1)
|
||||
return_value = Registry().execute(u'test1')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value, [u'function_1', u'function_1'], u'A return value list is provided and matches')
|
||||
|
||||
# WHEN: I execute the a 2nd function with the different reference and execute the function
|
||||
Registry().register_function(u'test2', self.dummy_function_2)
|
||||
return_value = Registry().execute(u'test2')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value[0], u'function_2', u'A return value is provided and matches')
|
||||
|
||||
def dummy_function_1(self):
|
||||
return "function_1"
|
||||
|
||||
def dummy_function_2(self):
|
||||
return "function_2"
|
58
tests/functional/openlp_core_lib/test_screen.py
Normal file
58
tests/functional/openlp_core_lib/test_screen.py
Normal file
@ -0,0 +1,58 @@
|
||||
"""
|
||||
Package to test the openlp.core.lib.screenlist package.
|
||||
"""
|
||||
import copy
|
||||
from unittest import TestCase
|
||||
|
||||
from mock import MagicMock
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.lib import Registry, ScreenList
|
||||
|
||||
|
||||
SCREEN = {
|
||||
u'primary': False,
|
||||
u'number': 1,
|
||||
u'size': QtCore.QRect(0, 0, 1024, 768)
|
||||
}
|
||||
|
||||
|
||||
class TestScreenList(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the components need for all tests.
|
||||
"""
|
||||
self.application = QtGui.QApplication.instance()
|
||||
Registry.create()
|
||||
self.application.setOrganizationName(u'OpenLP-tests')
|
||||
self.application.setOrganizationDomain(u'openlp.org')
|
||||
self.screens = ScreenList.create(self.application.desktop())
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Delete QApplication.
|
||||
"""
|
||||
del self.screens
|
||||
del self.application
|
||||
|
||||
def add_desktop_test(self):
|
||||
"""
|
||||
Test the ScreenList class' - screen_count_changed method to check if new monitors are detected by OpenLP.
|
||||
"""
|
||||
# GIVEN: The screen list.
|
||||
old_screens = copy.deepcopy(self.screens.screen_list)
|
||||
# Mock the attributes.
|
||||
self.screens.desktop.primaryScreen = MagicMock(return_value=SCREEN[u'primary'])
|
||||
self.screens.desktop.screenCount = MagicMock(return_value=SCREEN[u'number'] + 1)
|
||||
self.screens.desktop.screenGeometry = MagicMock(return_value=SCREEN[u'size'])
|
||||
|
||||
# WHEN: Add a new screen.
|
||||
self.screens.screen_count_changed(len(old_screens))
|
||||
|
||||
# THEN: The screen should have been added.
|
||||
new_screens = self.screens.screen_list
|
||||
assert len(old_screens) + 1 == len(new_screens), u'The new_screens list should be bigger.'
|
||||
|
||||
# THEN: The screens should be identically.
|
||||
assert SCREEN == new_screens.pop(), u'The new screen should be identically to the screen defined above.'
|
@ -3,11 +3,10 @@
|
||||
"""
|
||||
import os
|
||||
import cPickle
|
||||
|
||||
from unittest import TestCase
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from mock import MagicMock
|
||||
from openlp.core.lib import ServiceItem, Registry
|
||||
from openlp.core.lib import ItemCapabilities, ServiceItem, Registry
|
||||
|
||||
|
||||
VERSE = u'The Lord said to {r}Noah{/r}: \n'\
|
||||
@ -19,7 +18,7 @@ VERSE = u'The Lord said to {r}Noah{/r}: \n'\
|
||||
'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
|
||||
FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456']
|
||||
|
||||
TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
||||
|
||||
|
||||
class TestServiceItem(TestCase):
|
||||
@ -28,7 +27,7 @@ class TestServiceItem(TestCase):
|
||||
"""
|
||||
Set up the Registry
|
||||
"""
|
||||
registry = Registry.create()
|
||||
Registry.create()
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.format_slide.return_value = [VERSE]
|
||||
Registry().register(u'renderer', mocked_renderer)
|
||||
@ -40,7 +39,7 @@ class TestServiceItem(TestCase):
|
||||
"""
|
||||
# GIVEN: A new service item
|
||||
|
||||
# WHEN:A service item is created (without a plugin)
|
||||
# WHEN: A service item is created (without a plugin)
|
||||
service_item = ServiceItem(None)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
@ -79,7 +78,7 @@ class TestServiceItem(TestCase):
|
||||
service_item.name = u'test'
|
||||
|
||||
# WHEN: adding image to a service item
|
||||
test_image = os.path.join(TESTPATH, u'church.jpg')
|
||||
test_image = os.path.join(TEST_PATH, u'church.jpg')
|
||||
service_item.add_from_image(test_image, u'Image Title')
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
@ -102,12 +101,12 @@ class TestServiceItem(TestCase):
|
||||
service = service_item.get_service_repr(True)
|
||||
|
||||
# THEN: We should have two parts of the service.
|
||||
assert len(service) == 2, u'A saved service has two parts'
|
||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin was returned'
|
||||
assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name matches the request'
|
||||
assert service[u'data'][0][u'path'] == test_image , u'The first image name matches'
|
||||
assert len(service) == 2, u'A saved service should have two parts'
|
||||
assert service[u'header'][u'name'] == u'test', u'A test plugin should have been returned'
|
||||
assert service[u'data'][0][u'title'] == u'Image Title', u'"Image Title" should be returned as the title'
|
||||
assert service[u'data'][0][u'path'] == test_image, u'The returned path should match the inputted path'
|
||||
assert service[u'data'][0][u'title'] != service[u'data'][1][u'title'], \
|
||||
u'The individual titles should not match'
|
||||
u'The individual slide titles should not match'
|
||||
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The file paths should match'
|
||||
|
||||
# WHEN validating a service item
|
||||
@ -123,7 +122,7 @@ class TestServiceItem(TestCase):
|
||||
service_item.validate_item([u'jpg'])
|
||||
|
||||
# THEN the service item should be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid due to validation changes'
|
||||
assert service_item.is_valid is False, u'The service item should not be valid due to validation changes'
|
||||
|
||||
def serviceitem_add_command_test(self):
|
||||
"""
|
||||
@ -134,26 +133,26 @@ class TestServiceItem(TestCase):
|
||||
service_item.name = u'test'
|
||||
|
||||
# WHEN: adding image to a service item
|
||||
test_file = os.path.join(TESTPATH, u'church.jpg')
|
||||
service_item.add_from_command(TESTPATH, u'church.jpg', test_file)
|
||||
test_file = os.path.join(TEST_PATH, u'church.jpg')
|
||||
service_item.add_from_command(TEST_PATH, u'church.jpg', test_file)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert len(service_item._display_frames) == 0, u'The service item has no display frames '
|
||||
assert len(service_item._display_frames) == 0, u'The service item should have no display frames '
|
||||
|
||||
# THEN: We should have a page of output.
|
||||
assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has one raw frame'
|
||||
assert service_item.get_rendered_frame(0) == test_file, u'The image matches the input'
|
||||
assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item should have one raw frame'
|
||||
assert service_item.get_rendered_frame(0) == test_file, u'The image should match the input'
|
||||
|
||||
# WHEN requesting a saved service item
|
||||
service = service_item.get_service_repr(True)
|
||||
|
||||
# THEN: We should have two parts of the service.
|
||||
assert len(service) == 2, u'A saved service has two parts'
|
||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
||||
assert service[u'data'][0][u'title'] == u'church.jpg' , u'The first title name '
|
||||
assert service[u'data'][0][u'path'] == TESTPATH , u'The first image name'
|
||||
assert service[u'data'][0][u'image'] == test_file , u'The first image name'
|
||||
assert len(service) == 2, u'The saved service should have two parts'
|
||||
assert service[u'header'][u'name'] == u'test', u'A test plugin should be returned'
|
||||
assert service[u'data'][0][u'title'] == u'church.jpg', u'The first title name should be "church,jpg"'
|
||||
assert service[u'data'][0][u'path'] == TEST_PATH, u'The path should match the input path'
|
||||
assert service[u'data'][0][u'image'] == test_file, u'The image should match the full path to image'
|
||||
|
||||
# WHEN validating a service item
|
||||
service_item.validate_item([u'jpg'])
|
||||
@ -165,7 +164,7 @@ class TestServiceItem(TestCase):
|
||||
service_item.validate_item([u'png'])
|
||||
|
||||
# THEN the service item should not be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid'
|
||||
assert service_item.is_valid is False, u'The service item should not be valid'
|
||||
|
||||
def serviceitem_load_custom_from_service_test(self):
|
||||
"""
|
||||
@ -173,41 +172,103 @@ class TestServiceItem(TestCase):
|
||||
"""
|
||||
# GIVEN: A new service item and a mocked add icon function
|
||||
service_item = ServiceItem(None)
|
||||
mocked_add_icon = MagicMock()
|
||||
service_item.add_icon = mocked_add_icon
|
||||
service_item.add_icon = MagicMock()
|
||||
|
||||
# WHEN: adding a custom from a saved Service
|
||||
line = self.convert_file_service_item(u'serviceitem_custom1.osd')
|
||||
line = self.convert_file_service_item(u'serviceitem_custom_1.osd')
|
||||
service_item.set_from_service(line)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert len(service_item._display_frames) == 0, u'The service item has no display frames'
|
||||
assert len(service_item.capabilities) == 5, u'There are 5 default custom item capabilities'
|
||||
assert len(service_item._display_frames) == 0, u'The service item should have no display frames'
|
||||
assert len(service_item.capabilities) == 5, u'There should be 5 default custom item capabilities'
|
||||
service_item.render(True)
|
||||
assert (service_item.get_display_title()) == u'Test Custom', u'The custom title should be correct'
|
||||
assert service_item.get_display_title() == u'Test Custom', u'The title should be "Test Custom"'
|
||||
assert service_item.get_frames()[0][u'text'] == VERSE[:-1], \
|
||||
u'The returned text matches the input, except the last line feed'
|
||||
assert service_item.get_rendered_frame(1) == VERSE.split(u'\n', 1)[0], u'The first line has been returned'
|
||||
assert service_item.get_frame_title(0) == u'Slide 1', u'"Slide 1" has been returned as the title'
|
||||
assert service_item.get_frame_title(1) == u'Slide 2', u'"Slide 2" has been returned as the title'
|
||||
assert service_item.get_frame_title(2) == u'', u'Blank has been returned as the title of slide 3'
|
||||
|
||||
def serviceitem_load_image_from_service_test(self):
|
||||
"""
|
||||
Test the Service Item - adding an image from a saved service
|
||||
"""
|
||||
# GIVEN: A new service item and a mocked add icon function
|
||||
service_item = ServiceItem(None)
|
||||
mocked_add_icon = MagicMock()
|
||||
service_item.add_icon = mocked_add_icon
|
||||
image_name = u'image_1.jpg'
|
||||
test_file = os.path.join(TEST_PATH, image_name)
|
||||
frame_array = {u'path': test_file, u'title': image_name}
|
||||
|
||||
# WHEN: adding a custom from a saved Service
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_icon = MagicMock()
|
||||
|
||||
# WHEN: adding an image from a saved Service and mocked exists
|
||||
line = self.convert_file_service_item(u'serviceitem_image_1.osd')
|
||||
with patch('os.path.exists'):
|
||||
service_item.set_from_service(line, TEST_PATH)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
print service_item.get_rendered_frame(0)
|
||||
assert service_item.get_rendered_frame(0) == test_file, u'The first frame should match the path to the image'
|
||||
assert service_item.get_frames()[0] == frame_array, u'The return should match frame array1'
|
||||
assert service_item.get_frame_path(0) == test_file, u'The frame path should match the full path to the image'
|
||||
assert service_item.get_frame_title(0) == image_name, u'The frame title should match the image name'
|
||||
assert service_item.get_display_title() == image_name, u'The display title should match the first image name'
|
||||
assert service_item.is_image() is True, u'This service item is an Image'
|
||||
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, u'This service item can be Maintained'
|
||||
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, u'This service item can be Previewed'
|
||||
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'This service item can be made to Loop'
|
||||
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||
u'This service item can have new items added'
|
||||
|
||||
def serviceitem_load_image_from_local_service_test(self):
|
||||
"""
|
||||
Test the Service Item - adding an image from a saved local service
|
||||
"""
|
||||
# GIVEN: A new service item and a mocked add icon function
|
||||
image_name1 = u'image_1.jpg'
|
||||
image_name2 = u'image_2.jpg'
|
||||
test_file1 = os.path.join(u'/home/openlp', image_name1)
|
||||
test_file2 = os.path.join(u'/home/openlp', image_name2)
|
||||
frame_array1 = {u'path': test_file1, u'title': image_name1}
|
||||
frame_array2 = {u'path': test_file2, u'title': image_name2}
|
||||
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_icon = MagicMock()
|
||||
|
||||
# WHEN: adding an image from a saved Service and mocked exists
|
||||
line = self.convert_file_service_item(u'serviceitem_image_2.osd')
|
||||
with patch('os.path.exists'):
|
||||
service_item.set_from_service(line)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert service_item.get_rendered_frame(0) == test_file1, u'The first frame should match the path to the image'
|
||||
assert service_item.get_rendered_frame(1) == test_file2, u'The Second frame should match the path to the image'
|
||||
assert service_item.get_frames()[0] == frame_array1, u'The return should match the frame array1'
|
||||
assert service_item.get_frames()[1] == frame_array2, u'The return should match the frame array2'
|
||||
assert service_item.get_frame_path(0) == test_file1, u'The frame path should match the full path to the image'
|
||||
assert service_item.get_frame_path(1) == test_file2, u'The frame path should match the full path to the image'
|
||||
assert service_item.get_frame_title(0) == image_name1, u'The 1st frame title should match the image name'
|
||||
assert service_item.get_frame_title(1) == image_name2, u'The 2nd frame title should match the image name'
|
||||
assert service_item.get_display_title().lower() == service_item.name, \
|
||||
u'The plugin name should match the display title, as there are > 1 Images'
|
||||
assert service_item.is_image() is True, u'This service item should be of an "image" type'
|
||||
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, u'This service item can be Maintained'
|
||||
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, u'This service item can be Previewed'
|
||||
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'This service item can be made to Loop'
|
||||
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||
u'This service item can have new items added'
|
||||
|
||||
def convert_file_service_item(self, name):
|
||||
service_file = os.path.join(TESTPATH, name)
|
||||
service_file = os.path.join(TEST_PATH, name)
|
||||
try:
|
||||
open_file = open(service_file, u'r')
|
||||
items = cPickle.load(open_file)
|
||||
first_line = items[0]
|
||||
except:
|
||||
except IOError:
|
||||
first_line = u''
|
||||
return first_line
|
||||
return first_line
|
||||
|
||||
|
22
tests/functional/openlp_core_lib/test_uistrings.py
Normal file
22
tests/functional/openlp_core_lib/test_uistrings.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""
|
||||
Package to test the openlp.core.lib.uistrings package.
|
||||
"""
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.lib import UiStrings
|
||||
|
||||
class TestUiStrings(TestCase):
|
||||
|
||||
def check_same_instance_test(self):
|
||||
"""
|
||||
Test the UiStrings class - we always should have only one instance of the UiStrings class.
|
||||
"""
|
||||
# WHEN: Create two instances of the UiStrings class.
|
||||
first_instance = UiStrings()
|
||||
second_instance = UiStrings()
|
||||
|
||||
# THEN: Check if the instances are the same.
|
||||
assert first_instance is second_instance, "They should be the same instance!"
|
||||
|
||||
|
@ -6,3 +6,8 @@ sip.setapi(u'QTextStream', 2)
|
||||
sip.setapi(u'QTime', 2)
|
||||
sip.setapi(u'QUrl', 2)
|
||||
sip.setapi(u'QVariant', 2)
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication.
|
||||
application = QtGui.QApplication([])
|
||||
|
0
tests/interfaces/openlp_core_lib/__init__.py
Normal file
0
tests/interfaces/openlp_core_lib/__init__.py
Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user