forked from openlp/openlp
EventManager Removal part 1
This commit is contained in:
parent
8b1425d163
commit
7226d4a232
@ -25,11 +25,36 @@ class EventReceiver(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
Class to allow events to be passed from different parts of the system.
|
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
|
This is a private class and should not be used directly but via the Receiver class
|
||||||
|
|
||||||
|
``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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
|
||||||
def send_message(self, event, msg=None):
|
def send_message(self, event, msg=None):
|
||||||
|
print u'message ', event, msg
|
||||||
self.emit(QtCore.SIGNAL(event), msg)
|
self.emit(QtCore.SIGNAL(event), msg)
|
||||||
|
|
||||||
class Receiver():
|
class Receiver():
|
||||||
@ -39,11 +64,11 @@ class Receiver():
|
|||||||
As there is only one instance of it in the systems the QT signal/slot architecture
|
As there is only one instance of it in the systems the QT signal/slot architecture
|
||||||
can send messages across the system
|
can send messages across the system
|
||||||
|
|
||||||
Send message
|
``Send message``
|
||||||
Receiver().send_message(u'messageid',data)
|
Receiver().send_message(u'<<Message ID>>', data)
|
||||||
|
|
||||||
Receive Message
|
``Receive Message``
|
||||||
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<<ACTION>>)
|
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
|
||||||
"""
|
"""
|
||||||
eventreceiver = EventReceiver()
|
eventreceiver = EventReceiver()
|
||||||
|
|
||||||
|
@ -19,12 +19,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import PluginConfig
|
from openlp.core.lib import PluginConfig
|
||||||
# why does this not work???
|
# why does this not work???
|
||||||
# from openlp.core.lib import Event, EventType
|
# from openlp.core.lib import Event, EventType
|
||||||
# so I have to do this???
|
# so I have to do this???
|
||||||
from event import Event, EventType
|
from event import Event, EventType
|
||||||
|
from eventreceiver import Receiver
|
||||||
|
|
||||||
class Plugin(object):
|
class Plugin(object):
|
||||||
"""
|
"""
|
||||||
@ -126,7 +128,8 @@ class Plugin(object):
|
|||||||
self.render_manager = plugin_helpers[u'render']
|
self.render_manager = plugin_helpers[u'render']
|
||||||
self.service_manager = plugin_helpers[u'service']
|
self.service_manager = plugin_helpers[u'service']
|
||||||
self.settings = plugin_helpers[u'settings']
|
self.settings = plugin_helpers[u'settings']
|
||||||
self.dnd_id=None
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
|
||||||
|
|
||||||
def check_pre_conditions(self):
|
def check_pre_conditions(self):
|
||||||
"""
|
"""
|
||||||
@ -177,29 +180,37 @@ class Plugin(object):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def process_add_service_event(self):
|
||||||
|
"""
|
||||||
|
Proxy method as method is not defined early enough
|
||||||
|
in the processing
|
||||||
|
"""
|
||||||
|
log.debug(u'Handle event called with plugin %s' % self.name)
|
||||||
|
self.media_item.onAddClick()
|
||||||
def handle_event(self, event):
|
def handle_event(self, event):
|
||||||
"""
|
# """
|
||||||
Handle the event contained in the event object. If you want
|
# Handle the event contained in the event object. If you want
|
||||||
to use this default behaviour, you must set self.dnd_id equal
|
# to use this default behaviour, you must set self.dnd_id equal
|
||||||
to that sent by the dnd source - eg the MediaItem
|
# to that sent by the dnd source - eg the MediaItem
|
||||||
|
#
|
||||||
``event``
|
# ``event``
|
||||||
An object describing the event.
|
# An object describing the event.
|
||||||
"""
|
# """
|
||||||
# default behaviour - can be overridden if desired
|
# # default behaviour - can be overridden if desired
|
||||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
pass
|
||||||
if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
|
# log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||||
log.debug(u'Load Service Item received')
|
# if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
|
||||||
self.media_item.onAddClick()
|
# log.debug(u'Load Service Item received')
|
||||||
return True
|
# self.media_item.onAddClick()
|
||||||
if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
|
# return True
|
||||||
log.debug(u'Load Preview Item received')
|
# if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
|
||||||
self.media_item.onPreviewClick()
|
# log.debug(u'Load Preview Item received')
|
||||||
return True
|
# self.media_item.onPreviewClick()
|
||||||
if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
|
# return True
|
||||||
log.debug(u'Load Live Show Item received')
|
# if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
|
||||||
return True
|
# log.debug(u'Load Live Show Item received')
|
||||||
self.media_item.onLiveClick()
|
# return True
|
||||||
|
# self.media_item.onLiveClick()
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
"""
|
"""
|
||||||
@ -208,37 +219,37 @@ class Plugin(object):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def save(self, data):
|
# def save(self, data):
|
||||||
"""
|
# """
|
||||||
Service item data is passed to this function, which should return a
|
# Service item data is passed to this function, which should return a
|
||||||
string which can be written to the service file.
|
# string which can be written to the service file.
|
||||||
|
#
|
||||||
``data``
|
# ``data``
|
||||||
The data to be saved.
|
# The data to be saved.
|
||||||
"""
|
# """
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
def load(self, string):
|
# def load(self, string):
|
||||||
"""
|
# """
|
||||||
A string from the service file is passed in. This function parses and
|
# A string from the service file is passed in. This function parses and
|
||||||
sets up the internals of the plugin.
|
# sets up the internals of the plugin.
|
||||||
|
#
|
||||||
``string``
|
# ``string``
|
||||||
The data to be loaded into the plugin.
|
# The data to be loaded into the plugin.
|
||||||
"""
|
# """
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
def render(self, theme, screen=None):
|
# def render(self, theme, screen=None):
|
||||||
"""
|
# """
|
||||||
Render the screenth screenful of data using theme settings in theme.
|
# Render the screenth screenful of data using theme settings in theme.
|
||||||
|
#
|
||||||
``theme``
|
# ``theme``
|
||||||
The theme to use when rendering.
|
# The theme to use when rendering.
|
||||||
|
#
|
||||||
``screen``
|
# ``screen``
|
||||||
Defaults to *None*. The screen to render to.
|
# Defaults to *None*. The screen to render to.
|
||||||
"""
|
# """
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
"""
|
"""
|
||||||
|
@ -24,9 +24,9 @@ import zipfile
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \
|
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||||
RenderManager, EventType, EventManager, translate, buildIcon, \
|
RenderManager, translate, buildIcon, \
|
||||||
contextMenuAction, contextMenuSeparator
|
contextMenuAction, contextMenuSeparator, Receiver
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
class ServiceManagerList(QtGui.QTreeWidget):
|
class ServiceManagerList(QtGui.QTreeWidget):
|
||||||
@ -66,6 +66,7 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
|||||||
class Iter(QtGui.QTreeWidgetItemIterator):
|
class Iter(QtGui.QTreeWidgetItemIterator):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QtGui.QTreeWidgetItemIterator.__init__(self, *args)
|
QtGui.QTreeWidgetItemIterator.__init__(self, *args)
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
self.__iadd__(1)
|
self.__iadd__(1)
|
||||||
value = self.value()
|
value = self.value()
|
||||||
@ -488,7 +489,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
link = event.mimeData()
|
link = event.mimeData()
|
||||||
if link.hasText():
|
if link.hasText():
|
||||||
plugin = event.mimeData().text()
|
plugin = event.mimeData().text()
|
||||||
self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin))
|
Receiver().send_message(u'%s_add_service_item' % plugin)
|
||||||
|
|
||||||
def updateThemeList(self, theme_list):
|
def updateThemeList(self, theme_list):
|
||||||
"""
|
"""
|
||||||
|
@ -30,7 +30,7 @@ from openlp.core.ui import AmendThemeForm, ServiceManager
|
|||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import PluginConfig, Event, EventType, \
|
from openlp.core.lib import PluginConfig, Event, EventType, \
|
||||||
EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \
|
EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \
|
||||||
file_to_xml, buildIcon
|
file_to_xml, buildIcon, Receiver
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
class ThemeManager(QtGui.QWidget):
|
class ThemeManager(QtGui.QWidget):
|
||||||
@ -184,7 +184,8 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.pushThemes()
|
self.pushThemes()
|
||||||
|
|
||||||
def pushThemes(self):
|
def pushThemes(self):
|
||||||
self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))
|
#self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))
|
||||||
|
Receiver().send_message(u'update_themes', self.getThemes() )
|
||||||
|
|
||||||
def getThemes(self):
|
def getThemes(self):
|
||||||
return self.themelist
|
return self.themelist
|
||||||
|
@ -41,9 +41,6 @@ class BiblePlugin(Plugin):
|
|||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
#Register the bible Manager
|
#Register the bible Manager
|
||||||
self.biblemanager = BibleManager(self.config)
|
self.biblemanager = BibleManager(self.config)
|
||||||
# passed with drag and drop messages
|
|
||||||
self.dnd_id = u'Bibles'
|
|
||||||
|
|
||||||
|
|
||||||
def get_settings_tab(self):
|
def get_settings_tab(self):
|
||||||
self.bibles_tab = BiblesTab()
|
self.bibles_tab = BiblesTab()
|
||||||
|
@ -152,9 +152,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
|||||||
def onCancelButtonClicked(self):
|
def onCancelButtonClicked(self):
|
||||||
# tell import to stop
|
# tell import to stop
|
||||||
self.message = u'Bible import stopped'
|
self.message = u'Bible import stopped'
|
||||||
Receiver().send_message(u'openlpstopimport')
|
Receiver().send_message(u'stop_import')
|
||||||
# tell bibleplugin to reload the bibles
|
# tell bibleplugin to reload the bibles
|
||||||
Receiver().send_message(u'openlpreloadbibles')
|
Receiver().send_message(u'pre_load_bibles')
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def onImportButtonClicked(self):
|
def onImportButtonClicked(self):
|
||||||
@ -172,7 +172,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
|||||||
self.MessageLabel.setText(message)
|
self.MessageLabel.setText(message)
|
||||||
self.ProgressBar.setValue(self.barmax)
|
self.ProgressBar.setValue(self.barmax)
|
||||||
# tell bibleplugin to reload the bibles
|
# tell bibleplugin to reload the bibles
|
||||||
Receiver().send_message(u'openlpreloadbibles')
|
Receiver().send_message(u'pre_load_bibles')
|
||||||
reply = QtGui.QMessageBox.information(self,
|
reply = QtGui.QMessageBox.information(self,
|
||||||
translate(u'BibleMediaItem', u'Information'),
|
translate(u'BibleMediaItem', u'Information'),
|
||||||
translate(u'BibleMediaItem', message))
|
translate(u'BibleMediaItem', message))
|
||||||
|
@ -41,7 +41,6 @@ class PresentationPlugin(Plugin):
|
|||||||
self.icon = QtGui.QIcon()
|
self.icon = QtGui.QIcon()
|
||||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
|
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.dnd_id = u'Presentations'
|
|
||||||
|
|
||||||
def get_settings_tab(self):
|
def get_settings_tab(self):
|
||||||
"""
|
"""
|
||||||
|
@ -27,7 +27,7 @@ from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
|
|||||||
|
|
||||||
class SongListView(BaseListWithDnD):
|
class SongListView(BaseListWithDnD):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
self.PluginName = u'Song'
|
self.PluginName = u'Songs'
|
||||||
BaseListWithDnD.__init__(self, parent)
|
BaseListWithDnD.__init__(self, parent)
|
||||||
|
|
||||||
class SongMediaItem(MediaManagerItem):
|
class SongMediaItem(MediaManagerItem):
|
||||||
|
@ -46,8 +46,6 @@ class SongsPlugin(Plugin):
|
|||||||
self.icon = QtGui.QIcon()
|
self.icon = QtGui.QIcon()
|
||||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),
|
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
# passed with drag and drop messages
|
|
||||||
self.dnd_id=u'Song'
|
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the MediaManagerItem object
|
||||||
|
Loading…
Reference in New Issue
Block a user