forked from openlp/openlp
Docstring cleanups
Finish adding base preview pluing
This commit is contained in:
parent
ecd587319b
commit
ccb85f8f4b
@ -34,14 +34,27 @@ class EventManager(object):
|
||||
log = logging.getLogger(u'EventManager')
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Defines the class and a list of endpoints
|
||||
"""
|
||||
self.endpoints = []
|
||||
log.info(u'Initialising')
|
||||
|
||||
def register(self, plugin):
|
||||
"""
|
||||
Called by plugings who wish to receive event notifications
|
||||
"""
|
||||
log.debug(u'plugin %s registered with EventManager', plugin)
|
||||
self.endpoints.append(plugin)
|
||||
|
||||
def post_event(self, event):
|
||||
"""
|
||||
Called by any part of the system which wants send events to the plugins
|
||||
|
||||
``event``
|
||||
The event type to be triggered
|
||||
|
||||
"""
|
||||
log.debug(u'post event called for event %s', event.event_type)
|
||||
for point in self.endpoints:
|
||||
point.handle_event(event)
|
||||
|
@ -135,10 +135,18 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.service_theme = self.config.get_config(u'theme service theme', u'')
|
||||
|
||||
def collapsed(self, item):
|
||||
"""
|
||||
Record if an item is collapsed
|
||||
Used when repainting the list to get the correct state
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
self.serviceItems[pos -1 ][u'expanded'] = False
|
||||
|
||||
def expanded(self, item):
|
||||
"""
|
||||
Record if an item is collapsed
|
||||
Used when repainting the list to get the correct state
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
self.serviceItems[pos -1 ][u'expanded'] = True
|
||||
|
||||
@ -212,6 +220,11 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def repaintServiceList(self):
|
||||
"""
|
||||
Clear the existing service list and prepaint all the items
|
||||
Used when moving items as the move takes place in supporting array,
|
||||
and when regenerating all the items due to theme changes
|
||||
"""
|
||||
#Correct order of idems in array
|
||||
count = 1
|
||||
for item in self.serviceItems:
|
||||
@ -236,7 +249,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onSaveService(self):
|
||||
"""
|
||||
Save the current service
|
||||
Save the current service in a zip file
|
||||
This file contains
|
||||
* An ood which is a pickle of the service items
|
||||
* All image , presentation and video files needed to run the service.
|
||||
"""
|
||||
filename = QtGui.QFileDialog.getSaveFileName(self, u'Save Order of Service',self.config.get_last_dir() )
|
||||
filename = unicode(filename)
|
||||
@ -264,7 +280,9 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onLoadService(self):
|
||||
"""
|
||||
Load an existing service from disk
|
||||
Load an existing service from disk and rebuilds the serviceitems
|
||||
All files retrieved from the zip file are placed in a temporary directory and
|
||||
will only be used for this service.
|
||||
"""
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
|
||||
u'Services (*.oos)')
|
||||
|
@ -61,6 +61,7 @@ class SlideController(QtGui.QWidget):
|
||||
Set up the Slide Controller.
|
||||
"""
|
||||
self.toolbarList = {}
|
||||
self.previewList = {}
|
||||
QtGui.QWidget.__init__(self, parent.mainWindow)
|
||||
self.isLive = isLive
|
||||
self.parent = parent
|
||||
@ -114,7 +115,118 @@ class SlideController(QtGui.QWidget):
|
||||
self.grid.setMargin(8)
|
||||
self.grid.setObjectName(u'grid')
|
||||
# Actual preview screen
|
||||
self.SlidePreview = QtGui.QLabel(self.PreviewFrame)
|
||||
masterPreview = MasterPreview(self.PreviewFrame).getPreview()
|
||||
self.registerPreview(u'master', masterPreview)
|
||||
self.SlidePreview = self.retrievePreview(u'master')
|
||||
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.PreviewListWidget,
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
QtCore.QObject.connect(self.PreviewListWidget,
|
||||
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
# Add Late Arrivals
|
||||
self.BaseToolbar.PreviewListWidget = self.PreviewListWidget
|
||||
self.BaseToolbar.SlidePreview = self.SlidePreview
|
||||
self.BaseToolbar.mainDisplay = self.parent.mainDisplay
|
||||
|
||||
def registerToolbar(self, handle,controller):
|
||||
"""
|
||||
Register a new toolbar with the controller
|
||||
``handle``
|
||||
Identifier for the toolbar being stored this should equal the
|
||||
plugins name.
|
||||
``controller``
|
||||
The toolbar class which should extend MasterToolbar
|
||||
"""
|
||||
#store the handle name in lower case so no probems later
|
||||
self.toolbarList[handle.lower()] = controller
|
||||
|
||||
def registerPreview(self, handle,controller):
|
||||
"""
|
||||
Register a new preview with the controller
|
||||
``handle``
|
||||
Identifier for the preview being stored this should equal the
|
||||
plugins name.
|
||||
``controller``
|
||||
The preview class which should extend MasterToolbar
|
||||
"""
|
||||
#store the handle name in lower case so no probems later
|
||||
self.previewList[handle.lower()] = controller
|
||||
|
||||
def retrieveToolbar(self, handle):
|
||||
"""
|
||||
Find the toolbar and return master if none present
|
||||
Add extra information back into toolbar class
|
||||
``handle``
|
||||
Identifier for the toolbar being requested
|
||||
"""
|
||||
try:
|
||||
toolbar = self.toolbarList[handle.lower()]
|
||||
except:
|
||||
toolbar = self.toolbarList[u'master']
|
||||
toolbar.PreviewListWidget = self.PreviewListWidget
|
||||
toolbar.SlidePreview = self.SlidePreview
|
||||
toolbar.mainDisplay = self.parent.mainDisplay
|
||||
return toolbar
|
||||
|
||||
def retrievePreview(self, handle):
|
||||
"""
|
||||
Find the preview and return master if none present
|
||||
Add extra information back into toolbar class
|
||||
``handle``
|
||||
Identifier for the toolbar being requested
|
||||
"""
|
||||
try:
|
||||
preview = self.previewList[handle.lower()]
|
||||
except:
|
||||
preview = self.previewList[u'master']
|
||||
return preview
|
||||
|
||||
def addServiceItem(self, item):
|
||||
"""
|
||||
Method to install the service item into the controller and
|
||||
request the correct the toolbar of the plugin
|
||||
Called by plugins
|
||||
"""
|
||||
self.SlidePreview = self.retrievePreview(item.shortname)
|
||||
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||
#remove the old toolbar
|
||||
self.Toolbar.clear()
|
||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
self.BaseToolbar.addServiceItem(item)
|
||||
|
||||
def addServiceManagerItem(self, item, slideno):
|
||||
"""
|
||||
Method to install the service item into the controller and
|
||||
request the correct the toolbar of the plugin
|
||||
Called by ServiceManager
|
||||
"""
|
||||
self.SlidePreview = self.retrievePreview(item.shortname)
|
||||
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||
#remove the old toolbar
|
||||
self.Toolbar.clear()
|
||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
self.BaseToolbar.addServiceManagerItem(item, slideno)
|
||||
|
||||
class MasterPreview(QtCore.QObject):
|
||||
"""
|
||||
Class from which all Previews should extend allowing plugins to have their own
|
||||
previews
|
||||
s """
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
QtCore.QObject.__init__(self)
|
||||
self.definePreview()
|
||||
|
||||
def getPreview(self):
|
||||
return self.SlidePreview
|
||||
|
||||
def definePreview(self):
|
||||
self.SlidePreview = QtGui.QLabel(self.parent)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
@ -128,58 +240,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.SlidePreview.setLineWidth(1)
|
||||
self.SlidePreview.setScaledContents(True)
|
||||
self.SlidePreview.setObjectName(u'SlidePreview')
|
||||
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.PreviewListWidget,
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
QtCore.QObject.connect(self.PreviewListWidget,
|
||||
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
# Add Late Arrivals
|
||||
self.BaseToolbar.PreviewListWidget = self.PreviewListWidget
|
||||
self.BaseToolbar.SlidePreview = self.SlidePreview
|
||||
self.BaseToolbar.mainDisplay = self.parent.mainDisplay
|
||||
|
||||
def registerToolbar(self, handle,controller):
|
||||
#store the handle name in lower case so no probems later
|
||||
self.toolbarList[handle.lower()] = controller
|
||||
|
||||
def retrieveToolbar(self, handle):
|
||||
"""
|
||||
Find the toolbar and return master if none present
|
||||
Add extra information back into toolbar class
|
||||
"""
|
||||
try:
|
||||
toolbar = self.toolbarList[handle.lower()]
|
||||
except:
|
||||
toolbar = self.toolbarList[u'master']
|
||||
toolbar.PreviewListWidget = self.PreviewListWidget
|
||||
toolbar.SlidePreview = self.SlidePreview
|
||||
toolbar.mainDisplay = self.parent.mainDisplay
|
||||
return toolbar
|
||||
|
||||
def addServiceItem(self, item):
|
||||
"""
|
||||
helper method to pass item to correct toolbar
|
||||
"""
|
||||
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||
#remove the old toolbar
|
||||
self.Toolbar.clear()
|
||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
self.BaseToolbar.addServiceItem(item)
|
||||
|
||||
def addServiceManagerItem(self, item, slideno):
|
||||
"""
|
||||
helper method to pass item to correct toolbar
|
||||
"""
|
||||
self.BaseToolbar = self.retrieveToolbar(item.shortname)
|
||||
self.ControllerLayout.removeWidget(self.Toolbar)
|
||||
#remove the old toolbar
|
||||
self.Toolbar.clear()
|
||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
self.BaseToolbar.addServiceManagerItem(item, slideno)
|
||||
|
||||
class MasterToolbar(QtCore.QObject):
|
||||
"""
|
||||
@ -305,7 +366,7 @@ class MasterToolbar(QtCore.QObject):
|
||||
def addServiceManagerItem(self, serviceitem, slideno):
|
||||
"""
|
||||
Loads a ServiceItem into the system from ServiceManager
|
||||
Display the Slide Passed
|
||||
Display the slide number passed
|
||||
"""
|
||||
log.debug(u'add Service Manager Item')
|
||||
self.PreviewListWidget.clear()
|
||||
|
Loading…
Reference in New Issue
Block a user