Implement going to the previous serviceitem.

This commit is contained in:
Tomas Groth 2019-02-15 20:33:43 +01:00
parent ad0eacd4f0
commit aa982492e4
5 changed files with 45 additions and 10 deletions

View File

@ -1174,7 +1174,8 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
if not self.service_item:
return
if self.service_item.is_command():
past_end = Registry().execute('%s_next' % self.service_item.name.lower(), [self.service_item, self.is_live])
past_end = Registry().execute('{text}_next'.format(text=self.service_item.name.lower()),
[self.service_item, self.is_live])
# Check if we have gone past the end of the last slide
if self.is_live and past_end and past_end[0]:
if wrap is None:
@ -1211,9 +1212,17 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
if not self.service_item:
return
if self.service_item.is_command():
Registry().execute('{text}_previous'.format(text=self.service_item.name.lower()),
[self.service_item, self.is_live])
if self.is_live:
before_start = Registry().execute('{text}_previous'.format(text=self.service_item.name.lower()),
[self.service_item, self.is_live])
# Check id we have tried to go before that start slide
if self.is_live and before_start and before_start[0]:
print('detected before start!')
if self.slide_limits == SlideLimits.Wrap:
self.on_slide_selected_index([self.preview_widget.slide_count() - 1])
elif self.is_live and self.slide_limits == SlideLimits.Next:
self.keypress_queue.append(ServiceItemAction.PreviousLastSlide)
self._process_queue()
elif self.is_live:
self.update_preview()
else:
row = self.preview_widget.current_slide_number() - 1

View File

@ -46,6 +46,18 @@ from openlp.plugins.presentations.lib.presentationcontroller import Presentation
if is_win():
from win32com.client import Dispatch
import pywintypes
uno_available = False
try:
service_manager = Dispatch('com.sun.star.ServiceManager')
service_manager._FlagAsMethod('Bridge_GetStruct')
XSlideShowListenerObj = service_manager.Bridge_GetStruct('com.sun.star.presentation.XSlideShowListener')
class SlideShowListenerImport(XSlideShowListenerObj.__class__):
pass
except (AttributeError, pywintypes.com_error):
class SlideShowListenerImport(object):
pass
# Declare an empty exception to match the exception imported from UNO
class ErrorCodeIOException(Exception):
@ -58,6 +70,9 @@ else:
from com.sun.star.task import ErrorCodeIOException
from com.sun.star.presentation import XSlideShowListener
class SlideShowListenerImport(unohelper.Base, XSlideShowListener):
pass
uno_available = True
except ImportError:
uno_available = False
@ -504,8 +519,10 @@ class ImpressDocument(PresentationDocument):
notes.append(note)
self.save_titles_and_notes(titles, notes)
if is_win():
property_object = self.controller.manager.Bridge_GetStruct('com.sun.star.beans.PropertyValue')
class SlideShowListener(unohelper.Base, XSlideShowListener):
class SlideShowListener(SlideShowListenerImport):
"""
Listener interface to receive global slide show events.
"""

View File

@ -203,8 +203,10 @@ class Controller(object):
return
if not self.activate():
return
self.doc.previous_step()
ret = self.doc.previous_step()
self.poll()
print('previous returning: %d' % ret)
return ret
def shutdown(self):
"""
@ -435,11 +437,12 @@ class MessageListener(object):
"""
is_live = message[1]
if is_live:
self.live_handler.previous()
ret = self.live_handler.previous()
if Settings().value('core/click live slide to unblank'):
Registry().execute('slidecontroller_live_unblank')
return ret
else:
self.preview_handler.previous()
return self.preview_handler.previous()
def shutdown(self, message):
"""

View File

@ -468,12 +468,16 @@ class PowerpointDocument(PresentationDocument):
Triggers the previous slide on the running presentation.
"""
log.debug('previous_step')
# if we are at the presentations start we can't go further back, just return True
if self.presentation.SlideShowWindow.View.GetClickIndex() == 0 and self.get_slide_number() == 1:
return True
try:
self.presentation.SlideShowWindow.View.Previous()
except (AttributeError, pywintypes.com_error):
log.exception('Caught exception while in previous_step')
trace_error_handler(log)
self.show_error_msg()
return False
def get_slide_text(self, slide_no):
"""

View File

@ -246,15 +246,17 @@ class PresentationDocument(object):
def next_step(self):
"""
Triggers the next effect of slide on the running presentation. This might be the next animation on the current
slide, or the next slide
slide, or the next slide.
Returns True if we stepped beyond the slides of the presentation
"""
return False
def previous_step(self):
"""
Triggers the previous slide on the running presentation
Returns True if we stepped beyond the slides of the presentation
"""
pass
return False
def convert_thumbnail(self, image_path, index):
"""