From 7226d4a2321cf5f607ccffeaa9bd997f178535db Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 24 Aug 2009 21:05:46 +0100 Subject: [PATCH 1/4] EventManager Removal part 1 --- openlp/core/lib/eventreceiver.py | 33 ++++- openlp/core/lib/plugin.py | 119 ++++++++++-------- openlp/core/ui/servicemanager.py | 9 +- openlp/core/ui/thememanager.py | 5 +- openlp/plugins/bibles/bibleplugin.py | 3 - .../plugins/bibles/forms/bibleimportform.py | 6 +- .../presentations/presentationplugin.py | 1 - openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 - 9 files changed, 106 insertions(+), 74 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index ef8e0d97f..2bb3b6776 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -25,11 +25,36 @@ 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 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): QtCore.QObject.__init__(self) def send_message(self, event, msg=None): + print u'message ', event, msg self.emit(QtCore.SIGNAL(event), msg) class Receiver(): @@ -39,11 +64,11 @@ class Receiver(): As there is only one instance of it in the systems the QT signal/slot architecture can send messages across the system - Send message - Receiver().send_message(u'messageid',data) + ``Send message`` + Receiver().send_message(u'<>', data) - Receive Message - QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<>) + ``Receive Message`` + QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<>'),<>) """ eventreceiver = EventReceiver() diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 05700328c..11e6092b0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -19,12 +19,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ import logging +from PyQt4 import QtCore from openlp.core.lib import PluginConfig # why does this not work??? # from openlp.core.lib import Event, EventType # so I have to do this??? from event import Event, EventType +from eventreceiver import Receiver class Plugin(object): """ @@ -126,7 +128,8 @@ class Plugin(object): self.render_manager = plugin_helpers[u'render'] self.service_manager = plugin_helpers[u'service'] 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): """ @@ -177,29 +180,37 @@ class Plugin(object): """ 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): - """ - Handle the event contained in the event object. If you want - to use this default behaviour, you must set self.dnd_id equal - to that sent by the dnd source - eg the MediaItem - - ``event`` - An object describing the event. - """ - # default behaviour - can be overridden if desired - log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) - if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id: - log.debug(u'Load Service Item received') - self.media_item.onAddClick() - return True - if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id: - log.debug(u'Load Preview Item received') - self.media_item.onPreviewClick() - return True - if event.event_type == EventType.LiveShow and event.payload == self.dnd_id: - log.debug(u'Load Live Show Item received') - return True - self.media_item.onLiveClick() +# """ +# Handle the event contained in the event object. If you want +# to use this default behaviour, you must set self.dnd_id equal +# to that sent by the dnd source - eg the MediaItem +# +# ``event`` +# An object describing the event. +# """ +# # default behaviour - can be overridden if desired + pass +# log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) +# if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id: +# log.debug(u'Load Service Item received') +# self.media_item.onAddClick() +# return True +# if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id: +# log.debug(u'Load Preview Item received') +# self.media_item.onPreviewClick() +# return True +# if event.event_type == EventType.LiveShow and event.payload == self.dnd_id: +# log.debug(u'Load Live Show Item received') +# return True +# self.media_item.onLiveClick() def about(self): """ @@ -208,37 +219,37 @@ class Plugin(object): """ pass - def save(self, data): - """ - Service item data is passed to this function, which should return a - string which can be written to the service file. - - ``data`` - The data to be saved. - """ - pass - - def load(self, string): - """ - A string from the service file is passed in. This function parses and - sets up the internals of the plugin. - - ``string`` - The data to be loaded into the plugin. - """ - pass - - def render(self, theme, screen=None): - """ - Render the screenth screenful of data using theme settings in theme. - - ``theme`` - The theme to use when rendering. - - ``screen`` - Defaults to *None*. The screen to render to. - """ - pass +# def save(self, data): +# """ +# Service item data is passed to this function, which should return a +# string which can be written to the service file. +# +# ``data`` +# The data to be saved. +# """ +# pass +# +# def load(self, string): +# """ +# A string from the service file is passed in. This function parses and +# sets up the internals of the plugin. +# +# ``string`` +# The data to be loaded into the plugin. +# """ +# pass +# +# def render(self, theme, screen=None): +# """ +# Render the screenth screenful of data using theme settings in theme. +# +# ``theme`` +# The theme to use when rendering. +# +# ``screen`` +# Defaults to *None*. The screen to render to. +# """ +# pass def initialise(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6a1dc0f61..c20a19bed 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -24,9 +24,9 @@ import zipfile import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \ - RenderManager, EventType, EventManager, translate, buildIcon, \ - contextMenuAction, contextMenuSeparator +from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ + RenderManager, translate, buildIcon, \ + contextMenuAction, contextMenuSeparator, Receiver from openlp.core.utils import ConfigHelper class ServiceManagerList(QtGui.QTreeWidget): @@ -66,6 +66,7 @@ class ServiceManagerList(QtGui.QTreeWidget): class Iter(QtGui.QTreeWidgetItemIterator): def __init__(self, *args): QtGui.QTreeWidgetItemIterator.__init__(self, *args) + def next(self): self.__iadd__(1) value = self.value() @@ -488,7 +489,7 @@ class ServiceManager(QtGui.QWidget): link = event.mimeData() if link.hasText(): 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): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a2fd8b36d..a6c420151 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -30,7 +30,7 @@ from openlp.core.ui import AmendThemeForm, ServiceManager from openlp.core.theme import Theme from openlp.core.lib import PluginConfig, Event, EventType, \ EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \ - file_to_xml, buildIcon + file_to_xml, buildIcon, Receiver from openlp.core.utils import ConfigHelper class ThemeManager(QtGui.QWidget): @@ -184,7 +184,8 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() 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): return self.themelist diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 90e91bd0c..5eeabb514 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -41,9 +41,6 @@ class BiblePlugin(Plugin): QtGui.QIcon.Normal, QtGui.QIcon.Off) #Register the bible Manager self.biblemanager = BibleManager(self.config) - # passed with drag and drop messages - self.dnd_id = u'Bibles' - def get_settings_tab(self): self.bibles_tab = BiblesTab() diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 342818585..c07ed53d0 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -152,9 +152,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onCancelButtonClicked(self): # tell import to stop self.message = u'Bible import stopped' - Receiver().send_message(u'openlpstopimport') + Receiver().send_message(u'stop_import') # tell bibleplugin to reload the bibles - Receiver().send_message(u'openlpreloadbibles') + Receiver().send_message(u'pre_load_bibles') self.close() def onImportButtonClicked(self): @@ -172,7 +172,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): self.MessageLabel.setText(message) self.ProgressBar.setValue(self.barmax) # tell bibleplugin to reload the bibles - Receiver().send_message(u'openlpreloadbibles') + Receiver().send_message(u'pre_load_bibles') reply = QtGui.QMessageBox.information(self, translate(u'BibleMediaItem', u'Information'), translate(u'BibleMediaItem', message)) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 6bbce4c13..0f3a230e1 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -41,7 +41,6 @@ class PresentationPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.dnd_id = u'Presentations' def get_settings_tab(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 9f7c3f112..6e19b3961 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -27,7 +27,7 @@ from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm class SongListView(BaseListWithDnD): def __init__(self, parent=None): - self.PluginName = u'Song' + self.PluginName = u'Songs' BaseListWithDnD.__init__(self, parent) class SongMediaItem(MediaManagerItem): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index d18e008ad..48fe8fcdb 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -46,8 +46,6 @@ class SongsPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - # passed with drag and drop messages - self.dnd_id=u'Song' def get_media_manager_item(self): # Create the MediaManagerItem object From 9b826aab5600ebf193dfd88e80619c941e1f47ce Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 25 Aug 2009 06:18:09 +0100 Subject: [PATCH 2/4] EventManager Removal part 2 --- openlp/core/ui/mainwindow.py | 8 ++------ openlp/core/ui/servicemanager.py | 2 ++ openlp/core/ui/themestab.py | 4 +++- openlp/plugins/bibles/bibleplugin.py | 12 ------------ openlp/plugins/bibles/lib/biblestab.py | 4 +++- openlp/plugins/custom/customplugin.py | 12 ------------ openlp/plugins/custom/forms/editcustomform.py | 4 +++- openlp/plugins/images/imageplugin.py | 2 -- openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 4 +++- openlp/plugins/songs/songsplugin.py | 3 --- 11 files changed, 17 insertions(+), 40 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 800af1d2a..dbdb70a96 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -593,9 +593,5 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): title = u'%s - %s*' % (self.mainTitle, service_name) self.setWindowTitle(title) - def handle_event(self, event): - if event.event_type == EventType.ThemeListChanged: - self.ServiceManagerContents.updateThemeList(event.payload) - self.settingsForm.ThemesTab.updateThemeList(event.payload) - self.DefaultThemeLabel.setText(self.defaultThemeText + \ - self.ThemeManagerContents.getDefault()) + def DefaultThemeChanged(self, theme): + self.DefaultThemeLabel.setText(self.defaultThemeText + theme) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c20a19bed..eaac4a3d2 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -159,6 +159,8 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed) QtCore.QObject.connect(self.ServiceManagerList, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_themes'), self.updateThemeList) # Last little bits of setting up self.config = PluginConfig(u'ServiceManager') self.servicePath = self.config.get_data_path() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 7b18a9917..489749e94 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import SettingsTab, translate, Receiver class ThemesTab(SettingsTab): """ @@ -98,6 +98,8 @@ class ThemesTab(SettingsTab): QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_themes'), self.updateThemeList) def retranslateUi(self): self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme')) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 5eeabb514..b3ba5c94b 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -65,18 +65,6 @@ class BiblePlugin(Plugin): export_menu.addAction(self.ExportBibleItem) self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible')) - def initialise(self): - pass - def onBibleNewClick(self): self.media_item.onBibleNewClick() - def handle_event(self, event): - """ - Handle the event contained in the event object. - """ - log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) - if event.event_type == EventType.ThemeListChanged: - log.debug(u'New Theme request received') - self.bibles_tab.updateThemeList(event.payload) - return Plugin.handle_event(self, event) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index a4bf46363..a9743abd5 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -21,7 +21,7 @@ import logging from PyQt4 import Qt, QtCore, QtGui -from openlp.core.lib import translate, str_to_bool +from openlp.core.lib import translate, str_to_bool, Receiver from openlp.core.lib import SettingsTab class BiblesTab(SettingsTab): @@ -146,6 +146,8 @@ class BiblesTab(SettingsTab): QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged) QtCore.QObject.connect(self.LayoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_themes'), self.updateThemeList) def retranslateUi(self): self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display')) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index fa2850a19..368bcbf07 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -42,20 +42,8 @@ class CustomPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - # passed with drag and drop messages - self.dnd_id=u'Custom' def get_media_manager_item(self): # Create the CustomManagerItem object self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides') return self.media_item - - def handle_event(self, event): - """ - Handle the event contained in the event object. - """ - log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) - if event.event_type == EventType.ThemeListChanged: - log.debug(u'New Theme request received') - self.edit_custom_form.loadThemes(event.payload) - return Plugin.handle_event(self, event) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a7b48bd12..fe9b24230 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import Qt, QtCore, QtGui from editcustomdialog import Ui_customEditDialog -from openlp.core.lib import SongXMLBuilder, SongXMLParser +from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver from openlp.plugins.custom.lib.models import CustomSlide class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): @@ -50,6 +50,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected) QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_themes'), self.loadThemest) # Create other objects and forms self.custommanager = custommanager self.initialise() diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 8a49b8c74..48471f826 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -37,8 +37,6 @@ class ImagePlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - # passed with drag and drop messages - self.dnd_id = u'Image' def get_settings_tab(self): self.ImageTab = ImageTab() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 443372b7a..560b23be5 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -28,7 +28,7 @@ from openlp.plugins.images.lib.imagetoolbar import ImageToolbar # in order for DnD to the Service manager to work correctly. class ImageListView(BaseListWithDnD): def __init__(self, parent=None): - self.PluginName = u'Image' + self.PluginName = u'Images' BaseListWithDnD.__init__(self, parent) class ImageMediaItem(MediaManagerItem): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 6bfd06cf0..52f91b1e1 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -23,7 +23,7 @@ import logging from PyQt4 import Qt, QtCore, QtGui from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \ - EventType, EventManager, translate + EventType, EventManager, translate, Receiver from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib.models import Song from editsongdialog import Ui_EditSongDialog @@ -71,6 +71,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged) QtCore.QObject.connect(self.MaintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_themes'), self.loadThemes) # Create other objects and forms self.songmanager = songmanager self.eventmanager = eventmanager diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 48fe8fcdb..4413798db 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -132,9 +132,6 @@ class SongsPlugin(Plugin): Handle the event contained in the event object. """ log.debug(u'Handle event called with event %s' % event.event_type) - if event.event_type == EventType.ThemeListChanged: - log.debug(u'New Theme request received') - self.media_item.edit_song_form.loadThemes(event.payload) if event.event_type == EventType.LoadSongList : log.debug(u'Load Load Song List Item received') self.media_item.displayResultsSong(self.songmanager.get_songs()) From 49a424abd1006de0157d51b53d84d04717e69ee2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 25 Aug 2009 21:04:58 +0100 Subject: [PATCH 3/4] EventManager Removal part 3 - Theme handling --- openlp/core/lib/event.py | 15 +++++------ openlp/core/lib/eventreceiver.py | 5 +++- openlp/core/ui/mainwindow.py | 6 +++-- openlp/core/ui/thememanager.py | 25 ++++++++++++++----- openlp/core/ui/themestab.py | 3 +-- openlp/plugins/custom/forms/editcustomform.py | 2 +- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index a09e06abb..8661ad4cf 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -27,18 +27,19 @@ class EventType(object): """ # "Default" event - a non-event Default = 0 - TriggerAlert = 1 + #TriggerAlert = 1 # General application events - Ready = 10 + # Ready = 10 # Service events - LoadServiceItem = 20 + #LoadServiceItem = 20 # Preview events - PreviewShow = 30 - LiveShow = 31 + #PreviewShow = 30 + #LiveShow = 31 #Theme Related Events - ThemeListChanged = 40 + #ThemeListChanged = 40 #Plugin Related Events - LoadSongList = 50 + #LoadSongList = 50 + class Event(object): diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 2bb3b6776..5c038a4ff 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -18,6 +18,7 @@ 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 """ +import logging from PyQt4 import QtCore @@ -48,12 +49,14 @@ class EventReceiver(QtCore.QObject): Tell the components we have a new global theme """ - + global log + log = logging.getLogger(u'EventReceiver') def __init__(self): QtCore.QObject.__init__(self) def send_message(self, event, msg=None): + log.debug(u'Event %s passed with payload %s' % (event, msg)) print u'message ', event, msg self.emit(QtCore.SIGNAL(event), msg) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index dbdb70a96..7df147328 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -27,7 +27,7 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ PluginForm from openlp.core.lib import translate, Plugin, MediaManagerItem, \ SettingsTab, EventManager, RenderManager, PluginConfig, \ - SettingsManager, PluginManager, EventType + SettingsManager, PluginManager, EventType, Receiver class Ui_MainWindow(object): def setupUi(self, MainWindow): @@ -458,6 +458,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.OptionsSettingsItem, QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged) #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager @@ -593,5 +595,5 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): title = u'%s - %s*' % (self.mainTitle, service_name) self.setWindowTitle(title) - def DefaultThemeChanged(self, theme): + def defaultThemeChanged(self, theme): self.DefaultThemeLabel.setText(self.defaultThemeText + theme) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a6c420151..1ee7f8777 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -72,7 +72,9 @@ class ThemeManager(QtGui.QWidget): self.Layout.addWidget(self.ThemeListWidget) #Signals QtCore.QObject.connect(self.ThemeListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_global_theme'), self.changeGlobalFromTab) #Variables self.themelist = [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') @@ -86,7 +88,22 @@ class ThemeManager(QtGui.QWidget): def getDefault(self): return self.global_theme - def changeGlobal(self, index): + def changeGlobalFromTab(self, themeName): + log.debug(u'changeGlobalFromTab %s', themeName) + for count in range (0, self.ThemeListWidget.count()): + #reset the old name + item = self.ThemeListWidget.item(count) + oldName = item.text() + newName = unicode(item.data(QtCore.Qt.UserRole).toString()) + if oldName != newName: + self.ThemeListWidget.item(count).setText(newName) + #Set the new name + if themeName == newName: + name = u'%s (%s)' % (newName, translate(u'ThemeManager', u'default')) + self.ThemeListWidget.item(count).setText(name) + + def changeGlobalFromScreen(self, index): + log.debug(u'changeGlobalFromScreen %s', index) for count in range (0, self.ThemeListWidget.count()): item = self.ThemeListWidget.item(count) oldName = item.text() @@ -184,7 +201,6 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() def pushThemes(self): - #self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes())) Receiver().send_message(u'update_themes', self.getThemes() ) def getThemes(self): @@ -195,7 +211,6 @@ class ThemeManager(QtGui.QWidget): xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml') try: xml = file_to_xml(xml_file) - #print xml except: newtheme = ThemeXML() newtheme.new_document(u'New Theme') @@ -206,9 +221,7 @@ class ThemeManager(QtGui.QWidget): unicode(0), unicode(0), unicode(0)) xml = newtheme.extract_xml() theme = ThemeXML() - #print theme theme.parse(xml) - #print "A ", theme theme.extend_image_filename(self.path) return theme diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 489749e94..a1a1d68c0 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -88,14 +88,12 @@ class ThemesTab(SettingsTab): self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.GlobalLevelLabel) self.ThemesTabLayout.addWidget(self.LevelGroupBox) - QtCore.QObject.connect(self.SongLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed) QtCore.QObject.connect(self.ServiceLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed) QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed) - QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) QtCore.QObject.connect(Receiver.get_receiver(), @@ -124,6 +122,7 @@ class ThemesTab(SettingsTab): def save(self): self.config.set_config(u'theme global style', self.global_style ) self.config.set_config(u'theme global theme',self.global_theme) + Receiver().send_message(u'update_global_theme', self.global_theme ) def onSongLevelButtonPressed(self): self.global_style= u'Song' diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index fe9b24230..fa936f469 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -51,7 +51,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'update_themes'), self.loadThemest) + QtCore.SIGNAL(u'update_themes'), self.loadThemes) # Create other objects and forms self.custommanager = custommanager self.initialise() From 63f67ea7562613e88afeda7489d57a22e4d8dc56 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 26 Aug 2009 06:00:19 +0100 Subject: [PATCH 4/4] EventManager Removal - complete --- openlp/core/lib/__init__.py | 3 - openlp/core/lib/event.py | 52 ---------------- openlp/core/lib/eventmanager.py | 72 ---------------------- openlp/core/lib/eventreceiver.py | 3 +- openlp/core/lib/plugin.py | 60 +----------------- openlp/core/lib/pluginmanager.py | 8 +-- openlp/core/ui/amendthemeform.py | 2 - openlp/core/ui/maindisplay.py | 16 +---- openlp/core/ui/mainwindow.py | 11 +--- openlp/core/ui/thememanager.py | 5 +- openlp/plugins/bibles/bibleplugin.py | 2 +- openlp/plugins/custom/customplugin.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/remotes/remoteplugin.py | 4 +- openlp/plugins/songs/forms/editsongform.py | 9 ++- openlp/plugins/songs/lib/mediaitem.py | 8 ++- openlp/plugins/songs/songsplugin.py | 12 +--- 17 files changed, 30 insertions(+), 241 deletions(-) delete mode 100644 openlp/core/lib/event.py delete mode 100644 openlp/core/lib/eventmanager.py diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c940bd649..be1848fed 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -60,12 +60,9 @@ def contextMenuSeparator(base): from settingsmanager import SettingsManager from pluginconfig import PluginConfig from plugin import Plugin -from eventmanager import EventManager from pluginmanager import PluginManager from settingstab import SettingsTab from mediamanageritem import MediaManagerItem -from event import Event -from event import EventType from xmlrootclass import XmlRootClass from serviceitem import ServiceItem from eventreceiver import Receiver diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py deleted file mode 100644 index 8661ad4cf..000000000 --- a/openlp/core/lib/event.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 -""" -OpenLP - Open Source Lyrics Projection - -Copyright (c) 2008 Raoul Snyman - -Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri, -Carsten Tingaard, Jonathan Corwin - -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 -""" - -class EventType(object): - """ - Types of events are stored in this class. - """ - # "Default" event - a non-event - Default = 0 - #TriggerAlert = 1 - # General application events - # Ready = 10 - # Service events - #LoadServiceItem = 20 - # Preview events - #PreviewShow = 30 - #LiveShow = 31 - #Theme Related Events - #ThemeListChanged = 40 - #Plugin Related Events - #LoadSongList = 50 - - - -class Event(object): - """ - Provides an Event class to encapsulate events within openlp.org. - """ - def __init__(self, sender, event_type=EventType.Default, payload=None): - self.event_type = event_type - self.payload = payload - self.sender = sender diff --git a/openlp/core/lib/eventmanager.py b/openlp/core/lib/eventmanager.py deleted file mode 100644 index 15edf02d8..000000000 --- a/openlp/core/lib/eventmanager.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 -""" -OpenLP - Open Source Lyrics Projection - -Copyright (c) 2008 Raoul Snyman - -Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri, -Carsten Tingaard, Jonathan Corwin - -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 -""" -import os -import logging - -class EventManager(object): - """ - A mechanism to send events to all registered endpoints. The - endpoints are registered and listen with a handle_event method. - The endpoint will decide whether to do somthing with the event or - ignore it. - """ - global log - log = logging.getLogger(u'EventManager') - - def __init__(self): - """ - Defines the class and a list of endpoints - """ - self.endpoints = [] - log.info(u'Initialising') - self.processing = False - self.events = [] - - def register(self, plugin): - """ - Called by plugings who wish to receive event notifications - """ - log.debug(u'Class %s registered with EventManager', plugin) - self.endpoints.append(plugin) - - def post_event(self, event): - """ - Called by any part of the system which wants send events to the plugins - - ``event`` - The event type to be triggered - - """ - log.debug(u'post event called for event %s (%s)', event.event_type, event.sender) - self.events.append(event) - if not self.processing: - self.processing = True - while len(self.events) > 0: - pEvent = self.events[0] - for point in self.endpoints: - status = point.handle_event(pEvent) - #if call returns true message is finished with - if status is not None and status : - break - self.events.remove(pEvent) - self.processing = False diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 5c038a4ff..7d7a4c2fe 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -47,6 +47,8 @@ class EventReceiver(QtCore.QObject): send out message with new themes ``update_global_theme `` Tell the components we have a new global theme + ``load_song_list`` + Tells the the song plugin to reload the song list """ global log @@ -57,7 +59,6 @@ class EventReceiver(QtCore.QObject): def send_message(self, event, msg=None): log.debug(u'Event %s passed with payload %s' % (event, msg)) - print u'message ', event, msg self.emit(QtCore.SIGNAL(event), msg) class Receiver(): diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 11e6092b0..5f009c014 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -25,7 +25,6 @@ from openlp.core.lib import PluginConfig # why does this not work??? # from openlp.core.lib import Event, EventType # so I have to do this??? -from event import Event, EventType from eventreceiver import Receiver class Plugin(object): @@ -124,7 +123,6 @@ class Plugin(object): self.log = logging.getLogger(self.name) self.preview_controller = plugin_helpers[u'preview'] self.live_controller = plugin_helpers[u'live'] - self.event_manager = plugin_helpers[u'event'] self.render_manager = plugin_helpers[u'render'] self.service_manager = plugin_helpers[u'service'] self.settings = plugin_helpers[u'settings'] @@ -185,32 +183,8 @@ class Plugin(object): Proxy method as method is not defined early enough in the processing """ - log.debug(u'Handle event called with plugin %s' % self.name) + log.debug(u'process_add_service_event event called for plugin %s' % self.name) self.media_item.onAddClick() - def handle_event(self, event): -# """ -# Handle the event contained in the event object. If you want -# to use this default behaviour, you must set self.dnd_id equal -# to that sent by the dnd source - eg the MediaItem -# -# ``event`` -# An object describing the event. -# """ -# # default behaviour - can be overridden if desired - pass -# log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) -# if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id: -# log.debug(u'Load Service Item received') -# self.media_item.onAddClick() -# return True -# if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id: -# log.debug(u'Load Preview Item received') -# self.media_item.onPreviewClick() -# return True -# if event.event_type == EventType.LiveShow and event.payload == self.dnd_id: -# log.debug(u'Load Live Show Item received') -# return True -# self.media_item.onLiveClick() def about(self): """ @@ -219,38 +193,6 @@ class Plugin(object): """ pass -# def save(self, data): -# """ -# Service item data is passed to this function, which should return a -# string which can be written to the service file. -# -# ``data`` -# The data to be saved. -# """ -# pass -# -# def load(self, string): -# """ -# A string from the service file is passed in. This function parses and -# sets up the internals of the plugin. -# -# ``string`` -# The data to be loaded into the plugin. -# """ -# pass -# -# def render(self, theme, screen=None): -# """ -# Render the screenth screenful of data using theme settings in theme. -# -# ``theme`` -# The theme to use when rendering. -# -# ``screen`` -# Defaults to *None*. The screen to render to. -# """ -# pass - def initialise(self): """ Called by the plugin Manager to initialise anything it needs. diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 8e1b519ea..484d74f97 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -21,7 +21,7 @@ import os import sys import logging -from openlp.core.lib import Plugin, EventManager +from openlp.core.lib import Plugin class PluginManager(object): """ @@ -50,7 +50,7 @@ class PluginManager(object): # this has to happen after the UI is sorted self.find_plugins(dir) log.info(u'Plugin manager done init') - def find_plugins(self, dir, plugin_helpers, eventmanager): + def find_plugins(self, dir, plugin_helpers): """ Scan the directory dir for objects inheriting from ``openlp.plugin``. @@ -60,8 +60,6 @@ class PluginManager(object): ``plugin_helpers`` A list of helper objects to pass to the plugins. - ``eventmanager`` - The event manager to pass to the plugins. """ self.plugin_helpers = plugin_helpers startdepth = len(os.path.abspath(dir).split(os.sep)) @@ -103,11 +101,9 @@ class PluginManager(object): pList = {u'plugin': plugin, u'status': u'Inactive'} if plugin.check_pre_conditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) - eventmanager.register(plugin) pList[u'status'] = u'Active' self.plugins.append(pList) - def order_by_weight(self, x, y): """ Sort two plugins and order them by their weight. diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index ef6f8368f..3b76e1c89 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -32,11 +32,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def __init__(self, thememanager, parent=None): QtGui.QDialog.__init__(self, parent) self.thememanager = thememanager - # Needed here as UI setup generates Events self.path = None self.theme = ThemeXML() self.setupUi(self) - #define signals #Buttons QtCore.QObject.connect(self.Color1PushButton , diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index bf5cfaa77..56db736ae 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -21,7 +21,7 @@ import logging from PyQt4 import QtCore, QtGui from time import sleep -from openlp.core.lib import translate, EventManager, Event, EventType, Receiver +from openlp.core.lib import translate, Receiver class MainDisplay(QtGui.QWidget): """ @@ -58,20 +58,10 @@ class MainDisplay(QtGui.QWidget): self.alertactive = False self.alertTab = None self.timer_id = 0 - # Register the main form as an event consumer. - self.parent.EventManager.register(self) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_slide_blank'), self.blankDisplay) - - def handle_event(self, event): - """ - Accept Events for the system and If It's for Alert - action it and Return true to stop futher processing - """ - log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload)) - if event.event_type == EventType.TriggerAlert: - self.displayAlert(event.payload) - return True + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'alert_text'), self.displayAlert) def setup(self, screenNumber): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 7df147328..bf8d232e4 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -26,8 +26,8 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ ServiceManager, ThemeManager, MainDisplay, SlideController, \ PluginForm from openlp.core.lib import translate, Plugin, MediaManagerItem, \ - SettingsTab, EventManager, RenderManager, PluginConfig, \ - SettingsManager, PluginManager, EventType, Receiver + SettingsTab, RenderManager, PluginConfig, \ + SettingsManager, PluginManager, Receiver class Ui_MainWindow(object): def setupUi(self, MainWindow): @@ -416,7 +416,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.screenList = screens self.oosNotSaved = False self.settingsmanager = SettingsManager(screens) - self.EventManager = EventManager() self.mainDisplay = MainDisplay(self, screens) self.generalConfig = PluginConfig(u'General') self.alertForm = AlertForm(self) @@ -469,12 +468,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #make the controllers available to the plugins self.plugin_helpers[u'preview'] = self.PreviewController self.plugin_helpers[u'live'] = self.LiveController - self.plugin_helpers[u'event'] = self.EventManager self.plugin_helpers[u'render'] = self.RenderManager self.plugin_helpers[u'service'] = self.ServiceManagerContents self.plugin_helpers[u'settings'] = self.settingsForm - self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, - self.EventManager) + self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) # hook methods have to happen after find_plugins. Find plugins needs the # controllers hence the hooks have moved from setupUI() to here @@ -492,8 +489,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Call the initialise method to setup plugins. log.info(u'initialise plugins') self.plugin_manager.initialise_plugins() - # Register the main form as an event consumer. - self.EventManager.register(self) # Once all components are initialised load the Themes log.info(u'Load Themes') self.ThemeManagerContents.loadThemes() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1ee7f8777..a1e346fbc 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -28,8 +28,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm, ServiceManager from openlp.core.theme import Theme -from openlp.core.lib import PluginConfig, Event, EventType, \ - EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \ +from openlp.core.lib import PluginConfig, \ + OpenLPToolbar, ThemeXML, Renderer, translate, \ file_to_xml, buildIcon, Receiver from openlp.core.utils import ConfigHelper @@ -116,6 +116,7 @@ class ThemeManager(QtGui.QWidget): name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default')) self.ThemeListWidget.item(count).setText(name) self.config.set_config(u'theme global theme', self.global_theme) + Receiver().send_message(u'update_global_theme', self.global_theme ) self.pushThemes() def onAddTheme(self): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index b3ba5c94b..84c6c3c31 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -22,7 +22,7 @@ import logging from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * -from openlp.core.lib import Plugin, Event, EventType, translate +from openlp.core.lib import Plugin, translate from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 368bcbf07..fd1cb43e1 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -22,7 +22,7 @@ import logging from PyQt4 import QtCore, QtGui from forms import EditCustomForm -from openlp.core.lib import Plugin, Event, EventType +from openlp.core.lib import Plugin from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 48471f826..0995413ad 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -21,7 +21,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Event, EventType +from openlp.core.lib import Plugin from openlp.plugins.images.lib import ImageMediaItem, ImageTab class ImagePlugin(Plugin): diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 601deec66..bf6d1bf43 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -22,7 +22,7 @@ import sys from PyQt4 import QtNetwork, QtGui, QtCore -from openlp.core.lib import Plugin, Event, EventType, Receiver +from openlp.core.lib import Plugin, Receiver from openlp.plugins.remotes.lib import RemoteTab class RemotesPlugin(Plugin): @@ -58,7 +58,7 @@ class RemotesPlugin(Plugin): event = unicode(datagram[:pos].lower()) if event == u'alert': - self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:]))) + Receiver().send_message(u'alert_text', unicode(datagram[pos + 1:])) if event == u'next_slide': Receiver().send_message(u'live_slide_next') diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 52f91b1e1..cafad139c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -22,8 +22,8 @@ import logging from PyQt4 import Qt, QtCore, QtGui -from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \ - EventType, EventManager, translate, Receiver +from openlp.core.lib import SongXMLBuilder, SongXMLParser, \ + translate, Receiver from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib.models import Song from editsongdialog import Ui_EditSongDialog @@ -36,7 +36,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): log = logging.getLogger(u'EditSongForm') log.info(u'Song Editor loaded') - def __init__(self, songmanager, eventmanager, parent=None): + def __init__(self, songmanager, parent=None): """ Constructor """ @@ -75,7 +75,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.SIGNAL(u'update_themes'), self.loadThemes) # Create other objects and forms self.songmanager = songmanager - self.eventmanager = eventmanager self.parent = parent self.verse_form = EditVerseForm() self.initialise() @@ -366,7 +365,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.processTitle() self.songmanager.save_song(self.song) if self.title_change: - self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList)) + Receiver().send_message(u'load_song_list') self.close() def processLyrics(self): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 6e19b3961..e28a4ffac 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -22,7 +22,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \ - SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD + SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD, \ + Receiver from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm class SongListView(BaseListWithDnD): @@ -43,7 +44,7 @@ class SongMediaItem(MediaManagerItem): self.PluginTextShort = u'Song' self.ConfigSection = u'song' MediaManagerItem.__init__(self, parent, icon, title) - self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager, self) + self.edit_song_form = EditSongForm(self.parent.songmanager, self) self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self) def setupUi(self): @@ -127,6 +128,9 @@ class SongMediaItem(MediaManagerItem): QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged) QtCore.QObject.connect(self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick) + #define and add the context menu self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.addAction(contextMenuAction(self.ListView, diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 4413798db..598e32d06 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -22,7 +22,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Event, EventType, translate +from openlp.core.lib import Plugin, translate from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \ OpenSongImportForm, OpenLPExportForm @@ -126,13 +126,3 @@ class SongsPlugin(Plugin): def onExportOpenSongItemClicked(self): self.opensong_export_form.show() - - def handle_event(self, event): - """ - Handle the event contained in the event object. - """ - log.debug(u'Handle event called with event %s' % event.event_type) - if event.event_type == EventType.LoadSongList : - log.debug(u'Load Load Song List Item received') - self.media_item.displayResultsSong(self.songmanager.get_songs()) - return Plugin.handle_event(self, event)