From af3f69afcecef4cc7e438f22b22c7a8785703ff8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 21 Jan 2010 19:41:17 +0000 Subject: [PATCH] Finish off Theme thumbnail performance improvements --- openlp/core/ui/thememanager.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index d4ab42432..4e5460b0a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -108,6 +108,9 @@ 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') + print self.thumbPath + self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up self.config = PluginConfig(u'themes') @@ -185,7 +188,7 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.takeItem(row) try: os.remove(os.path.join(self.path, th)) - os.remove(os.path.join(self.path, u'thumbs', th)) + os.remove(os.path.join(self.thumbPath, th)) shutil.rmtree(os.path.join(self.path, theme)) except: #if not present do not worry @@ -260,15 +263,14 @@ class ThemeManager(QtGui.QWidget): self.trUtf8('default')) else: name = textName - thumb = os.path.join(self.path, u'thumbs', u'%s.png' %textName) + thumb = os.path.join(self.thumbPath, u'%s.png' % textName) item_name = QtGui.QListWidgetItem(name) if os.path.exists(thumb): icon = build_icon(thumb) else: icon = build_icon(theme) pixmap = icon.pixmap(QtCore.QSize(88,50)) - ext = os.path.splitext(thumb)[1].lower() - pixmap.save(thumb, ext[1:]) + pixmap.save(thumb, u'png') item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName)) @@ -455,6 +457,10 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(samplepathname): os.unlink(samplepathname) frame.save(samplepathname, u'png') + thumb = os.path.join(self.thumbPath, u'%s.png' % name) + icon = build_icon(frame) + pixmap = icon.pixmap(QtCore.QSize(88,50)) + pixmap.save(thumb, u'png') log.debug(u'Theme image written to %s', samplepathname) def generateImage(self, themedata):