From 183c0c700dffed498d530c6d2b807277e7ff1caf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 26 Jan 2013 07:39:07 +0000 Subject: [PATCH] More Registry cleanups and bug fixes --- openlp/core/lib/mediamanageritem.py | 7 ++-- openlp/core/ui/printserviceform.py | 36 ++++++++++++++----- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/slidecontroller.py | 23 ++++++++++-- openlp/plugins/presentations/lib/mediaitem.py | 2 +- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 100f248c0..bcfb01259 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -536,7 +536,7 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: log.debug(u'%s Add requested', self.plugin.name) - serviceItem = self.plugin.serviceManager.getServiceItem() + serviceItem = self.service_manager.getServiceItem() if not serviceItem: QtGui.QMessageBox.information(self, UiStrings().NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) @@ -681,10 +681,11 @@ class MediaManagerItem(QtGui.QWidget): def _get_service_manager(self): """ - Adds the plugin manager to the class dynamically + 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) \ No newline at end of file + service_manager = property(_get_service_manager) + diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 0cdba6c9b..02ad00ad0 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -33,7 +33,7 @@ import os from PyQt4 import QtCore, QtGui from lxml import html -from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings +from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings, Registry from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.utils import AppLocation @@ -108,13 +108,11 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): - def __init__(self, mainWindow, serviceManager): + def __init__(self): """ Constructor """ - QtGui.QDialog.__init__(self, mainWindow) - self.mainWindow = mainWindow - self.serviceManager = serviceManager + QtGui.QDialog.__init__(self, self.main_window) self.printer = QtGui.QPrinter() self.printDialog = QtGui.QPrintDialog(self.printer, self) self.document = QtGui.QTextDocument() @@ -170,7 +168,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._addElement(u'body', parent=html_data) self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()), html_data.body, classId=u'serviceTitle') - for index, item in enumerate(self.serviceManager.serviceItems): + for index, item in enumerate(self.service_manager.serviceItems): self._addPreviewItem(html_data.body, item[u'service_item'], index) # Add the custom service notes: if self.footerTextEdit.toPlainText(): @@ -319,14 +317,14 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): # remove the icon from the text clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'') # and put it all on the clipboard - self.mainWindow.clipboard.setText(clipboard_text) + self.main_window.clipboard.setText(clipboard_text) def copyHtmlText(self): """ Copies the display text to the clipboard as Html """ self.update_song_usage() - self.mainWindow.clipboard.setText(self.document.toHtml()) + self.main_window.clipboard.setText(self.document.toHtml()) def printServiceOrder(self): """ @@ -392,6 +390,26 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): # Only continue when we include the song's text. if not self.slideTextCheckBox.isChecked(): return - for item in self.serviceManager.serviceItems: + for item in self.service_manager.serviceItems: # Trigger Audit requests Receiver.send_message(u'print_service_started', [item[u'service_item']]) + + 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_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7ba5e715b..dd1266190 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1545,7 +1545,7 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - settingDialog = PrintServiceForm(self.main_window, self) + settingDialog = PrintServiceForm() settingDialog.exec_() def _get_renderer(self): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 05151b20e..0bc828533 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1190,7 +1190,7 @@ class SlideController(DisplayController): From the preview display request the Item to be added to service """ if self.serviceItem: - self.parent().serviceManagerContents.addServiceItem(self.serviceItem) + self.service_manager.addServiceItem(self.serviceItem) def onGoLiveClick(self): """ @@ -1215,7 +1215,7 @@ class SlideController(DisplayController): Receiver.send_message('servicemanager_preview_live', u'%s:%s' % (self.serviceItem.unique_identifier, row)) else: - self.parent().liveController.addServiceManagerItem(self.serviceItem, row) + self.live_controller.addServiceManagerItem(self.serviceItem, row) def onMediaStart(self, item): """ @@ -1309,3 +1309,22 @@ class SlideController(DisplayController): media_controller = property(_get_media_controller) + 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) \ No newline at end of file diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index fe533a791..c7c98d5a4 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -85,7 +85,7 @@ class PresentationMediaItem(MediaManagerItem): for type in types: if fileType.find(type) == -1: fileType += u'*.%s ' % type - self.plugin.serviceManager.supportedSuffixes(type) + self.service_manager.supportedSuffixes(type) self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType def requiredIcons(self):