From ff4dc581b4bf00b1dd2c740bbf23342fc10d829e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 25 Aug 2019 12:37:34 +0100 Subject: [PATCH] fix setiing theme data --- openlp/core/display/render.py | 22 +++++++++++++++++++++- openlp/core/ui/servicemanager.py | 2 -- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/openlp/core/display/render.py b/openlp/core/display/render.py index 5e41c8174..8d4bff425 100644 --- a/openlp/core/display/render.py +++ b/openlp/core/display/render.py @@ -503,6 +503,26 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow): self.force_page = False return None + def get_theme(self, item): + """ + :param item: The :class:`~openlp.core.lib.serviceitem.ServiceItem` item object + :return string: The name of the theme to be used + + """ + # Just assume we use the global theme. + theme_name = Registry().get('theme_manager').global_theme + # The theme level is either set to Service or Item. Use the service theme if one is set. We also have to use the + # service theme, even when the theme level is set to Item, because the item does not necessarily have to have a + # theme. + if self.theme_level != ThemeLevel.Global: + # When the theme level is at Service and we actually have a service theme then use it. + if self.theme_level != ThemeLevel.Service: + theme_name = Registry().get('service_manager').service_theme + # If we have Item level and have an item theme then use it. + if self.theme_level == ThemeLevel.Song and item.theme: + theme_name = item.theme + return theme_name + def format_slide(self, text, item): """ Calculate how much text can fit on a slide. @@ -515,7 +535,7 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow): QtWidgets.QApplication.instance().processEvents() self.log_debug('format slide') if item: - theme_name = item.theme if item.theme else Registry().get('theme_manager').global_theme + theme_name = self.get_theme(item) theme_data = Registry().get('theme_manager').get_theme_data(theme_name) self.theme_height = theme_data.font_main_height # Set theme for preview diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 202a926dd..43626ee83 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1617,8 +1617,6 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi theme_group.addAction(create_widget_action(self.theme_menu, theme, text=theme, checked=False, triggers=self.on_theme_change_action)) find_and_set_in_combo_box(self.theme_combo_box, self.service_theme) - # TODO: Sort this out - # self.renderer.set_service_theme(self.service_theme) self.regenerate_service_items() def on_theme_change_action(self):