forked from openlp/openlp
Changes to presentations to allow smart file selection
Fix ServiceManager to load / save services. Add start of filtering to allow Services to handle presentations where the player is missing Add debugging to try and sort out Impress crashes. bzr-revno: 699
This commit is contained in:
commit
ade33da3a3
@ -159,7 +159,7 @@ def main():
|
||||
help="Set the Qt4 style (passed directly to Qt4).")
|
||||
# Set up logging
|
||||
filename = u'openlp.log'
|
||||
logfile = FileHandler(filename)
|
||||
logfile = FileHandler(filename, u'w')
|
||||
logfile.setFormatter(logging.Formatter(
|
||||
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
|
||||
log.addHandler(logfile)
|
||||
|
@ -104,6 +104,9 @@ class EventReceiver(QtCore.QObject):
|
||||
``remote_edit_clear``
|
||||
Informs all components that remote edit has been aborted.
|
||||
|
||||
``presentation types``
|
||||
Informs all components of the presentation types supported.
|
||||
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EventReceiver')
|
||||
@ -161,4 +164,4 @@ class Receiver():
|
||||
"""
|
||||
Get the global ``eventreceiver`` instance.
|
||||
"""
|
||||
return Receiver.eventreceiver
|
||||
return Receiver.eventreceiver
|
||||
|
@ -225,12 +225,17 @@ class ServiceManager(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentation types'), self.onPresentationTypes)
|
||||
# Last little bits of setting up
|
||||
self.config = PluginConfig(u'ServiceManager')
|
||||
self.servicePath = self.config.get_data_path()
|
||||
self.service_theme = unicode(
|
||||
self.config.get_config(u'service theme', u''))
|
||||
|
||||
def onPresentationTypes(self, presentation_types):
|
||||
self.presentation_types = presentation_types
|
||||
|
||||
def onMoveSelectionUp(self):
|
||||
"""
|
||||
Moves the selection up the window
|
||||
@ -433,10 +438,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
for item in self.serviceItems:
|
||||
service.append({u'serviceitem':item[u'service_item'].get_service_repr()})
|
||||
if item[u'service_item'].uses_file():
|
||||
for frame in item[u'service_item'].get_frames:
|
||||
for frame in item[u'service_item'].get_frames():
|
||||
path_from = unicode(os.path.join(
|
||||
item[u'service_item'].service_item_path,
|
||||
frame.get_frame_title()))
|
||||
frame[u'title']))
|
||||
zip.write(path_from)
|
||||
file = open(servicefile, u'wb')
|
||||
cPickle.dump(service, file)
|
||||
@ -499,7 +504,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
serviceitem = ServiceItem()
|
||||
serviceitem.RenderManager = self.parent.RenderManager
|
||||
serviceitem.set_from_service(item, self.servicePath)
|
||||
self.addServiceItem(serviceitem)
|
||||
if self.validateItem(serviceitem):
|
||||
self.addServiceItem(serviceitem)
|
||||
try:
|
||||
if os.path.isfile(p_file):
|
||||
os.remove(p_file)
|
||||
@ -516,6 +522,14 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceName = name[len(name) - 1]
|
||||
self.parent.serviceChanged(True, self.serviceName)
|
||||
|
||||
def validateItem(self, serviceItem):
|
||||
# print "---"
|
||||
# print serviceItem.name
|
||||
# print serviceItem.title
|
||||
# print serviceItem.service_item_path
|
||||
# print serviceItem.service_item_type
|
||||
return True
|
||||
|
||||
def cleanUp(self):
|
||||
"""
|
||||
Empties the servicePath of temporary files
|
||||
@ -617,7 +631,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
else:
|
||||
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
#adjuest for zero based arrays
|
||||
#adjust for zero based arrays
|
||||
pos = pos - 1
|
||||
return pos, count
|
||||
|
||||
|
@ -62,10 +62,12 @@ class ImpressController(PresentationController):
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Impress')
|
||||
self.supports= [u'.odp', u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||
self.process = None
|
||||
self.document = None
|
||||
self.presentation = None
|
||||
self.controller = None
|
||||
self.desktop = None
|
||||
|
||||
def check_available(self):
|
||||
"""
|
||||
@ -85,7 +87,7 @@ class ImpressController(PresentationController):
|
||||
It is not displayed to the user but is available to the UNO interface
|
||||
when required.
|
||||
"""
|
||||
log.debug(u'start Openoffice')
|
||||
log.debug(u'start process Openoffice')
|
||||
if os.name == u'nt':
|
||||
self.manager = self.get_com_servicemanager()
|
||||
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
||||
@ -101,7 +103,7 @@ class ImpressController(PresentationController):
|
||||
"""
|
||||
Called at system exit to clean up any running presentations
|
||||
"""
|
||||
log.debug(u'Kill')
|
||||
log.debug(u'Kill OpenOffice')
|
||||
self.close_presentation()
|
||||
if os.name != u'nt':
|
||||
desktop = self.get_uno_desktop()
|
||||
@ -121,8 +123,9 @@ class ImpressController(PresentationController):
|
||||
``presentation``
|
||||
The file name of the presentatios to the run.
|
||||
"""
|
||||
log.debug(u'LoadPresentation')
|
||||
log.debug(u'Load Presentation OpenOffice')
|
||||
self.store_filename(presentation)
|
||||
#print "s.dsk1 ", self.desktop
|
||||
if os.name == u'nt':
|
||||
desktop = self.get_com_desktop()
|
||||
if desktop is None:
|
||||
@ -135,6 +138,7 @@ class ImpressController(PresentationController):
|
||||
if desktop is None:
|
||||
return
|
||||
self.desktop = desktop
|
||||
#print "s.dsk2 ", self.desktop
|
||||
properties = []
|
||||
properties.append(self.create_property(u'Minimized', True))
|
||||
properties = tuple(properties)
|
||||
@ -153,9 +157,9 @@ class ImpressController(PresentationController):
|
||||
"""
|
||||
Create thumbnail images for presentation
|
||||
"""
|
||||
log.debug(u'create thumbnails OpenOffice')
|
||||
if self.check_thumbnails():
|
||||
return
|
||||
|
||||
if os.name == u'nt':
|
||||
thumbdir = u'file:///' + self.thumbnailpath.replace(
|
||||
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
||||
@ -170,13 +174,14 @@ class ImpressController(PresentationController):
|
||||
page = pages.getByIndex(idx)
|
||||
doc.getCurrentController().setCurrentPage(page)
|
||||
path = u'%s/%s%s.png'% (thumbdir, self.thumbnailprefix,
|
||||
unicode(idx+1))
|
||||
unicode(idx + 1))
|
||||
try:
|
||||
doc.storeToURL(path , props)
|
||||
except:
|
||||
log.exception(u'%s\nUnable to store preview' % path)
|
||||
|
||||
def create_property(self, name, value):
|
||||
log.debug(u'create property OpenOffice')
|
||||
if os.name == u'nt':
|
||||
prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
|
||||
else:
|
||||
@ -186,7 +191,7 @@ class ImpressController(PresentationController):
|
||||
return prop
|
||||
|
||||
def get_uno_desktop(self):
|
||||
log.debug(u'getUNODesktop')
|
||||
log.debug(u'get UNO Desktop Openoffice')
|
||||
ctx = None
|
||||
loop = 0
|
||||
context = uno.getComponentContext()
|
||||
@ -196,6 +201,7 @@ class ImpressController(PresentationController):
|
||||
try:
|
||||
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
||||
except:
|
||||
log.exception(u'Unable to fine running instance ')
|
||||
self.start_process()
|
||||
loop += 1
|
||||
try:
|
||||
@ -208,7 +214,7 @@ class ImpressController(PresentationController):
|
||||
return None
|
||||
|
||||
def get_com_desktop(self):
|
||||
log.debug(u'getCOMDesktop')
|
||||
log.debug(u'get COM Desktop OpenOffice')
|
||||
try:
|
||||
desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
||||
return desktop
|
||||
@ -217,7 +223,7 @@ class ImpressController(PresentationController):
|
||||
return None
|
||||
|
||||
def get_com_servicemanager(self):
|
||||
log.debug(u'get_com_servicemanager')
|
||||
log.debug(u'get_com_servicemanager openoffice')
|
||||
try:
|
||||
return Dispatch(u'com.sun.star.ServiceManager')
|
||||
except:
|
||||
@ -230,6 +236,7 @@ class ImpressController(PresentationController):
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
being shut down
|
||||
"""
|
||||
log.debug(u'close Presentation OpenOffice')
|
||||
if self.document:
|
||||
if self.presentation:
|
||||
try:
|
||||
@ -242,32 +249,44 @@ class ImpressController(PresentationController):
|
||||
self.document = None
|
||||
|
||||
def is_loaded(self):
|
||||
log.debug(u'is loaded OpenOffice')
|
||||
#print "is_loaded "
|
||||
if self.presentation is None or self.document is None:
|
||||
#print "no present or document"
|
||||
return False
|
||||
try:
|
||||
if self.document.getPresentation() is None:
|
||||
#print "no getPresentation"
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
def is_active(self):
|
||||
log.debug(u'is active OpenOffice')
|
||||
#print "is_active "
|
||||
if not self.is_loaded():
|
||||
#print "False "
|
||||
return False
|
||||
#print "self.con ", self.controller
|
||||
if self.controller is None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def unblank_screen(self):
|
||||
log.debug(u'unblank screen OpenOffice')
|
||||
return self.controller.resume()
|
||||
|
||||
def blank_screen(self):
|
||||
log.debug(u'blank screen OpenOffice')
|
||||
self.controller.blankScreen(0)
|
||||
|
||||
def stop_presentation(self):
|
||||
log.debug(u'stop presentation OpenOffice')
|
||||
self.controller.deactivate()
|
||||
|
||||
def start_presentation(self):
|
||||
log.debug(u'start presentation OpenOffice')
|
||||
if self.controller is None or not self.controller.isRunning():
|
||||
self.presentation.start()
|
||||
# start() returns before the getCurrentComponent is ready. Try for 5 seconds
|
||||
|
@ -63,7 +63,13 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = self.trUtf8('Select Presentation(s)')
|
||||
self.OnNewFileMasks = self.trUtf8('Presentations (*.ppt *.pps *.odp)')
|
||||
fileType = u''
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled:
|
||||
for type in self.controllers[controller].supports:
|
||||
if fileType.find(type) == -1:
|
||||
fileType += type + u' '
|
||||
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
@ -151,4 +157,4 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
service_item.add_from_command(path, name, img)
|
||||
i = i + 1
|
||||
img = controller.get_slide_preview_file(i)
|
||||
return True
|
||||
return True
|
||||
|
@ -52,6 +52,7 @@ class PowerpointController(PresentationController):
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint')
|
||||
self.supports= [u'.ppt', u'.pps']
|
||||
self.process = None
|
||||
self.presentation = None
|
||||
|
||||
@ -255,4 +256,4 @@ class PowerpointController(PresentationController):
|
||||
if os.path.isfile(path):
|
||||
return path
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
@ -49,6 +49,7 @@ class PptviewController(PresentationController):
|
||||
log.debug(u'Initialising')
|
||||
self.process = None
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||
self.supports= [u'.ppt', u'.pps']
|
||||
self.pptid = None
|
||||
|
||||
def check_available(self):
|
||||
|
@ -118,7 +118,7 @@ class PresentationController(object):
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'PresentationController')
|
||||
log.info(u'loaded')
|
||||
log.info(u'PresentationController loaded')
|
||||
|
||||
def __init__(self, plugin=None, name=u'PresentationController'):
|
||||
"""
|
||||
@ -136,6 +136,7 @@ class PresentationController(object):
|
||||
``name``
|
||||
Name of the application, to appear in the application
|
||||
"""
|
||||
self.supports = []
|
||||
self.plugin = plugin
|
||||
self.name = name
|
||||
self.available = self.check_available()
|
||||
@ -313,4 +314,4 @@ class PresentationController(object):
|
||||
else:
|
||||
prefix = u'preview'
|
||||
Receiver.send_message(u'%s_slidecontroller_change' % prefix,
|
||||
self.slidenumber - 1)
|
||||
self.slidenumber - 1)
|
||||
|
@ -26,7 +26,7 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon
|
||||
from openlp.core.lib import Plugin, build_icon, Receiver
|
||||
from openlp.plugins.presentations.lib import *
|
||||
|
||||
class PresentationPlugin(Plugin):
|
||||
@ -51,6 +51,12 @@ class PresentationPlugin(Plugin):
|
||||
log.info(u'Presentations Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.insert_toolbox_item()
|
||||
presentation_types = []
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled:
|
||||
presentation_types.append({u'%s' % controller : self.controllers[controller].supports})
|
||||
Receiver.send_message(
|
||||
u'presentation types', presentation_types)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
@ -106,4 +112,4 @@ class PresentationPlugin(Plugin):
|
||||
'the ability to show presentations using a number of different '
|
||||
'programs. The choice of available presentation programs is '
|
||||
'available to the user in a drop down box.')
|
||||
return about_text
|
||||
return about_text
|
||||
|
Loading…
Reference in New Issue
Block a user