openlp/openlp/core/lib/eventreceiver.py

294 lines
9.2 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2011-12-27 10:33:55 +00:00
# Copyright (c) 2008-2012 Raoul Snyman #
# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
2012-10-21 13:16:22 +00:00
# Meinert Jordan, Armin Köhler, Eric Ludin, 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, #
# Erode 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 #
###############################################################################
2010-06-19 17:31:42 +00:00
"""
Provide event handling code for OpenLP
"""
import logging
2009-09-29 12:51:38 +00:00
from PyQt4 import QtCore
2010-02-27 15:31:23 +00:00
log = logging.getLogger(__name__)
2009-09-29 12:51:38 +00:00
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``
2011-10-22 11:16:25 +00:00
Changes the bottom status bar text on the mainwindow.
``openlp_warning_message``
Displays a standalone Warning Message.
``openlp_error_message``
Displays a standalone Error Message.
``openlp_information_message``
Displays a standalone Information Message.
``cursor_busy``
Makes the cursor got to a busy form.
``cursor_normal``
Resets the cursor to default.
2009-08-24 20:05:46 +00:00
2010-04-22 21:22:09 +00:00
``openlp_process_events``
Requests the Application to flush the events queue.
2009-08-29 07:17:56 +00:00
2010-04-22 21:22:09 +00:00
``openlp_version_check``
Version has changed so pop up window.
2009-08-29 07:17:56 +00:00
``openlp_stop_wizard``
Stops a wizard before completion.
**Setting related signals**
2010-04-22 21:22:09 +00:00
``config_updated``
Informs components that the config has changed.
2009-08-29 07:17:56 +00:00
2010-04-22 21:22:09 +00:00
``config_screen_changed``
The display monitor has been changed.
**Slidecontroller signals**
2009-08-29 07:17:56 +00:00
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_next``
Moves to the next slide.
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_next_noloop``
Moves to the next slide without auto advance.
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_previous``
Moves to the previous slide.
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_previous_noloop``
Moves to the previous slide, without auto advance.
2010-04-22 21:22:09 +00:00
2010-04-29 22:52:23 +00:00
``slidecontroller_{live|preview}_set``
Moves to a specific slide, by index.
2010-04-29 22:52:23 +00:00
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_started``
Broadcasts that an item has been made live/previewed.
2010-04-22 21:22:09 +00:00
``slidecontroller_{live|preview}_change``
2010-09-30 05:12:06 +00:00
Informs the slidecontroller that a slide change has occurred and to
update itself.
2010-04-29 22:52:23 +00:00
``slidecontroller_{live|preview}_changed``
Broadcasts that the slidecontroller has changed the current slide.
2010-04-29 22:52:23 +00:00
``slidecontroller_{live|preview}_blank``
Request that the output screen is blanked.
``slidecontroller_{live|preview}_unblank``
Request that the output screen is unblanked.
2010-04-22 21:22:09 +00:00
``slidecontroller_live_spin_delay``
Pushes out the loop delay.
2012-04-04 07:26:51 +00:00
``slidecontroller_update_slide_limits``
Updates the slide_limits variable from the saved settings.
2010-04-22 21:22:09 +00:00
``slidecontroller_live_stop_loop``
Stop the loop on the main display.
2011-12-10 14:34:28 +00:00
**Servicemanager related signals**
2010-04-22 21:22:09 +00:00
2011-12-10 14:34:28 +00:00
``servicemanager_new_service``
A new service is being loaded or created.
2010-04-29 22:52:23 +00:00
``servicemanager_previous_item``
Display the previous item in the service.
2010-04-29 22:52:23 +00:00
``servicemanager_preview_live``
Requests a Preview item from the Service Manager to update live and add
a new item to the preview panel.
2010-04-29 22:52:23 +00:00
``servicemanager_next_item``
Display the next item in the service.
2010-04-22 21:22:09 +00:00
2010-04-29 22:52:23 +00:00
``servicemanager_set_item``
Go live on a specific item, by index.
2009-08-24 20:05:46 +00:00
``service_item_update``
Passes back to the service manager the service item after it has been
processed by the plugin.
2009-10-29 15:57:58 +00:00
**Display signals**
2010-09-30 05:12:06 +00:00
``update_display_css``
CSS has been updated which needs to be changed on the main display.
2009-08-29 07:17:56 +00:00
**Live Display signals**
2010-04-22 21:22:09 +00:00
``live_display_hide``
Hide the live display.
2010-04-22 21:22:09 +00:00
``live_display_show``
Return the live display.
2010-04-22 21:22:09 +00:00
``live_display_active``
The live display has been made active.
2010-04-22 21:22:09 +00:00
``live_display_blank_check``
Check to see if the blank display message is required.
2010-04-22 21:22:09 +00:00
**Theme related singlas**
2010-04-22 21:22:09 +00:00
``theme_update_list``
send out message with new themes.
2010-04-22 21:22:09 +00:00
``theme_update_global``
Tell the components we have a new global theme.
**Plugin specific signals**
2009-08-29 07:17:56 +00:00
2009-09-05 13:30:09 +00:00
``{plugin}_start``
Requests a plugin to start a external program. Path and file have to
be provided in the message.
2009-09-05 13:30:09 +00:00
2009-09-05 19:58:02 +00:00
``{plugin}_first``
Requests a plugin to handle a first event.
2009-09-05 19:58:02 +00:00
``{plugin}_previous``
Requests a plugin to handle a previous event.
2009-09-05 19:58:02 +00:00
``{plugin}_next``
Requests a plugin to handle a next event.
2009-09-05 19:58:02 +00:00
``{plugin}_last``
Requests a plugin to handle a last event.
2009-09-05 19:58:02 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_slide``
Requests a plugin to handle a go to specific slide event.
2010-04-22 21:22:09 +00:00
2009-09-05 19:58:02 +00:00
``{plugin}_stop``
Requests a plugin to handle a stop event.
2009-09-05 19:58:02 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_blank``
Requests a plugin to handle a blank screen event.
2010-04-22 21:22:09 +00:00
``{plugin}_unblank``
Requests a plugin to handle an unblank screen event.
2010-04-22 21:22:09 +00:00
2009-10-29 09:18:26 +00:00
``{plugin}_edit``
Requests a plugin edit a database item with the key as the payload.
2009-10-29 09:18:26 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_edit_clear``
Editing has been completed.
2009-10-17 05:47:17 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_load_list``
Tells the the plugin to reload the media manager list.
2009-10-24 19:43:16 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_preview``
Tells the plugin it's item can be previewed.
2009-10-29 09:18:26 +00:00
2010-04-22 21:22:09 +00:00
``{plugin}_add_service_item``
Ask the plugin to push the selected items to the service item.
2009-10-29 09:18:26 +00:00
2012-03-17 10:46:08 +00:00
``{plugin}_service_load``
Ask the plugin to process an individual service item after it has been
loaded.
``{plugin}_config_updated``
2012-03-17 10:46:08 +00:00
The config has changed so tell the plugin about it.
2010-09-30 05:12:06 +00:00
2010-04-22 21:22:09 +00:00
``alerts_text``
Displays an alert message.
2010-09-30 05:12:06 +00:00
2010-04-22 21:22:09 +00:00
``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.
2011-10-16 15:39:49 +00:00
"""
def __init__(self):
"""
Initialise the event receiver, calling the parent constructor.
"""
2009-09-29 12:51:38 +00:00
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.
"""
2009-09-07 17:08:58 +00:00
log.debug(u'Event %s passed with payload %s' % (event, msg))
2009-09-29 12:51:38 +00:00
self.emit(QtCore.SIGNAL(event), msg)
2010-05-25 14:30:34 +00:00
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
2010-06-19 17:31:42 +00:00
``QtCore.QObject.connect(
Receiver.get_receiver(),
2011-10-22 11:28:47 +00:00
QtCore.SIGNAL(u'<<Message ID>>'),
2010-06-19 17:31:42 +00:00
<<ACTION>>
)``
"""
2012-06-09 15:46:01 +00:00
__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.
"""
2012-06-09 15:46:01 +00:00
Receiver.__eventreceiver__.send_message(event, msg)
@staticmethod
def get_receiver():
"""
2012-06-09 15:46:01 +00:00
Get the global ``__eventreceiver__`` instance.
"""
2012-06-09 15:46:01 +00:00
return Receiver.__eventreceiver__