More cleanups and removal of plugin_helpers

This commit is contained in:
Tim Bentley 2013-01-23 19:28:47 +00:00
parent 9067b16e0e
commit 3378e32da3
20 changed files with 197 additions and 78 deletions

View File

@ -36,7 +36,7 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, \ from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, \
Receiver, ListWidgetWithDnD, ServiceItemContext, Settings Receiver, ListWidgetWithDnD, ServiceItemContext, Settings, Registry
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, create_widget_action, critical_error_message_box from openlp.core.lib.ui import UiStrings, create_widget_action, critical_error_message_box
@ -98,6 +98,7 @@ class MediaManagerItem(QtGui.QWidget):
self.plugin = plugin self.plugin = plugin
visible_title = self.plugin.getString(StringContent.VisibleName) visible_title = self.plugin.getString(StringContent.VisibleName)
self.title = unicode(visible_title[u'title']) self.title = unicode(visible_title[u'title'])
Registry().register(self.title, self)
self.settingsSection = self.plugin.name self.settingsSection = self.plugin.name
self.icon = None self.icon = None
if icon: if icon:
@ -618,3 +619,73 @@ class MediaManagerItem(QtGui.QWidget):
Performs a plugin specific search for items containing ``string`` Performs a plugin specific search for items containing ``string``
""" """
raise NotImplementedError(u'Plugin.search needs to be defined by the plugin') raise NotImplementedError(u'Plugin.search needs to be defined by the plugin')
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)
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, u'_renderer'):
self._renderer = Registry().get(u'renderer')
return self._renderer
renderer = property(_get_renderer)
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_preview_controller(self):
"""
Adds the preview controller to the class dynamically
"""
if not hasattr(self, u'_preview_controller'):
self._preview_controller = Registry().get(u'preview_controller')
return self._preview_controller
preview_controller = property(_get_preview_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)
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, u'_media_controller'):
self._media_controller = Registry().get(u'media_controller')
return self._media_controller
media_controller = property(_get_media_controller)
def _get_service_manager(self):
"""
Adds the plugin 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)

View File

@ -33,7 +33,7 @@ import logging
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.lib import Receiver, Settings from openlp.core.lib import Receiver, Settings, Registry
from openlp.core.lib.ui import UiStrings from openlp.core.lib.ui import UiStrings
from openlp.core.utils import get_application_version from openlp.core.utils import get_application_version
@ -168,10 +168,7 @@ class Plugin(QtCore.QObject):
self.renderer = plugin_helpers[u'renderer'] self.renderer = plugin_helpers[u'renderer']
self.serviceManager = plugin_helpers[u'service'] self.serviceManager = plugin_helpers[u'service']
self.settingsForm = plugin_helpers[u'settings form'] self.settingsForm = plugin_helpers[u'settings form']
self.mediaDock = plugin_helpers[u'toolbox']
self.pluginManager = plugin_helpers[u'pluginmanager'] self.pluginManager = plugin_helpers[u'pluginmanager']
self.formParent = plugin_helpers[u'formparent']
self.mediaController = plugin_helpers[u'mediacontroller']
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent) self.processAddServiceEvent)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name),
@ -217,7 +214,7 @@ class Plugin(QtCore.QObject):
you need, and return it for integration into OpenLP. you need, and return it for integration into OpenLP.
""" """
if self.mediaItemClass: if self.mediaItemClass:
self.mediaItem = self.mediaItemClass(self.mediaDock.media_dock, self, self.icon) self.mediaItem = self.mediaItemClass(self.main_window.mediaDockManager.media_dock, self, self.icon)
def addImportMenuItem(self, importMenu): def addImportMenuItem(self, importMenu):
""" """
@ -287,14 +284,14 @@ class Plugin(QtCore.QObject):
""" """
if self.mediaItem: if self.mediaItem:
self.mediaItem.initialise() self.mediaItem.initialise()
self.mediaDock.insert_dock(self.mediaItem, self.icon, self.weight) self.main_window.mediaDockManager.insert_dock(self.mediaItem, self.icon, self.weight)
def finalise(self): def finalise(self):
""" """
Called by the plugin Manager to cleanup things. Called by the plugin Manager to cleanup things.
""" """
if self.mediaItem: if self.mediaItem:
self.mediaDock.remove_dock(self.mediaItem) self.main_window.mediaDockManager.remove_dock(self.mediaItem)
def appStartup(self): def appStartup(self):
""" """
@ -389,3 +386,13 @@ class Plugin(QtCore.QObject):
The plugin's config has changed The plugin's config has changed
""" """
pass pass
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

@ -47,12 +47,14 @@ class Registry(object):
return cls.__instance__ return cls.__instance__
@classmethod @classmethod
def create(self): def create(cls):
""" """
The constructor for the component registry providing a single registry of objects. The constructor for the component registry providing a single registry of objects.
""" """
log.info(u'Registry Initialising') log.info(u'Registry Initialising')
self.service_list = {} registry = cls()
registry.service_list = {}
return registry
def get(self, key): def get(self, key):
""" """

View File

@ -40,7 +40,7 @@ from datetime import datetime
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, PluginManager, Receiver, translate, ImageManager, \ from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, PluginManager, Receiver, translate, ImageManager, \
PluginStatus PluginStatus, Registry
from openlp.core.lib.ui import UiStrings, create_action from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.lib import SlideLimits, Settings from openlp.core.lib import SlideLimits, Settings
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
@ -456,6 +456,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
plugins. plugins.
""" """
QtGui.QMainWindow.__init__(self) QtGui.QMainWindow.__init__(self)
Registry().register(u'main_window', self)
self.application = application self.application = application
self.clipboard = self.application.clipboard() self.clipboard = self.application.clipboard()
self.arguments = self.application.args self.arguments = self.application.args

View File

@ -32,7 +32,7 @@ import os
import datetime import datetime
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, Receiver, translate, Settings from openlp.core.lib import OpenLPToolbar, Receiver, translate, Settings, Registry
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
from openlp.core.ui.media.mediaplayer import MediaPlayer from openlp.core.ui.media.mediaplayer import MediaPlayer
@ -88,6 +88,7 @@ class MediaController(object):
""" """
def __init__(self, parent): def __init__(self, parent):
self.mainWindow = parent self.mainWindow = parent
Registry().register(u'media_controller', self)
self.mediaPlayers = {} self.mediaPlayers = {}
self.displayControllers = {} self.displayControllers = {}
self.currentMediaPlayer = {} self.currentMediaPlayer = {}
@ -130,14 +131,14 @@ class MediaController(object):
for item in player.audio_extensions_list: for item in player.audio_extensions_list:
if not item in self.audio_extensions_list: if not item in self.audio_extensions_list:
self.audio_extensions_list.append(item) self.audio_extensions_list.append(item)
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:]) self.service_manager.supportedSuffixes(item[2:])
self.video_extensions_list = [] self.video_extensions_list = []
for player in self.mediaPlayers.values(): for player in self.mediaPlayers.values():
if player.isActive: if player.isActive:
for item in player.video_extensions_list: for item in player.video_extensions_list:
if item not in self.video_extensions_list: if item not in self.video_extensions_list:
self.video_extensions_list.extend(item) self.video_extensions_list.extend(item)
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:]) self.service_manager.supportedSuffixes(item[2:])
def register_players(self, player): def register_players(self, player):
""" """
@ -729,3 +730,13 @@ class MediaController(object):
if controller.isLive: if controller.isLive:
return controller.display return controller.display
return controller.previewDisplay return controller.previewDisplay
def _get_service_manager(self):
"""
Adds the plugin 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)

View File

@ -105,6 +105,7 @@ class ServiceManager(QtGui.QWidget):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png')) self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png')) self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
Registry().register(u'service_manager', self)
self.mainwindow = mainwindow self.mainwindow = mainwindow
self.serviceItems = [] self.serviceItems = []
self.suffixes = [] self.suffixes = []

View File

@ -82,8 +82,6 @@ class SlideController(DisplayController):
self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height()) self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height())
except ZeroDivisionError: except ZeroDivisionError:
self.ratio = 1 self.ratio = 1
self.imageManager = self.parent().imageManager
self.mediaController = self.parent().mediaController
self.loopList = [ self.loopList = [
u'playSlidesMenu', u'playSlidesMenu',
u'loopSeparator', u'loopSeparator',
@ -232,7 +230,7 @@ class SlideController(DisplayController):
tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong) tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong)
self.controllerLayout.addWidget(self.toolbar) self.controllerLayout.addWidget(self.toolbar)
# Build the Media Toolbar # Build the Media Toolbar
self.mediaController.register_controller(self) self.media_controller.register_controller(self)
if self.isLive: if self.isLive:
# Build the Song Toolbar # Build the Song Toolbar
self.songMenu = QtGui.QToolButton(self.toolbar) self.songMenu = QtGui.QToolButton(self.toolbar)
@ -355,8 +353,7 @@ class SlideController(DisplayController):
self.setLiveHotkeys(self) self.setLiveHotkeys(self)
self.__addActionsToWidget(self.previewListWidget) self.__addActionsToWidget(self.previewListWidget)
else: else:
self.previewListWidget.addActions( self.previewListWidget.addActions([self.nextItem, self.previousItem])
[self.nextItem, self.previousItem])
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop) QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -451,7 +448,7 @@ class SlideController(DisplayController):
def liveEscape(self): def liveEscape(self):
self.display.setVisible(False) self.display.setVisible(False)
self.mediaController.media_stop(self) self.media_controller.media_stop(self)
def toggleDisplay(self, action): def toggleDisplay(self, action):
""" """
@ -518,13 +515,13 @@ class SlideController(DisplayController):
self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height()) self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height())
except ZeroDivisionError: except ZeroDivisionError:
self.ratio = 1 self.ratio = 1
self.mediaController.setup_display(self.display, False) self.media_controller.setup_display(self.display, False)
self.previewSizeChanged() self.previewSizeChanged()
self.previewDisplay.setup() self.previewDisplay.setup()
serviceItem = ServiceItem() serviceItem = ServiceItem()
self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive, self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive,
plugins=self.plugin_manager.plugins)) plugins=self.plugin_manager.plugins))
self.mediaController.setup_display(self.previewDisplay,True) self.media_controller.setup_display(self.previewDisplay,True)
if self.serviceItem: if self.serviceItem:
self.refreshServiceItem() self.refreshServiceItem()
@ -774,9 +771,9 @@ class SlideController(DisplayController):
else: else:
# If current slide set background to image # If current slide set background to image
if framenumber == slideno: if framenumber == slideno:
self.serviceItem.bg_image_bytes = self.imageManager.getImageBytes(frame[u'path'], self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes(frame[u'path'],
ImageSource.ImagePlugin) ImageSource.ImagePlugin)
image = self.imageManager.getImage(frame[u'path'], ImageSource.ImagePlugin) image = self.image_manager.getImage(frame[u'path'], ImageSource.ImagePlugin)
label.setPixmap(QtGui.QPixmap.fromImage(image)) label.setPixmap(QtGui.QPixmap.fromImage(image))
self.previewListWidget.setCellWidget(framenumber, 0, label) self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * (1 / self.ratio) slideHeight = width * (1 / self.ratio)
@ -1225,7 +1222,7 @@ class SlideController(DisplayController):
Respond to the arrival of a media service item Respond to the arrival of a media service item
""" """
log.debug(u'SlideController onMediaStart') log.debug(u'SlideController onMediaStart')
self.mediaController.video(self.controllerType, item, self.hideMode()) self.media_controller.video(self.controllerType, item, self.hideMode())
if not self.isLive: if not self.isLive:
self.previewDisplay.show() self.previewDisplay.show()
self.slidePreview.hide() self.slidePreview.hide()
@ -1235,7 +1232,7 @@ class SlideController(DisplayController):
Respond to a request to close the Video Respond to a request to close the Video
""" """
log.debug(u'SlideController onMediaClose') log.debug(u'SlideController onMediaClose')
self.mediaController.media_reset(self) self.media_controller.media_reset(self)
self.previewDisplay.hide() self.previewDisplay.hide()
self.slidePreview.show() self.slidePreview.show()
@ -1290,4 +1287,25 @@ class SlideController(DisplayController):
self._plugin_manager = Registry().get(u'plugin_manager') self._plugin_manager = Registry().get(u'plugin_manager')
return self._plugin_manager return self._plugin_manager
plugin_manager = property(_get_plugin_manager) plugin_manager = property(_get_plugin_manager)
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)
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, u'_media_controller'):
self._media_controller = Registry().get(u'media_controller')
return self._media_controller
media_controller = property(_get_media_controller)

View File

@ -45,7 +45,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.manager = plugin.manager self.manager = plugin.manager
self.plugin = plugin self.plugin = plugin
self.item_id = None self.item_id = None
QtGui.QDialog.__init__(self, plugin.formParent) QtGui.QDialog.__init__(self, self.plugin.main_window)
self.setupUi(self) self.setupUi(self)
QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked) QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked)

View File

@ -81,7 +81,7 @@ class BiblePlugin(Plugin):
Perform tasks on application startup Perform tasks on application startup
""" """
if self.manager.old_bible_databases: if self.manager.old_bible_databases:
if QtGui.QMessageBox.information(self.formParent, if QtGui.QMessageBox.information(self.main_window,
translate('OpenLP', 'Information'), translate('OpenLP', 'Information'),
translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n' translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n'
'Should OpenLP upgrade now?'), 'Should OpenLP upgrade now?'),
@ -128,7 +128,7 @@ class BiblePlugin(Plugin):
Upgrade older bible databases. Upgrade older bible databases.
""" """
if not hasattr(self, u'upgrade_wizard'): if not hasattr(self, u'upgrade_wizard'):
self.upgrade_wizard = BibleUpgradeForm(self.formParent, self.manager, self) self.upgrade_wizard = BibleUpgradeForm(self.main_window, self.manager, self)
# If the import was not cancelled then reload. # If the import was not cancelled then reload.
if self.upgrade_wizard.exec_(): if self.upgrade_wizard.exec_():
self.mediaItem.reloadBibles() self.mediaItem.reloadBibles()

View File

@ -480,7 +480,7 @@ class BibleMediaItem(MediaManagerItem):
elif self.advancedTab.isVisible(): elif self.advancedTab.isVisible():
bible = self.advancedVersionComboBox.currentText() bible = self.advancedVersionComboBox.currentText()
if bible: if bible:
self.editBibleForm = EditBibleForm(self, self.plugin.formParent, self.plugin.manager) self.editBibleForm = EditBibleForm(self, self.main_window, self.plugin.manager)
self.editBibleForm.loadBible(bible) self.editBibleForm.loadBible(bible)
if self.editBibleForm.exec_(): if self.editBibleForm.exec_():
self.reloadBibles() self.reloadBibles()

View File

@ -58,7 +58,7 @@ class CustomMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon): def __init__(self, parent, plugin, icon):
self.IconPath = u'custom/custom' self.IconPath = u'custom/custom'
MediaManagerItem.__init__(self, parent, plugin, icon) MediaManagerItem.__init__(self, parent, plugin, icon)
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent, self.plugin.manager) self.edit_custom_form = EditCustomForm(self, self.main_window, self.plugin.manager)
self.singleServiceItem = False self.singleServiceItem = False
self.quickPreviewAllowed = True self.quickPreviewAllowed = True
self.hasSearch = True self.hasSearch = True

View File

@ -99,22 +99,22 @@ class ImageMediaItem(MediaManagerItem):
row_list = [item.row() for item in self.listView.selectedIndexes()] row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True) row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(row_list)) self.main_window.displayProgressBar(len(row_list))
for row in row_list: for row in row_list:
text = self.listView.item(row) text = self.listView.item(row)
if text: if text:
delete_file(os.path.join(self.servicePath, text.text())) delete_file(os.path.join(self.servicePath, text.text()))
self.listView.takeItem(row) self.listView.takeItem(row)
self.plugin.formParent.incrementProgressBar() self.main_window.incrementProgressBar()
SettingsManager.set_list(self.settingsSection, u'images', self.getFileList()) SettingsManager.set_list(self.settingsSection, u'images', self.getFileList())
self.plugin.formParent.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
self.listView.blockSignals(False) self.listView.blockSignals(False)
def loadList(self, images, initialLoad=False): def loadList(self, images, initialLoad=False):
if not initialLoad: if not initialLoad:
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(images)) self.main_window.displayProgressBar(len(images))
# Sort the images by its filename considering language specific # Sort the images by its filename considering language specific
# characters. # characters.
images.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1]) images.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1])
@ -134,9 +134,9 @@ class ImageMediaItem(MediaManagerItem):
item_name.setData(QtCore.Qt.UserRole, imageFile) item_name.setData(QtCore.Qt.UserRole, imageFile)
self.listView.addItem(item_name) self.listView.addItem(item_name)
if not initialLoad: if not initialLoad:
self.plugin.formParent.incrementProgressBar() self.main_window.incrementProgressBar()
if not initialLoad: if not initialLoad:
self.plugin.formParent.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,

View File

@ -63,14 +63,14 @@ class MediaMediaItem(MediaManagerItem):
self.mediaObject = None self.mediaObject = None
self.displayController = DisplayController(parent) self.displayController = DisplayController(parent)
self.displayController.controllerLayout = QtGui.QVBoxLayout() self.displayController.controllerLayout = QtGui.QVBoxLayout()
self.plugin.mediaController.register_controller(self.displayController) self.media_controller.register_controller(self.displayController)
self.plugin.mediaController.set_controls_visible(self.displayController, False) self.media_controller.set_controls_visible(self.displayController, False)
self.displayController.previewDisplay = Display(self.displayController, False, self.displayController) self.displayController.previewDisplay = Display(self.displayController, False, self.displayController)
self.displayController.previewDisplay.hide() self.displayController.previewDisplay.hide()
self.displayController.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300)) self.displayController.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300))
self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()} self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()}
self.displayController.previewDisplay.setup() self.displayController.previewDisplay.setup()
self.plugin.mediaController.setup_display(self.displayController.previewDisplay, False) self.media_controller.setup_display(self.displayController.previewDisplay, False)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'),
self.videobackgroundReplaced) self.videobackgroundReplaced)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players)
@ -130,7 +130,7 @@ class MediaMediaItem(MediaManagerItem):
""" """
Called to reset the Live background with the media selected, Called to reset the Live background with the media selected,
""" """
self.plugin.liveController.mediaController.media_reset(self.plugin.liveController) self.live_controller.mediaController.media_reset(self.plugin.liveController)
self.resetAction.setVisible(False) self.resetAction.setVisible(False)
def videobackgroundReplaced(self): def videobackgroundReplaced(self):
@ -153,7 +153,7 @@ class MediaMediaItem(MediaManagerItem):
service_item.shortname = service_item.title service_item.shortname = service_item.title
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_command(path, name,CLAPPERBOARD) service_item.add_from_command(path, name,CLAPPERBOARD)
if self.plugin.liveController.mediaController.video(DisplayControllerType.Live, service_item, if self.live_controller.mediaController.video(DisplayControllerType.Live, service_item,
videoBehindText=True): videoBehindText=True):
self.resetAction.setVisible(True) self.resetAction.setVisible(True)
else: else:
@ -185,7 +185,7 @@ class MediaMediaItem(MediaManagerItem):
# Only get start and end times if going to a service # Only get start and end times if going to a service
if context == ServiceItemContext.Service: if context == ServiceItemContext.Service:
# Start media and obtain the length # Start media and obtain the length
if not self.plugin.mediaController.media_length(service_item): if not self.media_controller.media_length(service_item):
return False return False
service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.RequiresMedia)
@ -211,11 +211,11 @@ class MediaMediaItem(MediaManagerItem):
""" """
self.populateDisplayTypes() self.populateDisplayTypes()
self.onNewFileMasks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % ( self.onNewFileMasks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % (
u' '.join(self.plugin.mediaController.video_extensions_list), u' '.join(self.media_controller.video_extensions_list),
u' '.join(self.plugin.mediaController.audio_extensions_list), UiStrings().AllFiles) u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles)
def displaySetup(self): def displaySetup(self):
self.plugin.mediaController.setup_display(self.displayController.previewDisplay, False) self.media_controller.setup_display(self.displayController.previewDisplay, False)
def populateDisplayTypes(self): def populateDisplayTypes(self):
""" """
@ -227,7 +227,7 @@ class MediaMediaItem(MediaManagerItem):
self.displayTypeComboBox.blockSignals(True) self.displayTypeComboBox.blockSignals(True)
self.displayTypeComboBox.clear() self.displayTypeComboBox.clear()
usedPlayers, overridePlayer = get_media_players() usedPlayers, overridePlayer = get_media_players()
mediaPlayers = self.plugin.mediaController.mediaPlayers mediaPlayers = self.media_controller.mediaPlayers
currentIndex = 0 currentIndex = 0
for player in usedPlayers: for player in usedPlayers:
# load the drop down selection # load the drop down selection
@ -269,7 +269,7 @@ class MediaMediaItem(MediaManagerItem):
elif track_info.isFile(): elif track_info.isFile():
filename = os.path.split(unicode(track))[1] filename = os.path.split(unicode(track))[1]
item_name = QtGui.QListWidgetItem(filename) item_name = QtGui.QListWidgetItem(filename)
if u'*.%s' % (filename.split(u'.')[-1].lower()) in self.plugin.mediaController.audio_extensions_list: if u'*.%s' % (filename.split(u'.')[-1].lower()) in self.media_controller.audio_extensions_list:
item_name.setIcon(AUDIO) item_name.setIcon(AUDIO)
else: else:
item_name.setIcon(VIDEO) item_name.setIcon(VIDEO)
@ -287,9 +287,9 @@ class MediaMediaItem(MediaManagerItem):
media.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1]) media.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1])
ext = [] ext = []
if type == MediaType.Audio: if type == MediaType.Audio:
ext = self.plugin.mediaController.audio_extensions_list ext = self.media_controller.audio_extensions_list
else: else:
ext = self.plugin.mediaController.video_extensions_list ext = self.media_controller.video_extensions_list
ext = map(lambda x: x[1:], ext) ext = map(lambda x: x[1:], ext)
media = filter(lambda x: os.path.splitext(x)[1] in ext, media) media = filter(lambda x: os.path.splitext(x)[1] in ext, media)
return media return media

View File

@ -31,8 +31,7 @@ import logging
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings, Registry
Settings
from openlp.plugins.media.lib import MediaMediaItem, MediaTab from openlp.plugins.media.lib import MediaMediaItem, MediaTab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -91,26 +90,26 @@ class MediaPlugin(Plugin):
Time to tidy up on exit Time to tidy up on exit
""" """
log.info(u'Media Finalising') log.info(u'Media Finalising')
self.mediaController.finalise() self.media_controller.finalise()
Plugin.finalise(self) Plugin.finalise(self)
def getDisplayCss(self): def getDisplayCss(self):
""" """
Add css style sheets to htmlbuilder Add css style sheets to htmlbuilder
""" """
return self.mediaController.get_media_display_css() return self.media_controller.get_media_display_css()
def getDisplayJavaScript(self): def getDisplayJavaScript(self):
""" """
Add javascript functions to htmlbuilder Add javascript functions to htmlbuilder
""" """
return self.mediaController.get_media_display_javascript() return self.media_controller.get_media_display_javascript()
def getDisplayHtml(self): def getDisplayHtml(self):
""" """
Add html code to htmlbuilder Add html code to htmlbuilder
""" """
return self.mediaController.get_media_display_html() return self.media_controller.get_media_display_html()
def appStartup(self): def appStartup(self):
""" """
@ -122,7 +121,7 @@ class MediaPlugin(Plugin):
settings.beginGroup(self.settingsSection) settings.beginGroup(self.settingsSection)
if settings.contains(u'use phonon'): if settings.contains(u'use phonon'):
log.info(u'Found old Phonon setting') log.info(u'Found old Phonon setting')
players = self.mediaController.mediaPlayers.keys() players = self.media_controller.mediaPlayers.keys()
has_phonon = u'phonon' in players has_phonon = u'phonon' in players
if settings.value(u'use phonon') and has_phonon: if settings.value(u'use phonon') and has_phonon:
log.debug(u'Converting old setting to new setting') log.debug(u'Converting old setting to new setting')
@ -130,8 +129,18 @@ class MediaPlugin(Plugin):
if players: if players:
new_players = [player for player in players if player != u'phonon'] new_players = [player for player in players if player != u'phonon']
new_players.insert(0, u'phonon') new_players.insert(0, u'phonon')
self.mediaController.mediaPlayers[u'phonon'].isActive = True self.media_controller.mediaPlayers[u'phonon'].isActive = True
settings.setValue(u'players', u','.join(new_players)) settings.setValue(u'players', u','.join(new_players))
self.settingsTab.load() self.settingsTab.load()
settings.remove(u'use phonon') settings.remove(u'use phonon')
settings.endGroup() settings.endGroup()
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, u'_media_controller'):
self._media_controller = Registry().get(u'media_controller')
return self._media_controller
media_controller = property(_get_media_controller)

View File

@ -154,13 +154,13 @@ class PresentationMediaItem(MediaManagerItem):
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
if not initialLoad: if not initialLoad:
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(files)) self.main_window.displayProgressBar(len(files))
# Sort the presentations by its filename considering language specific characters. # Sort the presentations by its filename considering language specific characters.
files.sort(cmp=locale_compare, files.sort(cmp=locale_compare,
key=lambda filename: os.path.split(unicode(filename))[1]) key=lambda filename: os.path.split(unicode(filename))[1])
for file in files: for file in files:
if not initialLoad: if not initialLoad:
self.plugin.formParent.incrementProgressBar() self.main_window.incrementProgressBar()
if currlist.count(file) > 0: if currlist.count(file) > 0:
continue continue
filename = os.path.split(unicode(file))[1] filename = os.path.split(unicode(file))[1]
@ -209,7 +209,7 @@ class PresentationMediaItem(MediaManagerItem):
self.listView.addItem(item_name) self.listView.addItem(item_name)
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
if not initialLoad: if not initialLoad:
self.plugin.formParent.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
def onDeleteClick(self): def onDeleteClick(self):
@ -221,15 +221,15 @@ class PresentationMediaItem(MediaManagerItem):
row_list = [item.row() for item in items] row_list = [item.row() for item in items]
row_list.sort(reverse=True) row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(row_list)) self.main_window.displayProgressBar(len(row_list))
for item in items: for item in items:
filepath = unicode(item.data(QtCore.Qt.UserRole)) filepath = unicode(item.data(QtCore.Qt.UserRole))
for cidx in self.controllers: for cidx in self.controllers:
doc = self.controllers[cidx].add_document(filepath) doc = self.controllers[cidx].add_document(filepath)
doc.presentation_deleted() doc.presentation_deleted()
doc.close_presentation() doc.close_presentation()
self.plugin.formParent.incrementProgressBar() self.main_window.incrementProgressBar()
self.plugin.formParent.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
for row in row_list: for row in row_list:
self.listView.takeItem(row) self.listView.takeItem(row)

View File

@ -100,7 +100,7 @@ class PresentationPlugin(Plugin):
Create the Media Manager List Create the Media Manager List
""" """
self.mediaItem = PresentationMediaItem( self.mediaItem = PresentationMediaItem(
self.mediaDock.media_dock, self, self.icon, self.controllers) self.main_window.mediaDockManager.media_dock, self, self.icon, self.controllers)
def registerControllers(self, controller): def registerControllers(self, controller):
""" """

View File

@ -59,7 +59,7 @@ class SongImportForm(OpenLPWizard):
``plugin`` ``plugin``
The songs plugin. The songs plugin.
""" """
self.clipboard = plugin.formParent.clipboard self.clipboard = self.main_window.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp') OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp')
def setupUi(self, image): def setupUi(self, image):

View File

@ -71,8 +71,7 @@ class SongMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon): def __init__(self, parent, plugin, icon):
self.IconPath = u'songs/song' self.IconPath = u'songs/song'
MediaManagerItem.__init__(self, parent, plugin, icon) MediaManagerItem.__init__(self, parent, plugin, icon)
self.editSongForm = EditSongForm(self, self.plugin.formParent, self.editSongForm = EditSongForm(self, self.main_window, self.plugin.manager)
self.plugin.manager)
self.openLyrics = OpenLyrics(self.plugin.manager) self.openLyrics = OpenLyrics(self.plugin.manager)
self.singleServiceItem = False self.singleServiceItem = False
self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self)
@ -374,7 +373,7 @@ class SongMediaItem(MediaManagerItem):
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return return
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(items)) self.main_window.displayProgressBar(len(items))
for item in items: for item in items:
item_id = item.data(QtCore.Qt.UserRole) item_id = item.data(QtCore.Qt.UserRole)
media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id) media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id)
@ -390,8 +389,8 @@ class SongMediaItem(MediaManagerItem):
except OSError: except OSError:
log.exception(u'Could not remove directory: %s', save_path) log.exception(u'Could not remove directory: %s', save_path)
self.plugin.manager.delete_object(Song, item_id) self.plugin.manager.delete_object(Song, item_id)
self.plugin.formParent.incrementProgressBar() self.main_window.incrementProgressBar()
self.plugin.formParent.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
self.onSearchTextButtonClicked() self.onSearchTextButtonClicked()

View File

@ -144,7 +144,7 @@ class SongsPlugin(Plugin):
if maxSongs == 0: if maxSongs == 0:
return return
progressDialog = QtGui.QProgressDialog(translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel, progressDialog = QtGui.QProgressDialog(translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel,
0, maxSongs, self.formParent) 0, maxSongs, self.main_window)
progressDialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs')) progressDialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs'))
progressDialog.setWindowModality(QtCore.Qt.WindowModal) progressDialog.setWindowModality(QtCore.Qt.WindowModal)
songs = self.manager.get_all_objects(Song) songs = self.manager.get_all_objects(Song)
@ -248,7 +248,7 @@ class SongsPlugin(Plugin):
if not song_dbs: if not song_dbs:
return return
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
progress = QtGui.QProgressDialog(self.formParent) progress = QtGui.QProgressDialog(self.main_window)
progress.setWindowModality(QtCore.Qt.WindowModal) progress.setWindowModality(QtCore.Qt.WindowModal)
progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs')) progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs'))
progress.setLabelText(translate('OpenLP.Ui', 'Starting import...')) progress.setLabelText(translate('OpenLP.Ui', 'Starting import...'))

View File

@ -92,12 +92,12 @@ class SongUsagePlugin(Plugin):
self.songUsageMenu.addSeparator() self.songUsageMenu.addSeparator()
self.songUsageMenu.addAction(self.songUsageReport) self.songUsageMenu.addAction(self.songUsageReport)
self.songUsageMenu.addAction(self.songUsageDelete) self.songUsageMenu.addAction(self.songUsageDelete)
self.songUsageActiveButton = QtGui.QToolButton(self.formParent.statusBar) self.songUsageActiveButton = QtGui.QToolButton(self.main_window.statusBar)
self.songUsageActiveButton.setCheckable(True) self.songUsageActiveButton.setCheckable(True)
self.songUsageActiveButton.setAutoRaise(True) self.songUsageActiveButton.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.')) self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton') self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
self.formParent.statusBar.insertPermanentWidget(1, self.songUsageActiveButton) self.main_window.statusBar.insertPermanentWidget(1, self.songUsageActiveButton)
self.songUsageActiveButton.hide() self.songUsageActiveButton.hide()
# Signals and slots # Signals and slots
QtCore.QObject.connect(self.songUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.QObject.connect(self.songUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'),
@ -119,8 +119,8 @@ class SongUsagePlugin(Plugin):
action_list.add_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formParent) self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.main_window)
self.songUsageDetailForm = SongUsageDetailForm(self, self.formParent) self.songUsageDetailForm = SongUsageDetailForm(self, self.main_window)
self.songUsageMenu.menuAction().setVisible(True) self.songUsageMenu.menuAction().setVisible(True)
self.songUsageActiveButton.show() self.songUsageActiveButton.show()