Add line spacing adjustment to renderer

Remove .thumbnail directories
This commit is contained in:
Tim Bentley 2010-04-24 08:21:35 +01:00
parent b1e8419ee8
commit a29ea3f861
7 changed files with 52 additions and 28 deletions

View File

@ -193,16 +193,10 @@ def main():
qInitResources()
# Now create and actually run the application.
app = OpenLP(qt_args)
try:
a = app.run()
print a
except:
log.exception(u'it went bang')
sys.exit(a)
sys.exit(app.run())
if __name__ == u'__main__':
"""
Instantiate and run the application.
"""
main()
main()

View File

@ -464,10 +464,11 @@ class Renderer(object):
# now draw the text, and any outlines/shadows
if self._theme.display_shadow:
self._get_extent_and_render(line, footer,
tlcorner=(x + display_shadow_size, y + display_shadow_size),
draw=True, color = self._theme.display_shadow_color)
self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=True,
outline_size=display_outline_size)
tlcorner=(x + display_shadow_size,
y + display_shadow_size),
draw=True, color = self._theme.display_shadow_color)
self._get_extent_and_render(line, footer, tlcorner=(x, y),
draw=True, outline_size=display_outline_size)
y += h
if linenum == 0:
self._first_line_right_extent = rightextent
@ -533,7 +534,7 @@ class Renderer(object):
font = self.mainFont
metrics = QtGui.QFontMetrics(font)
w = metrics.width(line)
h = metrics.height()
h = metrics.height() + int(self._theme.font_main_line_adjustment)
if draw:
self.painter.setFont(font)
if color is None:
@ -544,27 +545,29 @@ class Renderer(object):
else:
pen = QtGui.QColor(color)
x, y = tlcorner
rowpos = y + metrics.ascent()
if self._theme.display_outline and outline_size != 0 and not footer:
path = QtGui.QPainterPath()
path.addText(QtCore.QPointF(x, y + metrics.ascent()), font, line)
path.addText(QtCore.QPointF(x, rowpos), font, line)
self.painter.setBrush(self.painter.pen().brush())
self.painter.setPen(QtGui.QPen(
QtGui.QColor(self._theme.display_outline_color), outline_size))
self.painter.drawPath(path)
self.painter.setPen(pen)
self.painter.drawText(x, y + metrics.ascent(), line)
self.painter.drawText(x, rowpos, line)
if self._theme.display_slideTransition:
# Print 2nd image with 70% weight
if self._theme.display_outline and outline_size != 0 and not footer:
path = QtGui.QPainterPath()
path.addText(QtCore.QPointF(x, y + metrics.ascent()), font, line)
path.addText(QtCore.QPointF(x, rowpos), font, line)
self.painter2.setBrush(self.painter2.pen().brush())
self.painter2.setPen(QtGui.QPen(
QtGui.QColor(self._theme.display_outline_color), outline_size))
QtGui.QColor(self._theme.display_outline_color),
outline_size))
self.painter2.drawPath(path)
self.painter2.setFont(font)
self.painter2.setPen(pen)
self.painter2.drawText(x, y + metrics.ascent(), line)
self.painter2.drawText(x, rowpos, line)
return (w, h)
def snoop_Image(self, image, image2=None):

View File

@ -53,6 +53,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<line_adjustment>0</line_adjustment>
<location override="False" x="10" y="10" width="1004" height="730"/>
</font>
<font type="footer">
@ -62,6 +63,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<line_adjustment>0</line_adjustment>
<location override="False" x="10" y="730" width="1004" height="38"/>
</font>
<display>
@ -171,8 +173,8 @@ class ThemeXML(object):
self.child_element(background, u'filename', filename)
def add_font(self, name, color, proportion, override, fonttype=u'main',
weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0,
width=0, height=0):
weight=u'Normal', italics=u'False', indentation=0, line_adjustment=0,
xpos=0, ypos=0, width=0, height=0):
"""
Add a Font.
@ -227,6 +229,8 @@ class ThemeXML(object):
self.child_element(background, u'italics', italics)
#Create indentation name element
self.child_element(background, u'indentation', unicode(indentation))
#Create indentation name element
self.child_element(background, u'line_adjustment', unicode(line_adjustment))
#Create Location element
element = self.theme_xml.createElement(u'location')

View File

@ -178,16 +178,24 @@ class Ui_AmendThemeDialog(object):
self.FontMainWeightLabel.setObjectName("FontMainWeightLabel")
self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel)
self.MainLeftLayout.addWidget(self.FontMainGroupBox)
self.FontMainWrapLineAdjustmentLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainWrapLineAdjustmentLabel.setObjectName("FontMainWrapLineAdjustmentLabel")
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapLineAdjustmentLabel)
self.FontMainLineAdjustmentSpinBox = QtGui.QSpinBox(self.FontMainGroupBox)
self.FontMainLineAdjustmentSpinBox.setObjectName("FontMainLineAdjustmentSpinBox")
self.FontMainLineAdjustmentSpinBox.setMaximum(30)
self.FontMainLineAdjustmentSpinBox.setMinimum(-30)
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineAdjustmentSpinBox)
self.FontMainWrapIndentationLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel")
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapIndentationLabel)
self.MainFontLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.FontMainWrapIndentationLabel)
self.FontMainLineSpacingSpinBox = QtGui.QSpinBox(self.FontMainGroupBox)
self.FontMainLineSpacingSpinBox.setObjectName("FontMainLineSpacingSpinBox")
self.FontMainLineSpacingSpinBox.setMaximum(10)
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineSpacingSpinBox)
self.MainFontLayout.setWidget(5, QtGui.QFormLayout.FieldRole, self.FontMainLineSpacingSpinBox)
self.FontMainLinesPageLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainLinesPageLabel.setObjectName("FontMainLinesPageLabel")
self.MainFontLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.FontMainLinesPageLabel)
self.MainFontLayout.setWidget(6, QtGui.QFormLayout.LabelRole, self.FontMainLinesPageLabel)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.MainLeftLayout.addItem(spacerItem1)
self.FontMainLayout.addWidget(self.MainLeftWidget)
@ -620,6 +628,7 @@ class Ui_AmendThemeDialog(object):
self.FontMainSize.setText(self.trUtf8('Size:'))
self.FontMainSizeSpinBox.setSuffix(self.trUtf8('pt'))
self.FontMainWrapIndentationLabel.setText(self.trUtf8('Wrap Indentation'))
self.FontMainWrapLineAdjustmentLabel.setText(self.trUtf8('Adjust Line Spacing'))
self.FontMainWeightComboBox.setItemText(0, self.trUtf8('Normal'))
self.FontMainWeightComboBox.setItemText(1, self.trUtf8('Bold'))
self.FontMainWeightComboBox.setItemText(2, self.trUtf8('Italics'))

View File

@ -101,6 +101,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
QtCore.QObject.connect(self.FontMainHeightSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainHeightSpinBoxChanged)
QtCore.QObject.connect(self.FontMainLineAdjustmentSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainLineAdjustmentSpinBoxChanged)
QtCore.QObject.connect(self.FontMainLineSpacingSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainLineSpacingSpinBoxChanged)
@ -163,6 +166,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
unicode(self.theme.font_main_weight),
unicode(self.theme.font_main_italics),
unicode(self.theme.font_main_indentation),
unicode(self.theme.font_main_line_adjustment),
unicode(self.theme.font_main_x),
unicode(self.theme.font_main_y),
unicode(self.theme.font_main_width),
@ -173,7 +177,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
unicode(self.theme.font_footer_override), u'footer',
unicode(self.theme.font_footer_weight),
unicode(self.theme.font_footer_italics),
0,
0, # indentation
0, # line adjustment
unicode(self.theme.font_footer_x),
unicode(self.theme.font_footer_y),
unicode(self.theme.font_footer_width),
@ -261,6 +266,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.FontMainYSpinBox.setValue(self.theme.font_main_y)
self.FontMainWidthSpinBox.setValue(self.theme.font_main_width)
self.FontMainHeightSpinBox.setValue(self.theme.font_main_height)
self.FontMainLineAdjustmentSpinBox.setValue(
self.theme.font_main_line_adjustment)
self.FontMainLineSpacingSpinBox.setValue(
self.theme.font_main_indentation)
self.stateChanging(self.theme)
@ -281,6 +288,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.font_main_width = self.FontMainWidthSpinBox.value()
self.previewTheme()
def onFontMainLineAdjustmentSpinBoxChanged(self):
if self.theme.font_main_line_adjustment != \
self.FontMainLineAdjustmentSpinBox.value():
self.theme.font_main_line_adjustment = \
self.FontMainLineAdjustmentSpinBox.value()
self.previewTheme()
def onFontMainLineSpacingSpinBoxChanged(self):
if self.theme.font_main_indentation != \
self.FontMainLineSpacingSpinBox.value():
@ -687,7 +701,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
if self.allowPreview:
#calculate main number of rows
metrics = self._getThemeMetrics()
line_height = metrics.height()
line_height = metrics.height() \
+ int(self.theme.font_main_line_adjustment)
if self.theme.display_shadow:
line_height += int(self.theme.display_shadow_size)
if self.theme.display_outline:
@ -700,7 +715,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
page_length))
page_length_text = unicode(self.trUtf8('Slide Height is %s rows'))
self.FontMainLinesPageLabel.setText(page_length_text % page_length)
#a=c
frame = self.thememanager.generateImage(self.theme)
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))

View File

@ -107,7 +107,7 @@ class ThemeManager(QtGui.QWidget):
self.themelist = []
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
self.checkThemesExists(self.path)
self.thumbPath = os.path.join(self.path, u'.thumbnails')
self.thumbPath = os.path.join(self.path, u'thumbnails')
self.checkThemesExists(self.thumbPath)
self.amendThemeForm.path = self.path
# Last little bits of setting up

View File

@ -76,7 +76,7 @@ class ImageMediaItem(MediaManagerItem):
QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setIconSize(QtCore.QSize(88,50))
self.servicePath = os.path.join(
self.parent.config.get_data_path(), u'.thumbnails')
self.parent.config.get_data_path(), u'thumbnails')
if not os.path.exists(self.servicePath):
os.mkdir(self.servicePath)
self.loadList(self.parent.config.load_list(self.ConfigSection))