~wgrant/openlp/openlyrics_test

« back to all changes in this revision

Viewing changes to openlp/core/ui/thememanager.py

  • Committer: Martin Zibricky
  • Date: 2011-10-06 16:16:29 UTC
  • mfrom: (1186.2.584 openlp)
  • Revision ID: mzibr.public@gmail.com-20111006161629-17tyvvq60h3h15dd
[merge] r1770, rename testing dir to tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \
38
38
    Receiver, SettingsManager, translate, check_item_selected, \
39
 
    check_directory_exists
 
39
    check_directory_exists, create_thumb, validate_thumb
40
40
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
41
41
    BackgroundGradientType
42
42
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
359
359
            The theme to delete.
360
360
        """
361
361
        self.themelist.remove(theme)
362
 
        thumb = theme + u'.png'
 
362
        thumb = u'%s.png' % theme
363
363
        delete_file(os.path.join(self.path, thumb))
364
364
        delete_file(os.path.join(self.thumbPath, thumb))
365
365
        try:
473
473
                    name = textName
474
474
                thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
475
475
                item_name = QtGui.QListWidgetItem(name)
476
 
                if os.path.exists(thumb):
 
476
                if validate_thumb(theme, thumb):
477
477
                    icon = build_icon(thumb)
478
478
                else:
479
 
                    icon = build_icon(theme)
480
 
                    pixmap = icon.pixmap(QtCore.QSize(88, 50))
481
 
                    pixmap.save(thumb, u'png')
 
479
                    icon = create_thumb(theme, thumb)
482
480
                item_name.setIcon(icon)
483
 
                item_name.setData(QtCore.Qt.UserRole,
484
 
                    QtCore.QVariant(textName))
 
481
                item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName))
485
482
                self.themeListWidget.addItem(item_name)
486
483
                self.themelist.append(textName)
487
484
        self._pushThemes()
658
655
            os.unlink(samplepathname)
659
656
        frame.save(samplepathname, u'png')
660
657
        thumb = os.path.join(self.thumbPath, u'%s.png' % name)
661
 
        icon = build_icon(frame)
662
 
        pixmap = icon.pixmap(QtCore.QSize(88, 50))
663
 
        pixmap.save(thumb, u'png')
 
658
        create_thumb(samplepathname, thumb, False)
664
659
        log.debug(u'Theme image written to %s', samplepathname)
665
660
 
666
661
    def updatePreviewImages(self):