From 0271962d6dd0cfe7fd9f7b98efd04e828e99bca5 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 13 Nov 2018 21:00:14 +0000 Subject: [PATCH 1/2] a 'fix' for presenation previews --- openlp/core/display/window.py | 10 ++++++++-- openlp/core/ui/slidecontroller.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/openlp/core/display/window.py b/openlp/core/display/window.py index 13f9c0237..84ec7418e 100644 --- a/openlp/core/display/window.py +++ b/openlp/core/display/window.py @@ -152,8 +152,14 @@ class DisplayWindow(QtWidgets.QWidget): self.setGeometry(screen.display_geometry) self.screen_number = screen.number - def set_single_image(self, bg_color, image): - image_uri = image.as_uri() + def set_single_image(self, bg_color, image_path): + """ + + :param str bg_color: + :param Path image_path: + :return: + """ + image_uri = image_path.as_uri() self.run_javascript('Display.setFullscreenImage("{bg_color}", "{image}");'.format(bg_color=bg_color, image=image_uri)) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 07a8a572e..e09f7f13e 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -32,6 +32,7 @@ from openlp.core.common import SlideLimits from openlp.core.common.actions import ActionList, CategoryOrder from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.mixins import LogMixin, RegistryProperties +from openlp.core.common.path import Path from openlp.core.common.registry import Registry, RegistryBase from openlp.core.common.settings import Settings from openlp.core.display.screens import ScreenList @@ -1182,7 +1183,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): QtCore.QTimer.singleShot(2500, self.grab_maindisplay) else: # If not live, use the slide's thumbnail/icon instead - image_path = self.service_item.get_rendered_frame(self.selected_row) + image_path = Path(self.service_item.get_rendered_frame(self.selected_row)) # if self.service_item.is_capable(ItemCapabilities.HasThumbnails): # image = self.image_manager.get_image(image_path, ImageSource.CommandPlugins) # self.slide_image = QtGui.QPixmap.fromImage(image) From a1c4374b1dcedaabf5c912ce29010a16dfb73b80 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 13 Nov 2018 22:41:45 +0100 Subject: [PATCH 2/2] Fix hang in powerpointcontroller --- .../plugins/presentations/lib/powerpointcontroller.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index bbd7ba72e..5b8b2248a 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -337,7 +337,12 @@ class PowerpointDocument(PresentationDocument): log.debug('main display size: y={y:d}, height={height:d}, ' 'x={x:d}, width={width:d}'.format(y=size.y(), height=size.height(), x=size.x(), width=size.width())) - win32gui.EnumWindows(self._window_enum_callback, size) + try: + win32gui.EnumWindows(self._window_enum_callback, size) + except pywintypes.error: + # When _window_enum_callback returns False to stop the enumeration (looping over open windows) + # it causes an exception that is ignored here + pass # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList()) > 1: Registry().get('main_window').activateWindow() @@ -369,6 +374,10 @@ class PowerpointDocument(PresentationDocument): self.presentation_hwnd = hwnd # Stop powerpoint from flashing in the taskbar win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0) + # Returning false stops the enumeration (looping over open windows) + return False + else: + return True def get_slide_number(self): """