Added support for Powerpoint events, which is used to update the slidecontroller if OpenLP is not in focus.

This commit is contained in:
Tomas Groth 2015-05-05 10:53:31 +02:00
parent af3eaf2b37
commit cd6903be86

View File

@ -32,7 +32,7 @@ import time
from openlp.core.common import is_win, Settings
if is_win():
from win32com.client import Dispatch
from win32com.client import DispatchWithEvents
import win32com
import winreg
import win32ui
@ -81,9 +81,21 @@ class PowerpointController(PresentationController):
"""
Loads PowerPoint process.
"""
class PowerPointEvents:
"""
Class to catch events from PowerPoint.
"""
def OnSlideShowNextClick(self, slideshow_window, effect):
"""
Occurs on the next click of the slide. If the main OpenLP is not in focus force update of the slidecontroller.
"""
if not Registry().get('main_window').isActiveWindow():
log.debug('main window is not in focus - should update slidecontroller')
Registry().execute('slidecontroller_live_change', slideshow_window.View.CurrentShowPosition)
log.debug('start_process')
if not self.process:
self.process = Dispatch('PowerPoint.Application')
self.process = DispatchWithEvents('PowerPoint.Application', PowerPointEvents)
def kill(self):
"""
@ -311,6 +323,7 @@ class PowerpointDocument(PresentationDocument):
size = ScreenList().current['size']
ppt_window = None
try:
self.presentation.SlideShowSettings.ShowWithAnimation = True
ppt_window = self.presentation.SlideShowSettings.Run()
except (AttributeError, pywintypes.com_error) as e:
log.exception('Caught exception while in start_presentation')
@ -391,6 +404,7 @@ class PowerpointDocument(PresentationDocument):
"""
log.debug('next_step')
try:
self.presentation.SlideShowWindow.Activate()
self.presentation.SlideShowWindow.View.Next()
except (AttributeError, pywintypes.com_error) as e:
log.exception('Caught exception while in next_step')
@ -401,6 +415,9 @@ class PowerpointDocument(PresentationDocument):
if self.get_slide_number() > self.get_slide_count():
log.debug('past end, stepping back to previous')
self.previous_step()
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
if len(ScreenList().screen_list) > 1:
Registry().get('main_window').activateWindow()
def previous_step(self):
"""