forked from openlp/openlp
Add line spacing adjustment to renderer
Remove .thumbnail directories
This commit is contained in:
parent
b1e8419ee8
commit
a29ea3f861
10
openlp.pyw
10
openlp.pyw
@ -193,16 +193,10 @@ def main():
|
|||||||
qInitResources()
|
qInitResources()
|
||||||
# Now create and actually run the application.
|
# Now create and actually run the application.
|
||||||
app = OpenLP(qt_args)
|
app = OpenLP(qt_args)
|
||||||
try:
|
sys.exit(app.run())
|
||||||
a = app.run()
|
|
||||||
print a
|
|
||||||
except:
|
|
||||||
log.exception(u'it went bang')
|
|
||||||
|
|
||||||
sys.exit(a)
|
|
||||||
|
|
||||||
if __name__ == u'__main__':
|
if __name__ == u'__main__':
|
||||||
"""
|
"""
|
||||||
Instantiate and run the application.
|
Instantiate and run the application.
|
||||||
"""
|
"""
|
||||||
main()
|
main()
|
||||||
|
@ -464,10 +464,11 @@ class Renderer(object):
|
|||||||
# now draw the text, and any outlines/shadows
|
# now draw the text, and any outlines/shadows
|
||||||
if self._theme.display_shadow:
|
if self._theme.display_shadow:
|
||||||
self._get_extent_and_render(line, footer,
|
self._get_extent_and_render(line, footer,
|
||||||
tlcorner=(x + display_shadow_size, y + display_shadow_size),
|
tlcorner=(x + display_shadow_size,
|
||||||
draw=True, color = self._theme.display_shadow_color)
|
y + display_shadow_size),
|
||||||
self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=True,
|
draw=True, color = self._theme.display_shadow_color)
|
||||||
outline_size=display_outline_size)
|
self._get_extent_and_render(line, footer, tlcorner=(x, y),
|
||||||
|
draw=True, outline_size=display_outline_size)
|
||||||
y += h
|
y += h
|
||||||
if linenum == 0:
|
if linenum == 0:
|
||||||
self._first_line_right_extent = rightextent
|
self._first_line_right_extent = rightextent
|
||||||
@ -533,7 +534,7 @@ class Renderer(object):
|
|||||||
font = self.mainFont
|
font = self.mainFont
|
||||||
metrics = QtGui.QFontMetrics(font)
|
metrics = QtGui.QFontMetrics(font)
|
||||||
w = metrics.width(line)
|
w = metrics.width(line)
|
||||||
h = metrics.height()
|
h = metrics.height() + int(self._theme.font_main_line_adjustment)
|
||||||
if draw:
|
if draw:
|
||||||
self.painter.setFont(font)
|
self.painter.setFont(font)
|
||||||
if color is None:
|
if color is None:
|
||||||
@ -544,27 +545,29 @@ class Renderer(object):
|
|||||||
else:
|
else:
|
||||||
pen = QtGui.QColor(color)
|
pen = QtGui.QColor(color)
|
||||||
x, y = tlcorner
|
x, y = tlcorner
|
||||||
|
rowpos = y + metrics.ascent()
|
||||||
if self._theme.display_outline and outline_size != 0 and not footer:
|
if self._theme.display_outline and outline_size != 0 and not footer:
|
||||||
path = QtGui.QPainterPath()
|
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.setBrush(self.painter.pen().brush())
|
||||||
self.painter.setPen(QtGui.QPen(
|
self.painter.setPen(QtGui.QPen(
|
||||||
QtGui.QColor(self._theme.display_outline_color), outline_size))
|
QtGui.QColor(self._theme.display_outline_color), outline_size))
|
||||||
self.painter.drawPath(path)
|
self.painter.drawPath(path)
|
||||||
self.painter.setPen(pen)
|
self.painter.setPen(pen)
|
||||||
self.painter.drawText(x, y + metrics.ascent(), line)
|
self.painter.drawText(x, rowpos, line)
|
||||||
if self._theme.display_slideTransition:
|
if self._theme.display_slideTransition:
|
||||||
# Print 2nd image with 70% weight
|
# Print 2nd image with 70% weight
|
||||||
if self._theme.display_outline and outline_size != 0 and not footer:
|
if self._theme.display_outline and outline_size != 0 and not footer:
|
||||||
path = QtGui.QPainterPath()
|
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.setBrush(self.painter2.pen().brush())
|
||||||
self.painter2.setPen(QtGui.QPen(
|
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.drawPath(path)
|
||||||
self.painter2.setFont(font)
|
self.painter2.setFont(font)
|
||||||
self.painter2.setPen(pen)
|
self.painter2.setPen(pen)
|
||||||
self.painter2.drawText(x, y + metrics.ascent(), line)
|
self.painter2.drawText(x, rowpos, line)
|
||||||
return (w, h)
|
return (w, h)
|
||||||
|
|
||||||
def snoop_Image(self, image, image2=None):
|
def snoop_Image(self, image, image2=None):
|
||||||
|
@ -53,6 +53,7 @@ blankthemexml=\
|
|||||||
<weight>Normal</weight>
|
<weight>Normal</weight>
|
||||||
<italics>False</italics>
|
<italics>False</italics>
|
||||||
<indentation>0</indentation>
|
<indentation>0</indentation>
|
||||||
|
<line_adjustment>0</line_adjustment>
|
||||||
<location override="False" x="10" y="10" width="1004" height="730"/>
|
<location override="False" x="10" y="10" width="1004" height="730"/>
|
||||||
</font>
|
</font>
|
||||||
<font type="footer">
|
<font type="footer">
|
||||||
@ -62,6 +63,7 @@ blankthemexml=\
|
|||||||
<weight>Normal</weight>
|
<weight>Normal</weight>
|
||||||
<italics>False</italics>
|
<italics>False</italics>
|
||||||
<indentation>0</indentation>
|
<indentation>0</indentation>
|
||||||
|
<line_adjustment>0</line_adjustment>
|
||||||
<location override="False" x="10" y="730" width="1004" height="38"/>
|
<location override="False" x="10" y="730" width="1004" height="38"/>
|
||||||
</font>
|
</font>
|
||||||
<display>
|
<display>
|
||||||
@ -171,8 +173,8 @@ class ThemeXML(object):
|
|||||||
self.child_element(background, u'filename', filename)
|
self.child_element(background, u'filename', filename)
|
||||||
|
|
||||||
def add_font(self, name, color, proportion, override, fonttype=u'main',
|
def add_font(self, name, color, proportion, override, fonttype=u'main',
|
||||||
weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0,
|
weight=u'Normal', italics=u'False', indentation=0, line_adjustment=0,
|
||||||
width=0, height=0):
|
xpos=0, ypos=0, width=0, height=0):
|
||||||
"""
|
"""
|
||||||
Add a Font.
|
Add a Font.
|
||||||
|
|
||||||
@ -227,6 +229,8 @@ class ThemeXML(object):
|
|||||||
self.child_element(background, u'italics', italics)
|
self.child_element(background, u'italics', italics)
|
||||||
#Create indentation name element
|
#Create indentation name element
|
||||||
self.child_element(background, u'indentation', unicode(indentation))
|
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
|
#Create Location element
|
||||||
element = self.theme_xml.createElement(u'location')
|
element = self.theme_xml.createElement(u'location')
|
||||||
|
@ -178,16 +178,24 @@ class Ui_AmendThemeDialog(object):
|
|||||||
self.FontMainWeightLabel.setObjectName("FontMainWeightLabel")
|
self.FontMainWeightLabel.setObjectName("FontMainWeightLabel")
|
||||||
self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel)
|
self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel)
|
||||||
self.MainLeftLayout.addWidget(self.FontMainGroupBox)
|
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 = QtGui.QLabel(self.FontMainGroupBox)
|
||||||
self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel")
|
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 = QtGui.QSpinBox(self.FontMainGroupBox)
|
||||||
self.FontMainLineSpacingSpinBox.setObjectName("FontMainLineSpacingSpinBox")
|
self.FontMainLineSpacingSpinBox.setObjectName("FontMainLineSpacingSpinBox")
|
||||||
self.FontMainLineSpacingSpinBox.setMaximum(10)
|
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 = QtGui.QLabel(self.FontMainGroupBox)
|
||||||
self.FontMainLinesPageLabel.setObjectName("FontMainLinesPageLabel")
|
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)
|
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||||
self.MainLeftLayout.addItem(spacerItem1)
|
self.MainLeftLayout.addItem(spacerItem1)
|
||||||
self.FontMainLayout.addWidget(self.MainLeftWidget)
|
self.FontMainLayout.addWidget(self.MainLeftWidget)
|
||||||
@ -620,6 +628,7 @@ class Ui_AmendThemeDialog(object):
|
|||||||
self.FontMainSize.setText(self.trUtf8('Size:'))
|
self.FontMainSize.setText(self.trUtf8('Size:'))
|
||||||
self.FontMainSizeSpinBox.setSuffix(self.trUtf8('pt'))
|
self.FontMainSizeSpinBox.setSuffix(self.trUtf8('pt'))
|
||||||
self.FontMainWrapIndentationLabel.setText(self.trUtf8('Wrap Indentation'))
|
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(0, self.trUtf8('Normal'))
|
||||||
self.FontMainWeightComboBox.setItemText(1, self.trUtf8('Bold'))
|
self.FontMainWeightComboBox.setItemText(1, self.trUtf8('Bold'))
|
||||||
self.FontMainWeightComboBox.setItemText(2, self.trUtf8('Italics'))
|
self.FontMainWeightComboBox.setItemText(2, self.trUtf8('Italics'))
|
||||||
|
@ -101,6 +101,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
QtCore.QObject.connect(self.FontMainHeightSpinBox,
|
QtCore.QObject.connect(self.FontMainHeightSpinBox,
|
||||||
QtCore.SIGNAL(u'editingFinished()'),
|
QtCore.SIGNAL(u'editingFinished()'),
|
||||||
self.onFontMainHeightSpinBoxChanged)
|
self.onFontMainHeightSpinBoxChanged)
|
||||||
|
QtCore.QObject.connect(self.FontMainLineAdjustmentSpinBox,
|
||||||
|
QtCore.SIGNAL(u'editingFinished()'),
|
||||||
|
self.onFontMainLineAdjustmentSpinBoxChanged)
|
||||||
QtCore.QObject.connect(self.FontMainLineSpacingSpinBox,
|
QtCore.QObject.connect(self.FontMainLineSpacingSpinBox,
|
||||||
QtCore.SIGNAL(u'editingFinished()'),
|
QtCore.SIGNAL(u'editingFinished()'),
|
||||||
self.onFontMainLineSpacingSpinBoxChanged)
|
self.onFontMainLineSpacingSpinBoxChanged)
|
||||||
@ -163,6 +166,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
unicode(self.theme.font_main_weight),
|
unicode(self.theme.font_main_weight),
|
||||||
unicode(self.theme.font_main_italics),
|
unicode(self.theme.font_main_italics),
|
||||||
unicode(self.theme.font_main_indentation),
|
unicode(self.theme.font_main_indentation),
|
||||||
|
unicode(self.theme.font_main_line_adjustment),
|
||||||
unicode(self.theme.font_main_x),
|
unicode(self.theme.font_main_x),
|
||||||
unicode(self.theme.font_main_y),
|
unicode(self.theme.font_main_y),
|
||||||
unicode(self.theme.font_main_width),
|
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_override), u'footer',
|
||||||
unicode(self.theme.font_footer_weight),
|
unicode(self.theme.font_footer_weight),
|
||||||
unicode(self.theme.font_footer_italics),
|
unicode(self.theme.font_footer_italics),
|
||||||
0,
|
0, # indentation
|
||||||
|
0, # line adjustment
|
||||||
unicode(self.theme.font_footer_x),
|
unicode(self.theme.font_footer_x),
|
||||||
unicode(self.theme.font_footer_y),
|
unicode(self.theme.font_footer_y),
|
||||||
unicode(self.theme.font_footer_width),
|
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.FontMainYSpinBox.setValue(self.theme.font_main_y)
|
||||||
self.FontMainWidthSpinBox.setValue(self.theme.font_main_width)
|
self.FontMainWidthSpinBox.setValue(self.theme.font_main_width)
|
||||||
self.FontMainHeightSpinBox.setValue(self.theme.font_main_height)
|
self.FontMainHeightSpinBox.setValue(self.theme.font_main_height)
|
||||||
|
self.FontMainLineAdjustmentSpinBox.setValue(
|
||||||
|
self.theme.font_main_line_adjustment)
|
||||||
self.FontMainLineSpacingSpinBox.setValue(
|
self.FontMainLineSpacingSpinBox.setValue(
|
||||||
self.theme.font_main_indentation)
|
self.theme.font_main_indentation)
|
||||||
self.stateChanging(self.theme)
|
self.stateChanging(self.theme)
|
||||||
@ -281,6 +288,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_main_width = self.FontMainWidthSpinBox.value()
|
self.theme.font_main_width = self.FontMainWidthSpinBox.value()
|
||||||
self.previewTheme()
|
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):
|
def onFontMainLineSpacingSpinBoxChanged(self):
|
||||||
if self.theme.font_main_indentation != \
|
if self.theme.font_main_indentation != \
|
||||||
self.FontMainLineSpacingSpinBox.value():
|
self.FontMainLineSpacingSpinBox.value():
|
||||||
@ -687,7 +701,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
if self.allowPreview:
|
if self.allowPreview:
|
||||||
#calculate main number of rows
|
#calculate main number of rows
|
||||||
metrics = self._getThemeMetrics()
|
metrics = self._getThemeMetrics()
|
||||||
line_height = metrics.height()
|
line_height = metrics.height() \
|
||||||
|
+ int(self.theme.font_main_line_adjustment)
|
||||||
if self.theme.display_shadow:
|
if self.theme.display_shadow:
|
||||||
line_height += int(self.theme.display_shadow_size)
|
line_height += int(self.theme.display_shadow_size)
|
||||||
if self.theme.display_outline:
|
if self.theme.display_outline:
|
||||||
@ -700,7 +715,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
page_length))
|
page_length))
|
||||||
page_length_text = unicode(self.trUtf8('Slide Height is %s rows'))
|
page_length_text = unicode(self.trUtf8('Slide Height is %s rows'))
|
||||||
self.FontMainLinesPageLabel.setText(page_length_text % page_length)
|
self.FontMainLinesPageLabel.setText(page_length_text % page_length)
|
||||||
#a=c
|
|
||||||
frame = self.thememanager.generateImage(self.theme)
|
frame = self.thememanager.generateImage(self.theme)
|
||||||
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.themelist = []
|
self.themelist = []
|
||||||
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
||||||
self.checkThemesExists(self.path)
|
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.checkThemesExists(self.thumbPath)
|
||||||
self.amendThemeForm.path = self.path
|
self.amendThemeForm.path = self.path
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
|
@ -76,7 +76,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
self.ListView.setIconSize(QtCore.QSize(88,50))
|
self.ListView.setIconSize(QtCore.QSize(88,50))
|
||||||
self.servicePath = os.path.join(
|
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):
|
if not os.path.exists(self.servicePath):
|
||||||
os.mkdir(self.servicePath)
|
os.mkdir(self.servicePath)
|
||||||
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
||||||
|
Loading…
Reference in New Issue
Block a user