Fixed some crashes when creating a new theme. Still some work to do...

This commit is contained in:
Tomas Groth 2018-10-07 22:36:04 +02:00
parent e45be1a50f
commit 2fb0050531
2 changed files with 36 additions and 6 deletions

View File

@ -47,6 +47,16 @@ FIRST_CHORD_TEMPLATE = '<span class="chordline firstchordline">{chord}</span>'
CHORD_LINE_TEMPLATE = '<span class="chord"><span><strong>{chord}</strong></span></span>{tail}{whitespace}{remainder}' CHORD_LINE_TEMPLATE = '<span class="chord"><span><strong>{chord}</strong></span></span>{tail}{whitespace}{remainder}'
WHITESPACE_TEMPLATE = '<span class="ws">{whitespaces}</span>' WHITESPACE_TEMPLATE = '<span class="ws">{whitespaces}</span>'
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): def remove_tags(text, can_remove_chords=False):
""" """
@ -443,6 +453,26 @@ class Renderer(RegistryBase, LogMixin, RegistryProperties, DisplayWindow):
""" """
return self.run_javascript('Display.clearSlides();') 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): def format_slide(self, text, item):
""" """
Calculate how much text can fit on a slide. Calculate how much text can fit on a slide.

View File

@ -199,13 +199,13 @@ class Theme(object):
Set the header and footer size into the current primary screen. Set the header and footer size into the current primary screen.
10 px on each side is removed to allow for a border. 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_y = 0
self.font_main_width = current_screen['size'].width() - 20 self.font_main_width = current_screen_geometry.width() - 20
self.font_main_height = current_screen['size'].height() * 9 / 10 self.font_main_height = current_screen_geometry.height() * 9 / 10
self.font_footer_width = current_screen['size'].width() - 20 self.font_footer_width = current_screen_geometry.width() - 20
self.font_footer_y = current_screen['size'].height() * 9 / 10 self.font_footer_y = current_screen_geometry.height() * 9 / 10
self.font_footer_height = current_screen['size'].height() / 10 self.font_footer_height = current_screen_geometry.height() / 10
def load_theme(self, theme, theme_path=None): def load_theme(self, theme, theme_path=None):
""" """