From 1d0770b4c985d8d102e660d38ba9def913d8aa69 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 10 Sep 2018 22:14:13 +0200 Subject: [PATCH] First step to make displays work. --- openlp/core/display/screens.py | 3 ++- openlp/core/display/window.py | 3 ++- openlp/core/ui/slidecontroller.py | 33 ++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/openlp/core/display/screens.py b/openlp/core/display/screens.py index 3e9c8a828..44bc9ec7d 100644 --- a/openlp/core/display/screens.py +++ b/openlp/core/display/screens.py @@ -282,8 +282,9 @@ class ScreenList(object): """ self.screens = [] for number in range(self.desktop.screenCount()): + # TODO: Remove hardcoded last argument when the screen-settings tab works self.screens.append( - Screen(number, self.desktop.screenGeometry(number), self.desktop.primaryScreen() == number)) + Screen(number, self.desktop.screenGeometry(number), self.desktop.primaryScreen() == number, True)) def on_screen_resolution_changed(self, number): """ diff --git a/openlp/core/display/window.py b/openlp/core/display/window.py index 44cfc1e38..5232463de 100644 --- a/openlp/core/display/window.py +++ b/openlp/core/display/window.py @@ -108,7 +108,7 @@ class DisplayWindow(QtWidgets.QWidget): from openlp.core.display.webengine import WebEngineView self._is_initialised = False self._fbo = None - self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) + self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool) #| QtCore.Qt.WindowStaysOnTopHint self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) @@ -122,6 +122,7 @@ class DisplayWindow(QtWidgets.QWidget): self.webview.page().setWebChannel(self.channel) if screen and screen.is_display: self.update_from_screen(screen) + self.show() def update_from_screen(self, screen): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 03fe08290..5ade96f32 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -743,12 +743,6 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): :param item: The current service item """ - theme_name = item.theme if item.theme else Registry().get('theme_manager').global_theme - self.preview_display.set_theme(Registry().get('theme_manager').get_theme_data(theme_name)) - if item.is_text(): - self.preview_display.load_verses(item.rendered_slides) - elif item.is_image(): - self.preview_display.load_images(item.slides) slide_no = 0 # if self.song_edit: # slide_no = self.selected_row @@ -813,6 +807,16 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): Registry().execute( '{text}_start'.format(text=service_item.name.lower()), [self.service_item, self.is_live, self.hide_mode(), slide_no]) + else: + # Get theme + theme_name = service_item.theme if service_item.theme else Registry().get('theme_manager').global_theme + theme_data = Registry().get('theme_manager').get_theme_data(theme_name) + # Set theme for preview + self.preview_display.set_theme(theme_data) + # Set theme for displays + for display in self.displays: + display.set_theme(theme_data) + # Reset blanking if needed if old_item and self.is_live and (old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay) or self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)): @@ -846,6 +850,9 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): row = 0 width = self.main_window.control_splitter.sizes()[self.split] if self.service_item.is_text(): + self.preview_display.load_verses(service_item.rendered_slides) + for display in self.displays: + display.load_verses(service_item.rendered_slides) for slide_index, slide in enumerate(self.service_item.display_slides): if not slide['verse'].isdigit(): # These tags are already translated. @@ -861,6 +868,10 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): row += 1 self.slide_list[str(row)] = row - 1 else: + if service_item.is_image(): + self.preview_display.load_images(service_item.slides) + for display in self.displays: + display.load_images(service_item.slides) for slide_index, slide in enumerate(self.service_item.slides): row += 1 self.slide_list[str(row)] = row - 1 @@ -925,7 +936,15 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties): """ Set the preview display's zoom factor based on the size relative to the display size """ - ratio = float(size.width()) / 1920.0 + display_with = 0 + for screen in self.screens: + if screen.is_display: + display_with = screen.geometry.width() + if display_with == 0: + ratio = 0.25 + else: + ratio = float(size.width()) / display_with + # TODO: Find a different scale solution, setZoomFactor only supports 0.25-5.0. Maybe HTML scale? self.preview_display.webview.setZoomFactor(ratio) def main_display_set_background(self):