From 7f3c18f0a04e2c55b8b8f87f215034b7ecbe5464 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Feb 2013 16:20:29 +0100 Subject: [PATCH 1/4] fixed regression --- openlp/plugins/alerts/lib/alertsmanager.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index ab0f7c1d9..42a28eee1 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -35,7 +35,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, Registry log = logging.getLogger(__name__) @@ -87,7 +87,7 @@ class AlertsManager(QtCore.QObject): return text = self.alertList.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 +103,18 @@ 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() + + + 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) From 6efe1bf602b7b8c1cbc8685adbf8907bbc79c29e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Feb 2013 08:49:01 +0100 Subject: [PATCH 2/4] image and remote plugin regression --- openlp/plugins/images/imageplugin.py | 14 ++++++- openlp/plugins/remotes/lib/httpserver.py | 53 ++++++++++++++++++------ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 0f2829dbc..83c424e86 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui import logging -from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, build_icon, translate +from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, Registry, build_icon, translate from openlp.plugins.images.lib import ImageMediaItem, ImageTab log = logging.getLogger(__name__) @@ -98,4 +98,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) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index d444fc1c4..127c2c13b 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -123,7 +123,7 @@ 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 Receiver, Settings, PluginStatus, StringContent, Registry from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -252,12 +252,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 +387,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'}) @@ -414,7 +413,7 @@ 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'] @@ -506,7 +505,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 +524,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 +540,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 +553,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 +584,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) From ffe6bdb6b0cd735069a934105d300efbf980fdeb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Feb 2013 08:49:59 +0100 Subject: [PATCH 3/4] removed blank line --- openlp/plugins/alerts/lib/alertsmanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 42a28eee1..40910c67c 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -108,7 +108,6 @@ class AlertsManager(QtCore.QObject): self.timer_id = 0 self.generateAlert() - def _get_live_controller(self): """ Adds the live controller to the class dynamically From 60eed1018f72da3d37c5181a2acdfe53784a4a14 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 16 Feb 2013 10:24:06 +0100 Subject: [PATCH 4/4] fixed merge errors --- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/alerts/lib/alertsmanager.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index c09180702..aba13ddb9 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -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): diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index b4516cdd5..6db4f2d70 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -108,7 +108,7 @@ class AlertsManager(QtCore.QObject): 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): """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 6b7705e48..61cc29e01 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui import logging