From a69ba0a151b0e83fcfa1937335167195fb43fffa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 18 Jan 2010 19:56:02 +0000 Subject: [PATCH] Fix themes loading performance by storing small icons. --- openlp/core/ui/thememanager.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index fd0284412..d4ab42432 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -185,6 +185,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)) shutil.rmtree(os.path.join(self.path, theme)) except: #if not present do not worry @@ -259,8 +260,16 @@ class ThemeManager(QtGui.QWidget): self.trUtf8('default')) else: name = textName + thumb = os.path.join(self.path, u'thumbs', u'%s.png' %textName) item_name = QtGui.QListWidgetItem(name) - item_name.setIcon(build_icon(theme)) + 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:]) + item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName)) self.ThemeListWidget.addItem(item_name) @@ -427,8 +436,6 @@ class ThemeManager(QtGui.QWidget): if outfile: outfile.close() if image_from and image_from != image_to: - print "if", image_from - print "it", image_to try: shutil.copyfile(image_from, image_to) except: @@ -529,4 +536,4 @@ class ThemeManager(QtGui.QWidget): theme.font_main_y = int(theme.font_main_y.strip()) #theme.theme_mode theme.theme_name = theme.theme_name.strip() - #theme.theme_version \ No newline at end of file + #theme.theme_version