Add Lines per slide and wrap indentation

This commit is contained in:
Tim Bentley 2009-10-22 20:03:08 +01:00
parent 20ca8340b9
commit 979ba02b02
6 changed files with 94 additions and 25 deletions

View File

@ -173,6 +173,7 @@ class Renderer(object):
page = []
split_lines = []
for line in text:
split = False
#Must be a blank line so keep it.
if len(line) == 0:
line = u' '
@ -196,6 +197,9 @@ class Renderer(object):
split_text = line[:pos]
split_lines.append(split_text)
line = line[pos:]
if len(line) > 0 :
line = u'%s%s' % \
(u' '[:self._theme.font_main_indentation], line)
#Text fits in a line now
for line in split_lines:
page.append(line)

View File

@ -51,6 +51,7 @@ blankthemexml=\
<proportion>30</proportion>
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="0" y="0" width="0" height="0"/>
</font>
<font type="footer">
@ -59,6 +60,7 @@ blankthemexml=\
<proportion>12</proportion>
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="0" y="0" width="0" height="0"/>
</font>
<display>
@ -167,7 +169,7 @@ 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', xpos=0, ypos=0, width=0, height=0):
weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0, width=0, height=0):
"""
Add a Font.
@ -192,6 +194,9 @@ class ThemeXML(object):
``italics``
Does the font render to italics Defaults to 0 Normal
``indentation``
Number of characters the wrap line is indented
``xpos``
The X position of the text block.
@ -217,6 +222,9 @@ class ThemeXML(object):
self.child_element(background, u'weight', weight)
#Create italics name element
self.child_element(background, u'italics', italics)
#Create indentation name element
self.child_element(background, u'indentation', unicode(indentation))
#Create Location element
element = self.theme_xml.createElement(u'location')
element.setAttribute(u'override',override)

View File

@ -177,6 +177,16 @@ class Ui_AmendThemeDialog(object):
self.FontMainWeightLabel.setObjectName("FontMainWeightLabel")
self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel)
self.MainLeftLayout.addWidget(self.FontMainGroupBox)
self.FontMainWrapIndentationLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel")
self.MainFontLayout.setWidget(4, 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.FontMainLinesPageLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainLinesPageLabel.setObjectName("FontMainLinesPageLabel")
self.MainFontLayout.setWidget(5, 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)
@ -528,7 +538,9 @@ class Ui_AmendThemeDialog(object):
AmendThemeDialog.setTabOrder(self.GradientComboBox, self.FontMainComboBox)
AmendThemeDialog.setTabOrder(self.FontMainComboBox, self.FontMainColorPushButton)
AmendThemeDialog.setTabOrder(self.FontMainColorPushButton, self.FontMainSizeSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainSizeSpinBox, self.FontMainDefaultCheckBox)
AmendThemeDialog.setTabOrder(self.FontMainSizeSpinBox, self.FontMainWeightComboBox)
AmendThemeDialog.setTabOrder(self.FontMainWeightComboBox, self.FontMainLineSpacingSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainLineSpacingSpinBox, self.FontMainDefaultCheckBox)
AmendThemeDialog.setTabOrder(self.FontMainDefaultCheckBox, self.FontMainXSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainXSpinBox, self.FontMainYSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainYSpinBox, self.FontMainWidthSpinBox)
@ -536,7 +548,8 @@ class Ui_AmendThemeDialog(object):
AmendThemeDialog.setTabOrder(self.FontMainHeightSpinBox, self.FontFooterComboBox)
AmendThemeDialog.setTabOrder(self.FontFooterComboBox, self.FontFooterColorPushButton)
AmendThemeDialog.setTabOrder(self.FontFooterColorPushButton, self.FontFooterSizeSpinBox)
AmendThemeDialog.setTabOrder(self.FontFooterSizeSpinBox, self.FontFooterDefaultCheckBox)
AmendThemeDialog.setTabOrder(self.FontFooterSizeSpinBox, self.FontFooterWeightComboBox)
AmendThemeDialog.setTabOrder(self.FontFooterWeightComboBox, self.FontFooterDefaultCheckBox)
AmendThemeDialog.setTabOrder(self.FontFooterDefaultCheckBox, self.FontFooterXSpinBox)
AmendThemeDialog.setTabOrder(self.FontFooterXSpinBox, self.FontFooterYSpinBox)
AmendThemeDialog.setTabOrder(self.FontFooterYSpinBox, self.FontFooterWidthSpinBox)
@ -571,10 +584,11 @@ class Ui_AmendThemeDialog(object):
self.FontMainColorLabel.setText(translate(u'AmendThemeDialog', u'Font Color:'))
self.FontMainSize.setText(translate(u'AmendThemeDialog', u'Size:'))
self.FontMainSizeSpinBox.setSuffix(translate(u'AmendThemeDialog', u'pt'))
self.FontMainWeightComboBox.setItemText(0, translate("AmendThemeDialog", u'Normal'))
self.FontMainWeightComboBox.setItemText(1, translate("AmendThemeDialog", u'Bold'))
self.FontMainWeightComboBox.setItemText(2, translate("AmendThemeDialog", u'Italics'))
self.FontMainWeightComboBox.setItemText(3, translate("AmendThemeDialog", u'Bold/Italics'))
self.FontMainWrapIndentationLabel.setText(translate(u'AmendThemeDialog', u'Wrap Indentation'))
self.FontMainWeightComboBox.setItemText(0, translate(u'AmendThemeDialog', u'Normal'))
self.FontMainWeightComboBox.setItemText(1, translate(u'AmendThemeDialog', u'Bold'))
self.FontMainWeightComboBox.setItemText(2, translate(u'AmendThemeDialog', u'Italics'))
self.FontMainWeightComboBox.setItemText(3, translate(u'AmendThemeDialog', u'Bold/Italics'))
self.FontMainWeightLabel.setText(translate("AmendThemeDialog", u'Font Weight:'))
self.MainLocationGroupBox.setTitle(translate(u'AmendThemeDialog', u'Display Location'))
self.DefaultLocationLabel.setText(translate(u'AmendThemeDialog', u'Use Default Location:'))

View File

@ -100,6 +100,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
QtCore.QObject.connect(self.FontMainHeightSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainHeightSpinBoxChanged)
QtCore.QObject.connect(self.FontMainLineSpacingSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainLineSpacingSpinBoxChanged)
QtCore.QObject.connect(self.FontFooterDefaultCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onFontFooterDefaultCheckBoxChanged)
@ -150,6 +153,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
unicode(self.theme.font_main_override), u'main',
unicode(self.theme.font_main_weight),
unicode(self.theme.font_main_italics),
unicode(self.theme.font_main_indentation),
unicode(self.theme.font_main_x),
unicode(self.theme.font_main_y),
unicode(self.theme.font_main_width),
@ -160,6 +164,7 @@ 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,
unicode(self.theme.font_footer_x),
unicode(self.theme.font_footer_y),
unicode(self.theme.font_footer_width),
@ -187,6 +192,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.parse(xml)
self.theme.extend_image_filename(self.path)
self.thememanager.cleanTheme(self.theme)
# Stop the initial screen setup generating 1 preview per field!
self.allowPreview = False
self.paintUi(self.theme)
self.allowPreview = True
@ -252,6 +258,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
self.FontMainHeightSpinBox.setValue(int( \
self.theme.font_main_height))
self.FontMainLineSpacingSpinBox.setValue(int( \
self.theme.font_main_indentation))
self.stateChanging(self.theme)
self.previewTheme(self.theme)
@ -270,6 +278,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.font_main_width = self.FontMainWidthSpinBox.value()
self.previewTheme(self.theme)
def onFontMainLineSpacingSpinBoxChanged(self):
if self.theme.font_main_indentation != self.FontMainLineSpacingSpinBox.value():
self.theme.font_main_indentation = self.FontMainLineSpacingSpinBox.value()
self.previewTheme(self.theme)
def onFontMainHeightSpinBoxChanged(self):
if self.theme.font_main_height != self.FontMainHeightSpinBox.value():
self.theme.font_main_height = self.FontMainHeightSpinBox.value()
@ -498,7 +511,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.FontMainWeightComboBox.setCurrentIndex(2)
else:
self.FontMainWeightComboBox.setCurrentIndex(3)
self.FontMainLineSpacingSpinBox.setValue(int(self.theme.font_main_indentation))
self.FontMainXSpinBox.setValue(int(self.theme.font_main_x))
self.FontMainYSpinBox.setValue(int(self.theme.font_main_y))
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
@ -653,5 +666,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def previewTheme(self, theme):
if self.allowPreview:
#calculate main number of rows
main_weight = 50
if self.theme.font_main_weight == u'Bold':
main_weight = 75
mainFont = QtGui.QFont(self.theme.font_main_name,
int(self.theme.font_main_proportion), # size
int(main_weight), # weight
self.theme.font_main_italics)# italic
metrics = QtGui.QFontMetrics(mainFont)
page_length = (int(self.FontMainHeightSpinBox.value()) / metrics.height() - 2 ) - 1
self.FontMainLinesPageLabel.setText(
translate(u'ThemeManager', u'Slide Height is %s rows' % page_length ))
frame = self.thememanager.generateImage(theme)
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))

View File

@ -510,6 +510,7 @@ class ThemeManager(QtGui.QWidget):
theme.font_main_color = theme.font_main_color.strip()
theme.font_main_height = theme.font_main_height.strip()
theme.font_main_italics = str_to_bool(theme.font_main_italics)
theme.font_main_indentation = int(theme.font_main_indentation)
theme.font_main_name = theme.font_main_name.strip()
#theme.font_main_override
theme.font_main_proportion = theme.font_main_proportion.strip()

View File

@ -17,7 +17,7 @@
<string>Theme Maintance</string>
</property>
<property name="windowIcon">
<iconset resource="../images/openlp-2.qrc">
<iconset>
<normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property>
<property name="modal">
@ -64,7 +64,7 @@
<item>
<widget class="QTabWidget" name="ThemeTabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="BackgroundTab">
<attribute name="title">
@ -312,15 +312,32 @@
<height>0</height>
</size>
</property>
<property name="value">
<number>16</number>
</property>
<property name="suffix">
<string>pt</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="FontMainWrapIndentationLabel">
<property name="text">
<string>Wrap Indentation</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="FontMainLineSpacingSpinBox"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="FontMainLinesPageLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
@ -425,15 +442,15 @@
<height>0</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="1">
@ -609,15 +626,15 @@
<height>0</height>
</size>
</property>
<property name="value">
<number>10</number>
</property>
<property name="suffix">
<string>pt</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
@ -728,15 +745,15 @@
<height>0</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="1">
@ -753,15 +770,15 @@
<height>0</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="1">