← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugs into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugs into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Update theme code to handle lines per slide label.
Remove extra debugging as Author's now work for song loading from services.
-- 
https://code.launchpad.net/~trb143/openlp/bugs/+merge/41784
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bugs into lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2010-11-04 17:02:10 +0000
+++ openlp/core/lib/renderer.py	2010-11-24 19:58:09 +0000
@@ -32,7 +32,7 @@
 from PyQt4 import QtWebKit
 
 from openlp.core.lib import expand_tags, build_lyrics_format_css, \
-    build_lyrics_outline_css
+    build_lyrics_outline_css,  Receiver
 
 log = logging.getLogger(__name__)
 
@@ -92,13 +92,17 @@
             (build_lyrics_format_css(self._theme, self.page_width,
             self.page_height), build_lyrics_outline_css(self._theme))
 
-    def format_slide(self, words, line_break):
+    def format_slide(self, words, line_break, forcePage=False):
         """
         Figure out how much text can appear on a slide, using the current
         theme settings.
 
         ``words``
             The words to be fitted on the slide.
+
+        ``line_break``
+            Add line endings after each line of text used for bibles.
+
         """
         log.debug(u'format_slide - Start')
         line_end = u''
@@ -114,13 +118,19 @@
         formatted = []
         html_text = u''
         styled_text = u''
+        line_count = 0
         for line in text:
+            if line_count != -1:
+                line_count += 1
             styled_line = expand_tags(line) + line_end
             styled_text += styled_line
             html = self.page_shell + styled_text + u'</div></body></html>'
             self.web.setHtml(html)
             # Text too long so go to next page
             if self.web_frame.contentsSize().height() > self.page_height:
+                if forcePage and line_count > 0:
+                    Receiver.send_message(u'theme_line_count', line_count)
+                line_count = -1
                 if html_text.endswith(u'<br>'):
                     html_text = html_text[:len(html_text)-4]
                 formatted.append(html_text)

=== modified file 'openlp/core/lib/rendermanager.py'
--- openlp/core/lib/rendermanager.py	2010-10-23 17:37:10 +0000
+++ openlp/core/lib/rendermanager.py	2010-11-24 19:58:09 +0000
@@ -69,6 +69,7 @@
         self.override_background = None
         self.themedata = None
         self.alertTab = None
+        self.force_page = False
 
     def update_display(self):
         """
@@ -187,7 +188,7 @@
                 theme.font_footer_height - 1)
         self.renderer.set_text_rectangle(main_rect, footer_rect)
 
-    def generate_preview(self, themedata):
+    def generate_preview(self, themedata, forcePage=False):
         """
         Generate a preview of a theme.
 
@@ -195,6 +196,7 @@
             The theme to generated a preview for.
         """
         log.debug(u'generate preview')
+        self.force_page = forcePage
         # set the default image size for previews
         self.calculate_default(self.screens.preview[u'size'])
         verse = u'The Lord said to {r}Noah{/r}: \n' \
@@ -204,6 +206,9 @@
         'Get those children out of the muddy, muddy \n' \
         '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \
         'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
+        # make big page for theme edit dialog to get line count
+        if self.force_page:
+            verse = verse + verse + verse
         footer = []
         footer.append(u'Arky Arky (Unknown)' )
         footer.append(u'Public Domain')
@@ -215,12 +220,13 @@
         serviceItem.render_manager = self
         serviceItem.raw_footer = footer
         serviceItem.render(True)
-        self.display.buildHtml(serviceItem)
-        raw_html = serviceItem.get_rendered_frame(0)
-        preview = self.display.text(raw_html)
-        # Reset the real screen size for subsequent render requests
-        self.calculate_default(self.screens.current[u'size'])
-        return preview
+        if not self.force_page:
+            self.display.buildHtml(serviceItem)
+            raw_html = serviceItem.get_rendered_frame(0)
+            preview = self.display.text(raw_html)
+            # Reset the real screen size for subsequent render requests
+            self.calculate_default(self.screens.current[u'size'])
+            return preview
 
     def format_slide(self, words, line_break):
         """
@@ -228,9 +234,12 @@
 
         ``words``
             The words to go on the slides.
+
+        ``line_break``
+            Add line endings after each line of text used for bibles.
         """
         log.debug(u'format slide')
-        return self.renderer.format_slide(words, line_break)
+        return self.renderer.format_slide(words, line_break, self.force_page)
 
     def calculate_default(self, screen):
         """

=== modified file 'openlp/core/ui/themeform.py'
--- openlp/core/ui/themeform.py	2010-11-21 20:46:44 +0000
+++ openlp/core/ui/themeform.py	2010-11-24 19:58:09 +0000
@@ -29,7 +29,8 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate, BackgroundType, BackgroundGradientType
+from openlp.core.lib import translate, BackgroundType, BackgroundGradientType, \
+    Receiver
 from openlp.core.utils import get_images_filter
 from themewizard import Ui_ThemeWizard
 
@@ -96,10 +97,40 @@
         QtCore.QObject.connect(self,
             QtCore.SIGNAL(u'currentIdChanged(int)'),
             self.pageChanged)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'theme_line_count'),
+            self.updateLinesText)
+        QtCore.QObject.connect(self.mainSizeSpinBox,
+            QtCore.SIGNAL(u'valueChanged(int)'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.mainSizeSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.lineSpacingSpinBox,
+            QtCore.SIGNAL(u'valueChanged(int)'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.lineSpacingSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.outlineSizeSpinBox,
+            QtCore.SIGNAL(u'valueChanged(int)'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.outlineSizeSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.shadowSizeSpinBox,
+            QtCore.SIGNAL(u'valueChanged(int)'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.shadowSizeSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.calculateLines)
+        QtCore.QObject.connect(self.mainFontComboBox,
+            QtCore.SIGNAL(u'activated(int)'),
+            self.calculateLines)
 
     def pageChanged(self, pageId):
         """
-        Detects Page changes and updates.
+        Detects Page changes and updates as approprate.
         """
         if pageId == 6:
             self.updateTheme()
@@ -184,6 +215,22 @@
         self.backgroundPage.registerField(
             u'name', self.themeNameEdit)
 
+    def calculateLines(self):
+        """
+        Calculate the number of lines on a page by rendering text
+        """
+        # Do not trigger on start up
+        if self.page != 0:
+            self.updateTheme()
+            frame = self.thememanager.generateImage(self.theme, True)
+
+    def updateLinesText(self, lines):
+        """
+        Updates the lines on a page on the wizard
+        """
+        self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', \
+            '(%d lines per slide)' % int(lines))))
+
     def onOutlineCheckCheckBoxChanged(self, state):
         """
         Change state as Outline check box changed
@@ -194,6 +241,7 @@
             self.theme.font_main_outline = False
         self.outlineColorPushButton.setEnabled(self.theme.font_main_outline)
         self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
+        self.calculateLines()
 
     def onShadowCheckCheckBoxChanged(self, state):
         """
@@ -205,6 +253,7 @@
             self.theme.font_main_shadow = False
         self.shadowColorPushButton.setEnabled(self.theme.font_main_shadow)
         self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
+        self.calculateLines()
 
     def onMainDefaultPositionCheckBox(self, value):
         """
@@ -244,6 +293,7 @@
         Set up the pages for Initial run through dialog
         """
         log.debug(u'initializePage %s' % id)
+        self.page = id
         if id == 1:
             self.setBackgroundTabValues()
         elif id == 2:

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2010-11-20 16:36:54 +0000
+++ openlp/core/ui/thememanager.py	2010-11-24 19:58:09 +0000
@@ -729,7 +729,6 @@
 
     def generateAndSaveImage(self, dir, name, theme):
         log.debug(u'generateAndSaveImage %s %s', dir, name)
-        #theme = self.createThemeFromXml(theme_xml, dir)
         theme_xml = theme.extract_xml()
         frame = self.generateImage(theme)
         samplepathname = os.path.join(self.path, name + u'.png')
@@ -742,12 +741,12 @@
         pixmap.save(thumb, u'png')
         log.debug(u'Theme image written to %s', samplepathname)
 
-    def generateImage(self, themedata):
+    def generateImage(self, themedata, forcePage=False):
         """
         Call the RenderManager to build a Sample Image
         """
         log.debug(u'generateImage \n%s ', themedata)
-        return self.parent.RenderManager.generate_preview(themedata)
+        return self.parent.RenderManager.generate_preview(themedata, forcePage)
 
     def getPreviewImage(self, theme):
         """

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2010-11-22 18:52:58 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2010-11-24 19:58:09 +0000
@@ -415,17 +415,12 @@
             if search_results:
                 for song in search_results:
                     count = 0
-                    # temp debug to find why service items do not edit
-                    log.debug(u'author list %s' % author_list)
                     for author in song.authors:
-                        log.debug(u'author %s' % author.display_name)
                         if author.display_name in author_list:
                             count += 1
-                    log.debug(u'found %s : %s' % (count, len(author_list)))
                     if count == len(author_list):
                         editId = song.id
                         uuid = item._uuid
             if editId != 0:
                 Receiver.send_message(u'service_item_update',
                     u'%s:%s' %(editId, uuid))
-


Follow ups