Fix bugs with renderer

bzr-revno: 1005
This commit is contained in:
Tim Bentley 2010-09-03 20:44:56 +01:00
commit 3f93a44519
4 changed files with 14 additions and 19 deletions

View File

@ -47,26 +47,13 @@ class Renderer(object):
Initialise the renderer. Initialise the renderer.
""" """
self._rect = None self._rect = None
self._debug = False
self._display_shadow_size_footer = 0
self._display_outline_size_footer = 0
self.theme_name = None self.theme_name = None
self._theme = None self._theme = None
self._bg_image_filename = None self._bg_image_filename = None
self.frame = None self.frame = None
self.frame_opaque = None
self.bg_frame = None self.bg_frame = None
self.bg_image = None self.bg_image = None
def set_debug(self, debug):
"""
Set the debug mode of the renderer.
``debug``
The debug mode.
"""
self._debug = debug
def set_theme(self, theme): def set_theme(self, theme):
""" """
Set the theme to be used. Set the theme to be used.
@ -159,7 +146,7 @@ class Renderer(object):
doc = QtGui.QTextDocument() doc = QtGui.QTextDocument()
doc.setPageSize(QtCore.QSizeF(self._rect.width(), self._rect.height())) doc.setPageSize(QtCore.QSizeF(self._rect.width(), self._rect.height()))
df = doc.defaultFont() df = doc.defaultFont()
df.setPixelSize(self._theme.font_main_proportion) df.setPointSize(self._theme.font_main_proportion)
df.setFamily(self._theme.font_main_name) df.setFamily(self._theme.font_main_name)
main_weight = 50 main_weight = 50
if self._theme.font_main_weight == u'Bold': if self._theme.font_main_weight == u'Bold':
@ -188,7 +175,7 @@ class Renderer(object):
# Text too long so gone to next mage # Text too long so gone to next mage
if layout.pageCount() != 1: if layout.pageCount() != 1:
formatted.append(shell % old_html_text) formatted.append(shell % old_html_text)
temp_text = line temp_text = line + line_end
old_html_text = temp_text old_html_text = temp_text
formatted.append(shell % old_html_text) formatted.append(shell % old_html_text)
log.debug(u'format_slide - End') log.debug(u'format_slide - End')

View File

@ -93,6 +93,7 @@ class RenderManager(object):
""" """
self.global_theme = global_theme self.global_theme = global_theme
self.theme_level = theme_level self.theme_level = theme_level
self.themedata = None
def set_service_theme(self, service_theme): def set_service_theme(self, service_theme):
""" """
@ -102,6 +103,7 @@ class RenderManager(object):
The service-level theme to be set. The service-level theme to be set.
""" """
self.service_theme = service_theme self.service_theme = service_theme
self.themedata = None
def set_override_theme(self, theme, overrideLevels=False): def set_override_theme(self, theme, overrideLevels=False):
""" """
@ -111,6 +113,10 @@ class RenderManager(object):
``theme`` ``theme``
The name of the song-level theme. None means the service The name of the song-level theme. None means the service
item wants to use the given value. item wants to use the given value.
``overrideLevels``
Used to force the theme data passed in to be used.
""" """
log.debug(u'set override theme to %s', theme) log.debug(u'set override theme to %s', theme)
theme_level = self.theme_level theme_level = self.theme_level
@ -137,6 +143,7 @@ class RenderManager(object):
if self.theme != self.renderer.theme_name or self.themedata is None \ if self.theme != self.renderer.theme_name or self.themedata is None \
or overrideLevels: or overrideLevels:
log.debug(u'theme is now %s', self.theme) log.debug(u'theme is now %s', self.theme)
# Force the theme to be the one passed in.
if overrideLevels: if overrideLevels:
self.themedata = theme self.themedata = theme
else: else:

View File

@ -319,9 +319,6 @@ class MainDisplay(DisplayWidget):
# Make display show up if in single screen mode # Make display show up if in single screen mode
if self.isLive: if self.isLive:
self.setVisible(True) self.setVisible(True)
# save preview for debugging
if log.isEnabledFor(logging.DEBUG):
preview.save(u'temp.png', u'png')
return preview return preview
def buildHtml(self, serviceItem): def buildHtml(self, serviceItem):

View File

@ -574,7 +574,7 @@ class ServiceManager(QtGui.QWidget):
* An osd which is a pickle of the service items * An osd which is a pickle of the service items
* All image, presentation and video files needed to run the service. * All image, presentation and video files needed to run the service.
""" """
log.debug(u'onSaveService') log.debug(u'onSaveService %s' % quick)
if not quick or self.isNew: if not quick or self.isNew:
filename = QtGui.QFileDialog.getSaveFileName(self, filename = QtGui.QFileDialog.getSaveFileName(self,
translate('OpenLP.ServiceManager', 'Save Service'), translate('OpenLP.ServiceManager', 'Save Service'),
@ -755,6 +755,7 @@ class ServiceManager(QtGui.QWidget):
""" """
Set the theme for the current service Set the theme for the current service
""" """
log.debug(u'onThemeComboBoxSelected')
self.service_theme = unicode(self.themeComboBox.currentText()) self.service_theme = unicode(self.themeComboBox.currentText())
self.parent.RenderManager.set_service_theme(self.service_theme) self.parent.RenderManager.set_service_theme(self.service_theme)
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
@ -767,6 +768,7 @@ class ServiceManager(QtGui.QWidget):
The theme may have changed in the settings dialog so make The theme may have changed in the settings dialog so make
sure the theme combo box is in the correct state. sure the theme combo box is in the correct state.
""" """
log.debug(u'themeChange')
if self.parent.RenderManager.theme_level == ThemeLevel.Global: if self.parent.RenderManager.theme_level == ThemeLevel.Global:
self.toolbar.actions[u'ThemeLabel'].setVisible(False) self.toolbar.actions[u'ThemeLabel'].setVisible(False)
self.toolbar.actions[u'ThemeWidget'].setVisible(False) self.toolbar.actions[u'ThemeWidget'].setVisible(False)
@ -779,6 +781,7 @@ class ServiceManager(QtGui.QWidget):
Rebuild the service list as things have changed and a Rebuild the service list as things have changed and a
repaint is the easiest way to do this. repaint is the easiest way to do this.
""" """
log.debug(u'regenerateServiceItems')
# force reset of renderer as theme data has changed # force reset of renderer as theme data has changed
self.parent.RenderManager.themedata = None self.parent.RenderManager.themedata = None
if self.serviceItems: if self.serviceItems:
@ -800,6 +803,7 @@ class ServiceManager(QtGui.QWidget):
``item`` ``item``
Service Item to be added Service Item to be added
""" """
log.debug(u'addServiceItem')
sitem = self.findServiceItem()[0] sitem = self.findServiceItem()[0]
item.render() item.render()
if replace: if replace: