From 47936e34a74c2afbc5311cb258c53bed40a2688f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 3 Jun 2011 17:57:56 +0200 Subject: [PATCH 1/6] improved thumbnail creation speed --- openlp/core/lib/mediamanageritem.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 31890a252..0f6c24829 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -391,21 +391,23 @@ class MediaManagerItem(QtGui.QWidget): self.iconFromFile(image, thumb) return True - def iconFromFile(self, image, thumb): + def iconFromFile(self, image_path, thumb_path): """ Create a thumbnail icon from a given image. - ``image`` + ``image_path`` The image file to create the icon from. - ``thumb`` - The filename to save the thumbnail to + ``thumb_path`` + The filename to save the thumbnail to. """ - icon = build_icon(unicode(image)) - pixmap = icon.pixmap(QtCore.QSize(88, 50)) - ext = os.path.splitext(thumb)[1].lower() - pixmap.save(thumb, ext[1:]) - return icon + ext = os.path.splitext(thumb_path)[1].lower() + reader = QtGui.QImageReader(image_path) + reader.setScaledSize(QtCore.QSize( + reader.size().width() / reader.size().height() * 88, 88)) + thumb = reader.read() + thumb.save(thumb_path, ext[1:]) + return build_icon(unicode(thumb_path)) def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' From e08c65aa45ee047074bae86726711017ed33ea8d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 5 Jun 2011 18:33:28 +0200 Subject: [PATCH 2/6] fixed ratio --- openlp/core/lib/mediamanageritem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 0f6c24829..954179288 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -403,8 +403,8 @@ class MediaManagerItem(QtGui.QWidget): """ ext = os.path.splitext(thumb_path)[1].lower() reader = QtGui.QImageReader(image_path) - reader.setScaledSize(QtCore.QSize( - reader.size().width() / reader.size().height() * 88, 88)) + ratio = float(reader.size().width()) / float(reader.size().height()) + reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) thumb = reader.read() thumb.save(thumb_path, ext[1:]) return build_icon(unicode(thumb_path)) From b5810b271ef25f7459762d786ce86b00b8b3614c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 08:03:06 +0200 Subject: [PATCH 3/6] fixed bug #788770 --- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bd84e2bb5..d94368f52 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -772,7 +772,7 @@ class BibleMediaItem(MediaManagerItem): log.exception(u'The second_search_results does not have as ' 'many verses as the search_results.') break - bible_text = u' %s %d%s%d (%s, %s)' % (verse.book.name, + bible_text = u'%s %d%s%d (%s, %s)' % (verse.book.name, verse.chapter, verse_separator, verse.verse, version, second_version) else: @@ -830,7 +830,7 @@ class BibleMediaItem(MediaManagerItem): bible_text = u'' # If we are 'Verse Per Line' then force a new line. elif self.settings.layout_style == LayoutStyle.VersePerLine: - bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) + bible_text = u'%s%s %s\n' % (bible_text, verse_text, text) # We have to be 'Continuous'. else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) From 98e731ee9a340040ac6230779ce72d501a19ed34 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 09:05:10 +0200 Subject: [PATCH 4/6] fallback if thumb was not created --- openlp/core/lib/mediamanageritem.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 954179288..9aa159981 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -407,7 +407,11 @@ class MediaManagerItem(QtGui.QWidget): reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) thumb = reader.read() thumb.save(thumb_path, ext[1:]) - return build_icon(unicode(thumb_path)) + if os.path.exists(thumb_path): + return build_icon(unicode(thumb_path)) + # When the thumbnail creation was not successful then create the icon + # from the original file. + return build_icon(unicode(image_path)) def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' From 6047dd9f5b75b98bb000c7125d95dd9a6acc63ab Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 16:17:39 +0200 Subject: [PATCH 5/6] fixed bug 793537 Fixes: https://launchpad.net/bugs/793537 --- openlp/core/ui/screen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 160080c5a..b970158b2 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -106,7 +106,7 @@ class ScreenList(object): """ # Do not log at start up. if changed_screen != -1: - log.info(u'screen_count_changed %d' % number) + log.info(u'screen_count_changed %d' % self.desktop.numScreens()) # Remove unplugged screens. for screen in copy.deepcopy(self.screen_list): if screen[u'number'] == self.desktop.numScreens(): From 5d9e6acfbf1aa916bfc9ea7e606d3e0ddd5fa03a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 16:58:14 +0200 Subject: [PATCH 6/6] better comment --- openlp/core/lib/mediamanageritem.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9aa159981..cfd4948cb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -409,8 +409,7 @@ class MediaManagerItem(QtGui.QWidget): thumb.save(thumb_path, ext[1:]) if os.path.exists(thumb_path): return build_icon(unicode(thumb_path)) - # When the thumbnail creation was not successful then create the icon - # from the original file. + # Fallback for files with animation support. return build_icon(unicode(image_path)) def loadList(self, list):