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 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.ui import UiStrings, create_widget_action, critical_error_message_box
@ -98,6 +98,7 @@ class MediaManagerItem(QtGui.QWidget):
self.plugin = plugin
visible_title = self.plugin.getString(StringContent.VisibleName)
self.title = unicode(visible_title[u'title'])
Registry().register(self.title, self)
self.settingsSection = self.plugin.name
self.icon = None
if icon:
@ -618,3 +619,73 @@ class MediaManagerItem(QtGui.QWidget):
Performs a plugin specific search for items containing ``string``
"""
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 openlp.core.lib import Receiver, Settings
from openlp.core.lib import Receiver, Settings, Registry
from openlp.core.lib.ui import UiStrings
from openlp.core.utils import get_application_version
@ -168,10 +168,7 @@ class Plugin(QtCore.QObject):
self.renderer = plugin_helpers[u'renderer']
self.serviceManager = plugin_helpers[u'service']
self.settingsForm = plugin_helpers[u'settings form']
self.mediaDock = plugin_helpers[u'toolbox']
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),
self.processAddServiceEvent)
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.
"""
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):
"""
@ -287,14 +284,14 @@ class Plugin(QtCore.QObject):
"""
if self.mediaItem:
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):
"""
Called by the plugin Manager to cleanup things.
"""
if self.mediaItem:
self.mediaDock.remove_dock(self.mediaItem)
self.main_window.mediaDockManager.remove_dock(self.mediaItem)
def appStartup(self):
"""
@ -389,3 +386,13 @@ class Plugin(QtCore.QObject):
The plugin's config has changed
"""
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__
@classmethod
def create(self):
def create(cls):
"""
The constructor for the component registry providing a single registry of objects.
"""
log.info(u'Registry Initialising')
self.service_list = {}
registry = cls()
registry.service_list = {}
return registry
def get(self, key):
"""

View File

@ -40,7 +40,7 @@ from datetime import datetime
from PyQt4 import QtCore, QtGui
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 import SlideLimits, Settings
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
@ -456,6 +456,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
plugins.
"""
QtGui.QMainWindow.__init__(self)
Registry().register(u'main_window', self)
self.application = application
self.clipboard = self.application.clipboard()
self.arguments = self.application.args

View File

@ -32,7 +32,7 @@ import os
import datetime
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.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
from openlp.core.ui.media.mediaplayer import MediaPlayer
@ -88,6 +88,7 @@ class MediaController(object):
"""
def __init__(self, parent):
self.mainWindow = parent
Registry().register(u'media_controller', self)
self.mediaPlayers = {}
self.displayControllers = {}
self.currentMediaPlayer = {}
@ -130,14 +131,14 @@ class MediaController(object):
for item in player.audio_extensions_list:
if not item in self.audio_extensions_list:
self.audio_extensions_list.append(item)
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:])
self.service_manager.supportedSuffixes(item[2:])
self.video_extensions_list = []
for player in self.mediaPlayers.values():
if player.isActive:
for item in player.video_extensions_list:
if item not in self.video_extensions_list:
self.video_extensions_list.extend(item)
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:])
self.service_manager.supportedSuffixes(item[2:])
def register_players(self, player):
"""
@ -729,3 +730,13 @@ class MediaController(object):
if controller.isLive:
return controller.display
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)
self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
Registry().register(u'service_manager', self)
self.mainwindow = mainwindow
self.serviceItems = []
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())
except ZeroDivisionError:
self.ratio = 1
self.imageManager = self.parent().imageManager
self.mediaController = self.parent().mediaController
self.loopList = [
u'playSlidesMenu',
u'loopSeparator',
@ -232,7 +230,7 @@ class SlideController(DisplayController):
tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong)
self.controllerLayout.addWidget(self.toolbar)
# Build the Media Toolbar
self.mediaController.register_controller(self)
self.media_controller.register_controller(self)
if self.isLive:
# Build the Song Toolbar
self.songMenu = QtGui.QToolButton(self.toolbar)
@ -355,8 +353,7 @@ class SlideController(DisplayController):
self.setLiveHotkeys(self)
self.__addActionsToWidget(self.previewListWidget)
else:
self.previewListWidget.addActions(
[self.nextItem, self.previousItem])
self.previewListWidget.addActions([self.nextItem, self.previousItem])
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -451,7 +448,7 @@ class SlideController(DisplayController):
def liveEscape(self):
self.display.setVisible(False)
self.mediaController.media_stop(self)
self.media_controller.media_stop(self)
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())
except ZeroDivisionError:
self.ratio = 1
self.mediaController.setup_display(self.display, False)
self.media_controller.setup_display(self.display, False)
self.previewSizeChanged()
self.previewDisplay.setup()
serviceItem = ServiceItem()
self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive,
plugins=self.plugin_manager.plugins))
self.mediaController.setup_display(self.previewDisplay,True)
self.media_controller.setup_display(self.previewDisplay,True)
if self.serviceItem:
self.refreshServiceItem()
@ -774,9 +771,9 @@ class SlideController(DisplayController):
else:
# If current slide set background to image
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)
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))
self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * (1 / self.ratio)
@ -1225,7 +1222,7 @@ class SlideController(DisplayController):
Respond to the arrival of a media service item
"""
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:
self.previewDisplay.show()
self.slidePreview.hide()
@ -1235,7 +1232,7 @@ class SlideController(DisplayController):
Respond to a request to close the Video
"""
log.debug(u'SlideController onMediaClose')
self.mediaController.media_reset(self)
self.media_controller.media_reset(self)
self.previewDisplay.hide()
self.slidePreview.show()
@ -1291,3 +1288,24 @@ class SlideController(DisplayController):
return self._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.plugin = plugin
self.item_id = None
QtGui.QDialog.__init__(self, plugin.formParent)
QtGui.QDialog.__init__(self, self.plugin.main_window)
self.setupUi(self)
QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
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
"""
if self.manager.old_bible_databases:
if QtGui.QMessageBox.information(self.formParent,
if QtGui.QMessageBox.information(self.main_window,
translate('OpenLP', 'Information'),
translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n'
'Should OpenLP upgrade now?'),
@ -128,7 +128,7 @@ class BiblePlugin(Plugin):
Upgrade older bible databases.
"""
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 self.upgrade_wizard.exec_():
self.mediaItem.reloadBibles()

View File

@ -480,7 +480,7 @@ class BibleMediaItem(MediaManagerItem):
elif self.advancedTab.isVisible():
bible = self.advancedVersionComboBox.currentText()
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)
if self.editBibleForm.exec_():
self.reloadBibles()

View File

@ -58,7 +58,7 @@ class CustomMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon):
self.IconPath = u'custom/custom'
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.quickPreviewAllowed = 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.sort(reverse=True)
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:
text = self.listView.item(row)
if text:
delete_file(os.path.join(self.servicePath, text.text()))
self.listView.takeItem(row)
self.plugin.formParent.incrementProgressBar()
self.main_window.incrementProgressBar()
SettingsManager.set_list(self.settingsSection, u'images', self.getFileList())
self.plugin.formParent.finishedProgressBar()
self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
self.listView.blockSignals(False)
def loadList(self, images, initialLoad=False):
if not initialLoad:
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
# characters.
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)
self.listView.addItem(item_name)
if not initialLoad:
self.plugin.formParent.incrementProgressBar()
self.main_window.incrementProgressBar()
if not initialLoad:
self.plugin.formParent.finishedProgressBar()
self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
def generateSlideData(self, service_item, item=None, xmlVersion=False,

View File

@ -63,14 +63,14 @@ class MediaMediaItem(MediaManagerItem):
self.mediaObject = None
self.displayController = DisplayController(parent)
self.displayController.controllerLayout = QtGui.QVBoxLayout()
self.plugin.mediaController.register_controller(self.displayController)
self.plugin.mediaController.set_controls_visible(self.displayController, False)
self.media_controller.register_controller(self.displayController)
self.media_controller.set_controls_visible(self.displayController, False)
self.displayController.previewDisplay = Display(self.displayController, False, self.displayController)
self.displayController.previewDisplay.hide()
self.displayController.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300))
self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()}
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'),
self.videobackgroundReplaced)
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,
"""
self.plugin.liveController.mediaController.media_reset(self.plugin.liveController)
self.live_controller.mediaController.media_reset(self.plugin.liveController)
self.resetAction.setVisible(False)
def videobackgroundReplaced(self):
@ -153,7 +153,7 @@ class MediaMediaItem(MediaManagerItem):
service_item.shortname = service_item.title
(path, name) = os.path.split(filename)
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):
self.resetAction.setVisible(True)
else:
@ -185,7 +185,7 @@ class MediaMediaItem(MediaManagerItem):
# Only get start and end times if going to a service
if context == ServiceItemContext.Service:
# 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
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.RequiresMedia)
@ -211,11 +211,11 @@ class MediaMediaItem(MediaManagerItem):
"""
self.populateDisplayTypes()
self.onNewFileMasks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % (
u' '.join(self.plugin.mediaController.video_extensions_list),
u' '.join(self.plugin.mediaController.audio_extensions_list), UiStrings().AllFiles)
u' '.join(self.media_controller.video_extensions_list),
u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles)
def displaySetup(self):
self.plugin.mediaController.setup_display(self.displayController.previewDisplay, False)
self.media_controller.setup_display(self.displayController.previewDisplay, False)
def populateDisplayTypes(self):
"""
@ -227,7 +227,7 @@ class MediaMediaItem(MediaManagerItem):
self.displayTypeComboBox.blockSignals(True)
self.displayTypeComboBox.clear()
usedPlayers, overridePlayer = get_media_players()
mediaPlayers = self.plugin.mediaController.mediaPlayers
mediaPlayers = self.media_controller.mediaPlayers
currentIndex = 0
for player in usedPlayers:
# load the drop down selection
@ -269,7 +269,7 @@ class MediaMediaItem(MediaManagerItem):
elif track_info.isFile():
filename = os.path.split(unicode(track))[1]
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)
else:
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])
ext = []
if type == MediaType.Audio:
ext = self.plugin.mediaController.audio_extensions_list
ext = self.media_controller.audio_extensions_list
else:
ext = self.plugin.mediaController.video_extensions_list
ext = self.media_controller.video_extensions_list
ext = map(lambda x: x[1:], ext)
media = filter(lambda x: os.path.splitext(x)[1] in ext, media)
return media

View File

@ -31,8 +31,7 @@ import logging
from PyQt4 import QtCore
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Settings
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings, Registry
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
log = logging.getLogger(__name__)
@ -91,26 +90,26 @@ class MediaPlugin(Plugin):
Time to tidy up on exit
"""
log.info(u'Media Finalising')
self.mediaController.finalise()
self.media_controller.finalise()
Plugin.finalise(self)
def getDisplayCss(self):
"""
Add css style sheets to htmlbuilder
"""
return self.mediaController.get_media_display_css()
return self.media_controller.get_media_display_css()
def getDisplayJavaScript(self):
"""
Add javascript functions to htmlbuilder
"""
return self.mediaController.get_media_display_javascript()
return self.media_controller.get_media_display_javascript()
def getDisplayHtml(self):
"""
Add html code to htmlbuilder
"""
return self.mediaController.get_media_display_html()
return self.media_controller.get_media_display_html()
def appStartup(self):
"""
@ -122,7 +121,7 @@ class MediaPlugin(Plugin):
settings.beginGroup(self.settingsSection)
if settings.contains(u'use phonon'):
log.info(u'Found old Phonon setting')
players = self.mediaController.mediaPlayers.keys()
players = self.media_controller.mediaPlayers.keys()
has_phonon = u'phonon' in players
if settings.value(u'use phonon') and has_phonon:
log.debug(u'Converting old setting to new setting')
@ -130,8 +129,18 @@ class MediaPlugin(Plugin):
if players:
new_players = [player for player in players if player != 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))
self.settingsTab.load()
settings.remove(u'use phonon')
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')
if not initialLoad:
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.
files.sort(cmp=locale_compare,
key=lambda filename: os.path.split(unicode(filename))[1])
for file in files:
if not initialLoad:
self.plugin.formParent.incrementProgressBar()
self.main_window.incrementProgressBar()
if currlist.count(file) > 0:
continue
filename = os.path.split(unicode(file))[1]
@ -209,7 +209,7 @@ class PresentationMediaItem(MediaManagerItem):
self.listView.addItem(item_name)
Receiver.send_message(u'cursor_normal')
if not initialLoad:
self.plugin.formParent.finishedProgressBar()
self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
def onDeleteClick(self):
@ -221,15 +221,15 @@ class PresentationMediaItem(MediaManagerItem):
row_list = [item.row() for item in items]
row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(row_list))
self.main_window.displayProgressBar(len(row_list))
for item in items:
filepath = unicode(item.data(QtCore.Qt.UserRole))
for cidx in self.controllers:
doc = self.controllers[cidx].add_document(filepath)
doc.presentation_deleted()
doc.close_presentation()
self.plugin.formParent.incrementProgressBar()
self.plugin.formParent.finishedProgressBar()
self.main_window.incrementProgressBar()
self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
for row in row_list:
self.listView.takeItem(row)

View File

@ -100,7 +100,7 @@ class PresentationPlugin(Plugin):
Create the Media Manager List
"""
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):
"""

View File

@ -59,7 +59,7 @@ class SongImportForm(OpenLPWizard):
``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')
def setupUi(self, image):

View File

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

View File

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

View File

@ -92,12 +92,12 @@ class SongUsagePlugin(Plugin):
self.songUsageMenu.addSeparator()
self.songUsageMenu.addAction(self.songUsageReport)
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.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
self.formParent.statusBar.insertPermanentWidget(1, self.songUsageActiveButton)
self.main_window.statusBar.insertPermanentWidget(1, self.songUsageActiveButton)
self.songUsageActiveButton.hide()
# Signals and slots
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.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formParent)
self.songUsageDetailForm = SongUsageDetailForm(self, self.formParent)
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.main_window)
self.songUsageDetailForm = SongUsageDetailForm(self, self.main_window)
self.songUsageMenu.menuAction().setVisible(True)
self.songUsageActiveButton.show()