From a29ea3f8616262eea3cb29d6d1245ed01fdf3c22 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 24 Apr 2010 08:21:35 +0100 Subject: [PATCH] Add line spacing adjustment to renderer Remove .thumbnail directories --- openlp.pyw | 10 ++-------- openlp/core/lib/renderer.py | 23 +++++++++++++---------- openlp/core/lib/themexmlhandler.py | 8 ++++++-- openlp/core/ui/amendthemedialog.py | 15 ++++++++++++--- openlp/core/ui/amendthemeform.py | 20 +++++++++++++++++--- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- 7 files changed, 52 insertions(+), 28 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 0f546261f..5cbfea1df 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -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() \ No newline at end of file + main() diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index beec5389c..43db25d64 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -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): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index c30184328..a96cc7355 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -53,6 +53,7 @@ blankthemexml=\ Normal False 0 + 0 @@ -62,6 +63,7 @@ blankthemexml=\ Normal False 0 + 0 @@ -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') diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 65d675cd1..438542192 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -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')) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 03c2df3f5..c43d27cb5 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -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)) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a651c6211..247dd8394 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -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 diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 914a6ce20..9c19c8122 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -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))