Theme features - wrap indentation and lines per slide

bzr-revno: 618
This commit is contained in:
Tim Bentley 2009-10-22 20:13:48 +01:00
commit 53ba5ed0c1
6 changed files with 94 additions and 25 deletions

View File

@ -196,6 +196,10 @@ class Renderer(object):
split_text = line[:pos] split_text = line[:pos]
split_lines.append(split_text) split_lines.append(split_text)
line = line[pos:] line = line[pos:]
#if we have more text add up to 10 spaces on the front.
if len(line) > 0 :
line = u'%s%s' % \
(u' '[:self._theme.font_main_indentation], line)
#Text fits in a line now #Text fits in a line now
for line in split_lines: for line in split_lines:
page.append(line) page.append(line)

View File

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

View File

@ -177,6 +177,16 @@ 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.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) 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)
@ -528,7 +538,9 @@ class Ui_AmendThemeDialog(object):
AmendThemeDialog.setTabOrder(self.GradientComboBox, self.FontMainComboBox) AmendThemeDialog.setTabOrder(self.GradientComboBox, self.FontMainComboBox)
AmendThemeDialog.setTabOrder(self.FontMainComboBox, self.FontMainColorPushButton) AmendThemeDialog.setTabOrder(self.FontMainComboBox, self.FontMainColorPushButton)
AmendThemeDialog.setTabOrder(self.FontMainColorPushButton, self.FontMainSizeSpinBox) 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.FontMainDefaultCheckBox, self.FontMainXSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainXSpinBox, self.FontMainYSpinBox) AmendThemeDialog.setTabOrder(self.FontMainXSpinBox, self.FontMainYSpinBox)
AmendThemeDialog.setTabOrder(self.FontMainYSpinBox, self.FontMainWidthSpinBox) AmendThemeDialog.setTabOrder(self.FontMainYSpinBox, self.FontMainWidthSpinBox)
@ -536,7 +548,8 @@ class Ui_AmendThemeDialog(object):
AmendThemeDialog.setTabOrder(self.FontMainHeightSpinBox, self.FontFooterComboBox) AmendThemeDialog.setTabOrder(self.FontMainHeightSpinBox, self.FontFooterComboBox)
AmendThemeDialog.setTabOrder(self.FontFooterComboBox, self.FontFooterColorPushButton) AmendThemeDialog.setTabOrder(self.FontFooterComboBox, self.FontFooterColorPushButton)
AmendThemeDialog.setTabOrder(self.FontFooterColorPushButton, self.FontFooterSizeSpinBox) 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.FontFooterDefaultCheckBox, self.FontFooterXSpinBox)
AmendThemeDialog.setTabOrder(self.FontFooterXSpinBox, self.FontFooterYSpinBox) AmendThemeDialog.setTabOrder(self.FontFooterXSpinBox, self.FontFooterYSpinBox)
AmendThemeDialog.setTabOrder(self.FontFooterYSpinBox, self.FontFooterWidthSpinBox) AmendThemeDialog.setTabOrder(self.FontFooterYSpinBox, self.FontFooterWidthSpinBox)
@ -571,10 +584,11 @@ class Ui_AmendThemeDialog(object):
self.FontMainColorLabel.setText(translate(u'AmendThemeDialog', u'Font Color:')) self.FontMainColorLabel.setText(translate(u'AmendThemeDialog', u'Font Color:'))
self.FontMainSize.setText(translate(u'AmendThemeDialog', u'Size:')) self.FontMainSize.setText(translate(u'AmendThemeDialog', u'Size:'))
self.FontMainSizeSpinBox.setSuffix(translate(u'AmendThemeDialog', u'pt')) self.FontMainSizeSpinBox.setSuffix(translate(u'AmendThemeDialog', u'pt'))
self.FontMainWeightComboBox.setItemText(0, translate("AmendThemeDialog", u'Normal')) self.FontMainWrapIndentationLabel.setText(translate(u'AmendThemeDialog', u'Wrap Indentation'))
self.FontMainWeightComboBox.setItemText(1, translate("AmendThemeDialog", u'Bold')) self.FontMainWeightComboBox.setItemText(0, translate(u'AmendThemeDialog', u'Normal'))
self.FontMainWeightComboBox.setItemText(2, translate("AmendThemeDialog", u'Italics')) self.FontMainWeightComboBox.setItemText(1, translate(u'AmendThemeDialog', u'Bold'))
self.FontMainWeightComboBox.setItemText(3, translate("AmendThemeDialog", u'Bold/Italics')) 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.FontMainWeightLabel.setText(translate("AmendThemeDialog", u'Font Weight:'))
self.MainLocationGroupBox.setTitle(translate(u'AmendThemeDialog', u'Display Location')) self.MainLocationGroupBox.setTitle(translate(u'AmendThemeDialog', u'Display Location'))
self.DefaultLocationLabel.setText(translate(u'AmendThemeDialog', u'Use Default 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.QObject.connect(self.FontMainHeightSpinBox,
QtCore.SIGNAL(u'editingFinished()'), QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainHeightSpinBoxChanged) self.onFontMainHeightSpinBoxChanged)
QtCore.QObject.connect(self.FontMainLineSpacingSpinBox,
QtCore.SIGNAL(u'editingFinished()'),
self.onFontMainLineSpacingSpinBoxChanged)
QtCore.QObject.connect(self.FontFooterDefaultCheckBox, QtCore.QObject.connect(self.FontFooterDefaultCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onFontFooterDefaultCheckBoxChanged) 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_override), u'main',
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_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),
@ -160,6 +164,7 @@ 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,
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),
@ -187,6 +192,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.parse(xml) self.theme.parse(xml)
self.theme.extend_image_filename(self.path) self.theme.extend_image_filename(self.path)
self.thememanager.cleanTheme(self.theme) self.thememanager.cleanTheme(self.theme)
# Stop the initial screen setup generating 1 preview per field!
self.allowPreview = False self.allowPreview = False
self.paintUi(self.theme) self.paintUi(self.theme)
self.allowPreview = True self.allowPreview = True
@ -252,6 +258,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
self.FontMainHeightSpinBox.setValue(int( \ self.FontMainHeightSpinBox.setValue(int( \
self.theme.font_main_height)) self.theme.font_main_height))
self.FontMainLineSpacingSpinBox.setValue(int( \
self.theme.font_main_indentation))
self.stateChanging(self.theme) self.stateChanging(self.theme)
self.previewTheme(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.theme.font_main_width = self.FontMainWidthSpinBox.value()
self.previewTheme(self.theme) 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): def onFontMainHeightSpinBoxChanged(self):
if self.theme.font_main_height != self.FontMainHeightSpinBox.value(): if self.theme.font_main_height != self.FontMainHeightSpinBox.value():
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) self.FontMainWeightComboBox.setCurrentIndex(2)
else: else:
self.FontMainWeightComboBox.setCurrentIndex(3) self.FontMainWeightComboBox.setCurrentIndex(3)
self.FontMainLineSpacingSpinBox.setValue(int(self.theme.font_main_indentation))
self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) self.FontMainXSpinBox.setValue(int(self.theme.font_main_x))
self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) self.FontMainYSpinBox.setValue(int(self.theme.font_main_y))
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
@ -653,5 +666,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def previewTheme(self, theme): def previewTheme(self, theme):
if self.allowPreview: 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) frame = self.thememanager.generateImage(theme)
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) 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_color = theme.font_main_color.strip()
theme.font_main_height = theme.font_main_height.strip() theme.font_main_height = theme.font_main_height.strip()
theme.font_main_italics = str_to_bool(theme.font_main_italics) 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_name = theme.font_main_name.strip()
#theme.font_main_override #theme.font_main_override
theme.font_main_proportion = theme.font_main_proportion.strip() theme.font_main_proportion = theme.font_main_proportion.strip()

View File

@ -17,7 +17,7 @@
<string>Theme Maintance</string> <string>Theme Maintance</string>
</property> </property>
<property name="windowIcon"> <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> <normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property> </property>
<property name="modal"> <property name="modal">
@ -64,7 +64,7 @@
<item> <item>
<widget class="QTabWidget" name="ThemeTabWidget"> <widget class="QTabWidget" name="ThemeTabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="BackgroundTab"> <widget class="QWidget" name="BackgroundTab">
<attribute name="title"> <attribute name="title">
@ -312,15 +312,32 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="value">
<number>16</number>
</property>
<property name="suffix"> <property name="suffix">
<string>pt</string> <string>pt</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>999</number> <number>999</number>
</property> </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> </widget>
</item> </item>
</layout> </layout>
@ -425,15 +442,15 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="value">
<number>0</number>
</property>
<property name="suffix"> <property name="suffix">
<string>px</string> <string>px</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>9999</number> <number>9999</number>
</property> </property>
<property name="value">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
@ -609,15 +626,15 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="value">
<number>10</number>
</property>
<property name="suffix"> <property name="suffix">
<string>pt</string> <string>pt</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>999</number> <number>999</number>
</property> </property>
<property name="value">
<number>10</number>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -728,15 +745,15 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="value">
<number>0</number>
</property>
<property name="suffix"> <property name="suffix">
<string>px</string> <string>px</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>9999</number> <number>9999</number>
</property> </property>
<property name="value">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
@ -753,15 +770,15 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="value">
<number>0</number>
</property>
<property name="suffix"> <property name="suffix">
<string>px</string> <string>px</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>9999</number> <number>9999</number>
</property> </property>
<property name="value">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">