2009-02-08 15:25:00 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
OpenLP - Open Source Lyrics Projection
|
2009-07-10 15:45:17 +00:00
|
|
|
|
2009-02-08 15:25:00 +00:00
|
|
|
Copyright (c) 2008 Raoul Snyman
|
2009-07-10 15:45:17 +00:00
|
|
|
|
2009-05-20 20:17:20 +00:00
|
|
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
2009-02-08 15:25:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
2009-05-20 20:17:20 +00:00
|
|
|
from PyQt4 import QtCore
|
2009-02-08 15:25:00 +00:00
|
|
|
|
2009-05-20 20:17:20 +00:00
|
|
|
class EventReceiver(QtCore.QObject):
|
2009-02-08 15:25:00 +00:00
|
|
|
"""
|
|
|
|
Class to allow events to be passed from different parts of the system.
|
|
|
|
This is a private class and should not be used directly but via the Receiver class
|
2009-08-24 20:05:46 +00:00
|
|
|
|
|
|
|
``stop_import``
|
|
|
|
Stops the Bible Import
|
|
|
|
``pre_load_bibles``
|
|
|
|
Triggers the plugin to relaod the bible lists
|
|
|
|
``process_events``
|
|
|
|
Requests the Application to flush the events queue
|
|
|
|
``{preview|live}_slide_first``
|
|
|
|
display the first slide on the list
|
|
|
|
``{preview|live}_slide_previous``
|
|
|
|
display the previous slide on the list
|
|
|
|
``{preview|live}_slide_next``
|
|
|
|
display the next slide on the list
|
|
|
|
``{preview|live}_slide_last``
|
|
|
|
display the last slide on the list
|
|
|
|
``{plugin}_add_service_item ``
|
|
|
|
ask the plugin to push the selected items to the service item
|
|
|
|
``update_themes ``
|
|
|
|
send out message with new themes
|
|
|
|
``update_global_theme ``
|
|
|
|
Tell the components we have a new global theme
|
|
|
|
|
2009-02-08 15:25:00 +00:00
|
|
|
"""
|
2009-08-24 20:05:46 +00:00
|
|
|
|
|
|
|
|
2009-02-08 15:25:00 +00:00
|
|
|
def __init__(self):
|
2009-05-20 20:17:20 +00:00
|
|
|
QtCore.QObject.__init__(self)
|
2009-03-10 16:46:25 +00:00
|
|
|
|
2009-02-11 18:33:54 +00:00
|
|
|
def send_message(self, event, msg=None):
|
2009-08-24 20:05:46 +00:00
|
|
|
print u'message ', event, msg
|
2009-06-04 16:17:26 +00:00
|
|
|
self.emit(QtCore.SIGNAL(event), msg)
|
2009-03-10 16:46:25 +00:00
|
|
|
|
2009-02-08 15:25:00 +00:00
|
|
|
class Receiver():
|
|
|
|
"""
|
|
|
|
Class to allow events to be passed from different parts of the system.
|
2009-02-20 21:03:45 +00:00
|
|
|
This is a static wrapper around the EventReceiver class.
|
2009-02-08 15:25:00 +00:00
|
|
|
As there is only one instance of it in the systems the QT signal/slot architecture
|
|
|
|
can send messages across the system
|
2009-07-10 15:45:17 +00:00
|
|
|
|
2009-08-24 20:05:46 +00:00
|
|
|
``Send message``
|
|
|
|
Receiver().send_message(u'<<Message ID>>', data)
|
2009-03-10 16:46:25 +00:00
|
|
|
|
2009-08-24 20:05:46 +00:00
|
|
|
``Receive Message``
|
|
|
|
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
|
2009-03-10 16:46:25 +00:00
|
|
|
"""
|
|
|
|
eventreceiver = EventReceiver()
|
|
|
|
|
2009-02-08 15:25:00 +00:00
|
|
|
@staticmethod
|
2009-02-11 18:33:54 +00:00
|
|
|
def send_message(event, msg=None):
|
|
|
|
Receiver.eventreceiver.send_message(event, msg)
|
2009-03-10 16:46:25 +00:00
|
|
|
|
|
|
|
@staticmethod
|
2009-02-08 15:25:00 +00:00
|
|
|
def get_receiver():
|
|
|
|
return Receiver.eventreceiver
|