From 2fb0050531d20fed790a8eab23767e16aedb171b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sun, 7 Oct 2018 22:36:04 +0200 Subject: [PATCH] Fixed some crashes when creating a new theme. Still some work to do... --- openlp/core/display/render.py | 30 ++++++++++++++++++++++++++++++ openlp/core/lib/theme.py | 12 ++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/openlp/core/display/render.py b/openlp/core/display/render.py index f7bacf263..a539be319 100644 --- a/openlp/core/display/render.py +++ b/openlp/core/display/render.py @@ -47,6 +47,16 @@ FIRST_CHORD_TEMPLATE = '{chord}' CHORD_LINE_TEMPLATE = '{chord}{tail}{whitespace}{remainder}' WHITESPACE_TEMPLATE = '{whitespaces}' +VERSE = 'The Lord said to {r}Noah{/r}: \n' \ + 'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n' \ + 'The Lord said to {g}Noah{/g}:\n' \ + 'There\'s gonna be a {st}floody{/st}, {it}floody{/it}\n' \ + 'Get those children out of the muddy, muddy \n' \ + '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \ + 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' +VERSE_FOR_LINE_COUNT = '\n'.join(map(str, range(100))) +FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456'] + def remove_tags(text, can_remove_chords=False): """ @@ -443,6 +453,26 @@ class Renderer(RegistryBase, LogMixin, RegistryProperties, DisplayWindow): """ return self.run_javascript('Display.clearSlides();') + def generate_preview(self, theme_data, force_page=False): + """ + Generate a preview of a theme. + + :param theme_data: The theme to generated a preview for. + :param force_page: Flag to tell message lines per page need to be generated. + :rtype: QtGui.QPixmap + """ + # save value for use in format_slide + self.force_page = force_page + if not self.force_page: + self.set_theme(theme_data) + verses = dict() + verses['v1'] = VERSE + self.load_verses(verses) + self.force_page = False + return self.save_screenshot() + self.force_page = False + return None + def format_slide(self, text, item): """ Calculate how much text can fit on a slide. diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index b9a86f57c..1a319415d 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -199,13 +199,13 @@ class Theme(object): Set the header and footer size into the current primary screen. 10 px on each side is removed to allow for a border. """ - current_screen = ScreenList().current + current_screen_geometry = ScreenList().current.display_geometry self.font_main_y = 0 - self.font_main_width = current_screen['size'].width() - 20 - self.font_main_height = current_screen['size'].height() * 9 / 10 - self.font_footer_width = current_screen['size'].width() - 20 - self.font_footer_y = current_screen['size'].height() * 9 / 10 - self.font_footer_height = current_screen['size'].height() / 10 + self.font_main_width = current_screen_geometry.width() - 20 + self.font_main_height = current_screen_geometry.height() * 9 / 10 + self.font_footer_width = current_screen_geometry.width() - 20 + self.font_footer_y = current_screen_geometry.height() * 9 / 10 + self.font_footer_height = current_screen_geometry.height() / 10 def load_theme(self, theme, theme_path=None): """