forked from openlp/openlp
Finish off Theme thumbnail performance improvements
This commit is contained in:
parent
a69ba0a151
commit
af3f69afce
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user