openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00632
[Merge] lp:~j-corwin/openlp/present into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/present into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Fix so Impress quits when openlp shutdown.
First stab at showing the presentation output to the operator.
I wanted to do this in response to slide change events in the presentationcontrollers, but it started to look a bit tricky when it came to a COM message pump requirement on the PowerPoint front. Might end up resorting to timers after all.
--
https://code.launchpad.net/~j-corwin/openlp/present/+merge/13879
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2009-10-20 19:41:15 +0000
+++ openlp/core/ui/slidecontroller.py 2009-10-23 23:00:31 +0000
@@ -353,6 +353,7 @@
if self.commandItem is not None and \
self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
+ QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
else:
self.PreviewListWidget.selectRow(0)
self.onSlideSelected()
@@ -379,6 +380,7 @@
if row > -1 and row < self.PreviewListWidget.rowCount():
if self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row])
+ QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
else:
#label = self.PreviewListWidget.cellWidget(row, 0)
frame = self.serviceitem.frames[row][u'image']
@@ -389,6 +391,13 @@
log.info(u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive:
self.parent.mainDisplay.frameView(frame)
+
+ def grabMainDisplay(self):
+ winid = QtGui.QApplication.desktop().winId()
+ rm = self.parent.RenderManager
+ rect = rm.screen_list[rm.current_display][u'size']
+ winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height())
+ self.SlidePreview.setPixmap(winimg)
def onSlideSelectedNext(self):
"""
@@ -397,6 +406,7 @@
if self.commandItem is not None and \
self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_next'% self.commandItem.name.lower())
+ QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
else:
row = self.PreviewListWidget.currentRow() + 1
if row == self.PreviewListWidget.rowCount():
@@ -412,6 +422,7 @@
self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(
u'%s_previous'% self.commandItem.name.lower())
+ QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
else:
row = self.PreviewListWidget.currentRow() - 1
if row == -1:
@@ -426,6 +437,7 @@
if self.commandItem is not None and \
self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
+ QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
else:
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
self.onSlideSelected()
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2009-10-17 18:56:31 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-10-23 23:00:31 +0000
@@ -28,6 +28,7 @@
import logging
import os
+import time
if os.name == u'nt':
from win32com.client import Dispatch
@@ -85,7 +86,7 @@
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
else:
# -headless
- cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
+ cmd = u'openoffice.org -nologo -norestore -minimized -invisible -nofirststartwizard -accept="socket,host=localhost,port=2002;urp;"'
self.process = QtCore.QProcess()
self.process.startDetached(cmd)
self.process.waitForStarted()
@@ -96,6 +97,12 @@
"""
log.debug(u'Kill')
self.close_presentation()
+ if os.name != u'nt':
+ desktop = self.get_uno_desktop()
+ try:
+ desktop.terminate()
+ except:
+ pass
def load_presentation(self, presentation):
"""
@@ -121,18 +128,19 @@
url = uno.systemPathToFileUrl(presentation)
if desktop is None:
return
+ self.desktop = desktop
+ properties = []
+ properties.append(self.create_property(u'Minimized', True))
+ properties = tuple(properties)
try:
- self.desktop = desktop
- properties = []
- properties = tuple(properties)
self.document = desktop.loadComponentFromURL(url, u'_blank',
0, properties)
- self.presentation = self.document.getPresentation()
- self.presentation.Display = self.plugin.render_manager.current_display + 1
- self.controller = None
except:
log.exception(u'Failed to load presentation')
return
+ self.presentation = self.document.getPresentation()
+ self.presentation.Display = self.plugin.render_manager.current_display + 1
+ self.controller = None
self.create_thumbnails()
def create_thumbnails(self):
@@ -148,13 +156,7 @@
else:
thumbdir = uno.systemPathToFileUrl(self.thumbnailpath)
props = []
- if os.name == u'nt':
- prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
- else:
- prop = PropertyValue()
- prop.Name = u'FilterName'
- prop.Value = u'impress_png_Export'
- props.append(prop)
+ props.append(self.create_property(u'FilterName', u'impress_png_Export'))
props = tuple(props)
doc = self.document
pages = doc.getDrawPages()
@@ -164,6 +166,15 @@
doc.storeToURL(thumbdir + u'/' + self.thumbnailprefix +
unicode(idx+1) + u'.png', props)
+ def create_property(self, name, value):
+ if os.name == u'nt':
+ prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
+ else:
+ prop = PropertyValue()
+ prop.Name = name
+ prop.Value = value
+ return prop
+
def get_uno_desktop(self):
log.debug(u'getUNODesktop')
ctx = None
@@ -245,6 +256,11 @@
def start_presentation(self):
if self.controller is None or not self.controller.isRunning():
self.presentation.start()
+ # start() returns before the getCurrentComponent is ready. Try for 5 seconds
+ i = 1
+ while self.desktop.getCurrentComponent() is None and i < 50:
+ time.sleep(0.1)
+ i = i + 1
self.controller = self.desktop.getCurrentComponent().Presentation.getController()
else:
self.controller.activate()
Follow ups