Ejemplo n.º 1
0
    def start(self):
        '''Starts update state.
        '''
        self._vertScrollBar.valueChanged.connect(self.startThumbnailGen)
        self._timer.start(15)

        if cfg.verbose:
            utils.info('Updating Started')
Ejemplo n.º 2
0
    def stop(self):
        '''Stops update state.
        '''
        self._vertScrollBar.valueChanged.disconnect(self.startThumbnailGen)
        self._timer.stop()

        if cfg.verbose:
            utils.info('Updating Completed')
Ejemplo n.º 3
0
    def updateVisibleItems(self):
        '''Refreshes the list and trys to update items icons
        for thumbnails that exist.
        '''
        # Stop updating if all items have been processed.
        if len(self._processed) == len(self._itemCache):
            self.stop()
            return

        # Process all visible items
        visibleItems = self.getVisibleItems()
        for row in sorted(visibleItems.keys()):

            if row not in self._processed:
                item = visibleItems[row]
                tp = item.data(32)

                thumbnailPixmap = QtGui.QPixmap()
                thumbnailPixmap.load(tp.thumbnailPath)

                if not thumbnailPixmap.isNull():

                    # Composite background on images with alphas
                    if thumbnailPixmap.hasAlphaChannel():

                        bgBrush = QtGui.QBrush()
                        bgBrush.setStyle(QtCore.Qt.TexturePattern)
                        bgBrush.setTexture(
                            QtGui.QPixmap(
                                utils.getMariIconPath('Checker.png')))
                        bgPen = QtGui.QPen()
                        bgPen.setColor(QtCore.Qt.transparent)
                        bgPen.setWidth(0)
                        thumbnailPixmapWithBg = QtGui.QPixmap(
                            cfg.max_size, cfg.max_size)
                        thumbnailPixmapWithBg.fill(QtCore.Qt.transparent)

                        painter = QtGui.QPainter()
                        painter.begin(thumbnailPixmapWithBg)
                        painter.setBrush(bgBrush)
                        painter.setPen(bgPen)
                        painter.setOpacity(0.2)
                        painter.drawRect(
                            QtCore.QRectF(0.0, 0.0, float(cfg.max_size),
                                          float(cfg.max_size)))
                        painter.setOpacity(1.0)
                        painter.drawPixmap(
                            (cfg.max_size / 2) - (thumbnailPixmap.width() / 2),
                            0, thumbnailPixmap)
                        painter.end()
                        thumbnailPixmap = thumbnailPixmapWithBg

                    # Set Icon
                    item.setIcon(QtGui.QIcon(thumbnailPixmap))
                    self._processed.add(row)

                    if cfg.verbose:
                        utils.info('Completed Update for %s' % tp.sourceName)
Ejemplo n.º 4
0
    def createItems(self, tpList):
        '''Create items from list of thumbnail property.
        '''
        self.resetAll()

        if tpList:
            for tp in tpList:
                self.createItem(tp)

            if cfg.verbose:
                utils.info('Found %d viable items' % len(tpList))

            self.start()
Ejemplo n.º 5
0
    def startThumbnailGen(self):
        '''Starts updating visible qlistwidget items.
        '''
        visibleItems = self.getVisibleItems()
        thumbnailToProcess = []

        for row in sorted(visibleItems.keys()):
            item = visibleItems[row]
            tp = item.data(32)
            if not tp.isCurrent and row not in self._seen:
                thumbnailToProcess.append(tp)
                self._seen.add(row)

        # Start conversion thread
        if thumbnailToProcess:
            core.startConvert(thumbnailToProcess)

            if cfg.verbose:
                utils.info('Processing %d items' % len(thumbnailToProcess))