More Registry cleanups and bug fixes

This commit is contained in:
Tim Bentley 2013-01-26 07:39:07 +00:00
parent 96afb2a737
commit 183c0c700d
5 changed files with 54 additions and 16 deletions

View File

@ -536,7 +536,7 @@ class MediaManagerItem(QtGui.QWidget):
translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) translate('OpenLP.MediaManagerItem', 'You must select one or more items.'))
else: else:
log.debug(u'%s Add requested', self.plugin.name) log.debug(u'%s Add requested', self.plugin.name)
serviceItem = self.plugin.serviceManager.getServiceItem() serviceItem = self.service_manager.getServiceItem()
if not serviceItem: if not serviceItem:
QtGui.QMessageBox.information(self, UiStrings().NISs, QtGui.QMessageBox.information(self, UiStrings().NISs,
translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) 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): 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'): if not hasattr(self, u'_service_manager'):
self._service_manager = Registry().get(u'service_manager') self._service_manager = Registry().get(u'service_manager')
return self._service_manager return self._service_manager
service_manager = property(_get_service_manager) service_manager = property(_get_service_manager)

View File

@ -33,7 +33,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from lxml import html 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.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
from openlp.core.utils import AppLocation 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): class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
def __init__(self, mainWindow, serviceManager): def __init__(self):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, mainWindow) QtGui.QDialog.__init__(self, self.main_window)
self.mainWindow = mainWindow
self.serviceManager = serviceManager
self.printer = QtGui.QPrinter() self.printer = QtGui.QPrinter()
self.printDialog = QtGui.QPrintDialog(self.printer, self) self.printDialog = QtGui.QPrintDialog(self.printer, self)
self.document = QtGui.QTextDocument() self.document = QtGui.QTextDocument()
@ -170,7 +168,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
self._addElement(u'body', parent=html_data) self._addElement(u'body', parent=html_data)
self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()), self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()),
html_data.body, classId=u'serviceTitle') 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) self._addPreviewItem(html_data.body, item[u'service_item'], index)
# Add the custom service notes: # Add the custom service notes:
if self.footerTextEdit.toPlainText(): if self.footerTextEdit.toPlainText():
@ -319,14 +317,14 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
# remove the icon from the text # remove the icon from the text
clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'') clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'')
# and put it all on the clipboard # and put it all on the clipboard
self.mainWindow.clipboard.setText(clipboard_text) self.main_window.clipboard.setText(clipboard_text)
def copyHtmlText(self): def copyHtmlText(self):
""" """
Copies the display text to the clipboard as Html Copies the display text to the clipboard as Html
""" """
self.update_song_usage() self.update_song_usage()
self.mainWindow.clipboard.setText(self.document.toHtml()) self.main_window.clipboard.setText(self.document.toHtml())
def printServiceOrder(self): def printServiceOrder(self):
""" """
@ -392,6 +390,26 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
# Only continue when we include the song's text. # Only continue when we include the song's text.
if not self.slideTextCheckBox.isChecked(): if not self.slideTextCheckBox.isChecked():
return return
for item in self.serviceManager.serviceItems: for item in self.service_manager.serviceItems:
# Trigger Audit requests # Trigger Audit requests
Receiver.send_message(u'print_service_started', [item[u'service_item']]) 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)

View File

@ -1545,7 +1545,7 @@ class ServiceManager(QtGui.QWidget):
""" """
Print a Service Order Sheet. Print a Service Order Sheet.
""" """
settingDialog = PrintServiceForm(self.main_window, self) settingDialog = PrintServiceForm()
settingDialog.exec_() settingDialog.exec_()
def _get_renderer(self): def _get_renderer(self):

View File

@ -1190,7 +1190,7 @@ class SlideController(DisplayController):
From the preview display request the Item to be added to service From the preview display request the Item to be added to service
""" """
if self.serviceItem: if self.serviceItem:
self.parent().serviceManagerContents.addServiceItem(self.serviceItem) self.service_manager.addServiceItem(self.serviceItem)
def onGoLiveClick(self): def onGoLiveClick(self):
""" """
@ -1215,7 +1215,7 @@ class SlideController(DisplayController):
Receiver.send_message('servicemanager_preview_live', u'%s:%s' % Receiver.send_message('servicemanager_preview_live', u'%s:%s' %
(self.serviceItem.unique_identifier, row)) (self.serviceItem.unique_identifier, row))
else: else:
self.parent().liveController.addServiceManagerItem(self.serviceItem, row) self.live_controller.addServiceManagerItem(self.serviceItem, row)
def onMediaStart(self, item): def onMediaStart(self, item):
""" """
@ -1309,3 +1309,22 @@ class SlideController(DisplayController):
media_controller = property(_get_media_controller) 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)

View File

@ -85,7 +85,7 @@ class PresentationMediaItem(MediaManagerItem):
for type in types: for type in types:
if fileType.find(type) == -1: if fileType.find(type) == -1:
fileType += u'*.%s ' % type fileType += u'*.%s ' % type
self.plugin.serviceManager.supportedSuffixes(type) self.service_manager.supportedSuffixes(type)
self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType
def requiredIcons(self): def requiredIcons(self):