Make it possible for presentations to wrap or go to next item, like native openlp-items. Fixes bug 1165855.

Fixes: https://launchpad.net/bugs/1165855
This commit is contained in:
Tomas Groth 2016-04-21 22:09:42 +02:00
parent c3e27b44f0
commit cb3ef2f7c8
9 changed files with 39 additions and 18 deletions

View File

@ -135,7 +135,7 @@ class Registry(object):
for function in self.functions_list[event]: for function in self.functions_list[event]:
try: try:
result = function(*args, **kwargs) result = function(*args, **kwargs)
if result: if result is not None:
results.append(result) results.append(result)
except TypeError: except TypeError:
# Who has called me can help in debugging # Who has called me can help in debugging

View File

@ -1170,8 +1170,17 @@ class SlideController(DisplayController, RegistryProperties):
if not self.service_item: if not self.service_item:
return return
if self.service_item.is_command(): if self.service_item.is_command():
Registry().execute('%s_next' % self.service_item.name.lower(), [self.service_item, self.is_live]) past_end = Registry().execute('%s_next' % self.service_item.name.lower(), [self.service_item, self.is_live])
if 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:
if self.slide_limits == SlideLimits.Wrap:
self.on_slide_selected_index([0])
elif self.is_live and self.slide_limits == SlideLimits.Next:
self.service_next()
elif wrap:
self.on_slide_selected_index([0])
else:
self.update_preview() self.update_preview()
else: else:
row = self.preview_widget.current_slide_number() + 1 row = self.preview_widget.current_slide_number() + 1

View File

@ -416,11 +416,14 @@ class ImpressDocument(PresentationDocument):
""" """
Triggers the next effect of slide on the running presentation. Triggers the next effect of slide on the running presentation.
""" """
past_end = False
is_paused = self.control.isPaused() is_paused = self.control.isPaused()
self.control.gotoNextEffect() self.control.gotoNextEffect()
time.sleep(0.1) time.sleep(0.1)
if not is_paused and self.control.isPaused(): if not is_paused and self.control.isPaused():
self.control.gotoPreviousEffect() self.control.gotoPreviousEffect()
past_end = True
return past_end
def previous_step(self): def previous_step(self):
""" """

View File

@ -168,24 +168,25 @@ class Controller(object):
""" """
log.debug('Live = %s, next' % self.is_live) log.debug('Live = %s, next' % self.is_live)
if not self.doc: if not self.doc:
return return False
if not self.is_live: if not self.is_live:
return return False
if self.hide_mode: if self.hide_mode:
if not self.doc.is_active(): if not self.doc.is_active():
return return False
if self.doc.slidenumber < self.doc.get_slide_count(): if self.doc.slidenumber < self.doc.get_slide_count():
self.doc.slidenumber += 1 self.doc.slidenumber += 1
self.poll() self.poll()
return return False
if not self.activate(): if not self.activate():
return return False
# The "End of slideshow" screen is after the last slide. Note, we can't just stop on the last slide, since it # The "End of slideshow" screen is after the last slide. Note, we can't just stop on the last slide, since it
# may contain animations that need to be stepped through. # may contain animations that need to be stepped through.
if self.doc.slidenumber > self.doc.get_slide_count(): if self.doc.slidenumber > self.doc.get_slide_count():
return return True
self.doc.next_step() ret = self.doc.next_step()
self.poll() self.poll()
return ret
def previous(self): def previous(self):
""" """
@ -418,9 +419,9 @@ class MessageListener(object):
""" """
is_live = message[1] is_live = message[1]
if is_live: if is_live:
self.live_handler.next() return self.live_handler.next()
else: else:
self.preview_handler.next() return self.preview_handler.next()
def previous(self, message): def previous(self, message):
""" """

View File

@ -433,6 +433,7 @@ class PowerpointDocument(PresentationDocument):
Triggers the next effect of slide on the running presentation. Triggers the next effect of slide on the running presentation.
""" """
log.debug('next_step') log.debug('next_step')
past_end = False
try: try:
self.presentation.SlideShowWindow.Activate() self.presentation.SlideShowWindow.Activate()
self.presentation.SlideShowWindow.View.Next() self.presentation.SlideShowWindow.View.Next()
@ -441,16 +442,18 @@ class PowerpointDocument(PresentationDocument):
log.exception(e) log.exception(e)
trace_error_handler(log) trace_error_handler(log)
self.show_error_msg() self.show_error_msg()
return return past_end
if self.get_slide_number() > self.get_slide_count(): if self.get_slide_number() > self.get_slide_count():
log.debug('past end, stepping back to previous') log.debug('past end, stepping back to previous')
self.previous_step() self.previous_step()
past_end = True
# Stop powerpoint from flashing in the taskbar # Stop powerpoint from flashing in the taskbar
if self.presentation_hwnd: if self.presentation_hwnd:
win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0) win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0)
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
if len(ScreenList().screen_list) > 1: if len(ScreenList().screen_list) > 1:
Registry().get('main_window').activateWindow() Registry().get('main_window').activateWindow()
return past_end
def previous_step(self): def previous_step(self):
""" """

View File

@ -302,7 +302,10 @@ class PptviewDocument(PresentationDocument):
""" """
Triggers the next effect of slide on the running presentation. Triggers the next effect of slide on the running presentation.
""" """
self.controller.process.NextStep(self.ppt_id) if self.controller.process.NextStep(self.ppt_id) == 0:
return False
else:
return True
def previous_step(self): def previous_step(self):
""" """

View File

@ -518,16 +518,18 @@ DllExport int GetCurrentSlide(int id)
} }
// Take a step forwards through the show // Take a step forwards through the show
DllExport void NextStep(int id) DllExport int NextStep(int id)
{ {
DEBUG(L"NextStep:%d (%d)\n", id, pptView[id].currentSlide); DEBUG(L"NextStep:%d (%d)\n", id, pptView[id].currentSlide);
if (pptView[id].currentSlide > pptView[id].slideCount) return; // Return 1 to signal that the slideshow has gone past the end
if (pptView[id].currentSlide > pptView[id].slideCount) return 1;
if (pptView[id].currentSlide < pptView[id].slideCount) if (pptView[id].currentSlide < pptView[id].slideCount)
{ {
pptView[id].guess = pptView[id].currentSlide + 1; pptView[id].guess = pptView[id].currentSlide + 1;
} }
PostMessage(pptView[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, -WHEEL_DELTA), PostMessage(pptView[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, -WHEEL_DELTA),
0); 0);
return 0;
} }
// Take a step backwards through the show // Take a step backwards through the show

View File

@ -30,7 +30,7 @@ DllExport BOOL CheckInstalled();
DllExport void ClosePPT(int id); DllExport void ClosePPT(int id);
DllExport int GetCurrentSlide(int id); DllExport int GetCurrentSlide(int id);
DllExport int GetSlideCount(int id); DllExport int GetSlideCount(int id);
DllExport void NextStep(int id); DllExport int NextStep(int id);
DllExport void PrevStep(int id); DllExport void PrevStep(int id);
DllExport void GotoSlide(int id, int slide_no); DllExport void GotoSlide(int id, int slide_no);
DllExport void RestartShow(int id); DllExport void RestartShow(int id);

View File

@ -232,7 +232,7 @@ class PresentationDocument(object):
Triggers the next effect of slide on the running presentation. This might be the next animation on the current 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
""" """
pass return False
def previous_step(self): def previous_step(self):
""" """