示例#1
0
def drag_icon(self, cover, multiple):
    cover = cover.scaledToHeight(120, Qt.SmoothTransformation)
    if multiple:
        base_width = cover.width()
        base_height = cover.height()
        base = QImage(base_width+21, base_height+21,
                QImage.Format_ARGB32_Premultiplied)
        base.fill(QColor(255, 255, 255, 0).rgba())
        p = QPainter(base)
        rect = QRect(20, 0, base_width, base_height)
        p.fillRect(rect, QColor('white'))
        p.drawRect(rect)
        rect.moveLeft(10)
        rect.moveTop(10)
        p.fillRect(rect, QColor('white'))
        p.drawRect(rect)
        rect.moveLeft(0)
        rect.moveTop(20)
        p.fillRect(rect, QColor('white'))
        p.save()
        p.setCompositionMode(p.CompositionMode_SourceAtop)
        p.drawImage(rect.topLeft(), cover)
        p.restore()
        p.drawRect(rect)
        p.end()
        cover = base
    return QPixmap.fromImage(cover)
示例#2
0
def drag_icon(self, cover, multiple):
    cover = cover.scaledToHeight(120, Qt.SmoothTransformation)
    if multiple:
        base_width = cover.width()
        base_height = cover.height()
        base = QImage(base_width+21, base_height+21,
                QImage.Format_ARGB32_Premultiplied)
        base.fill(QColor(255, 255, 255, 0).rgba())
        p = QPainter(base)
        rect = QRect(20, 0, base_width, base_height)
        p.fillRect(rect, QColor('white'))
        p.drawRect(rect)
        rect.moveLeft(10)
        rect.moveTop(10)
        p.fillRect(rect, QColor('white'))
        p.drawRect(rect)
        rect.moveLeft(0)
        rect.moveTop(20)
        p.fillRect(rect, QColor('white'))
        p.save()
        p.setCompositionMode(p.CompositionMode_SourceAtop)
        p.drawImage(rect.topLeft(), cover)
        p.restore()
        p.drawRect(rect)
        p.end()
        cover = base
    return QPixmap.fromImage(cover)
示例#3
0
    def paintEvent(self, event):
        '''
        @param: event QPaintEvent
        '''
        if not self._use_background:
            return

        painter = QPainter(self)

        rect = self._side_widget.rect().adjusted(0, 0, 1, 0)
        rect = self.style().visualRect(self.layoutDirection(), self.geometry(),
                                       rect)
        styleHelper.verticalGradient(painter, rect, rect)

        if not self._background_pixmap.isNull():
            pixmap_rect = QRect(self._background_pixmap.rect())
            pixmap_rect.moveTo(rect.topLeft())

            while pixmap_rect.top() < rect.bottom():
                source_rect = QRect(pixmap_rect.intersected(rect))
                source_rect.moveTo(0, 0)
                painter.drawPixmap(pixmap_rect.topLeft(),
                                   self._background_pixmap, source_rect)
                pixmap_rect.moveTop(pixmap_rect.bottom() - 10)

        painter.setPen(styleHelper.borderColor())
        painter.drawLine(rect.topRight(), rect.bottomRight())

        # QColor
        light = styleHelper.sidebarHighlight()
        painter.setPen(light)
        painter.drawLine(rect.bottomLeft(), rect.bottomRight())
示例#4
0
 def calculate_rects(self):
     rect = self.rect()
     self.spinner_rect = r = QRect(0, 0, 96, 96)
     r.moveCenter(rect.center() - QPoint(0, r.height() // 2))
     r = QRect(r)
     r.moveTop(r.center().y() + 20 + r.height() // 2)
     r.setLeft(0), r.setRight(self.width())
     self.label.setGeometry(r)
示例#5
0
 def paint_emblems(self, painter, rect, emblems):
     gutter = self.emblem_size + self.MARGIN
     grect = QRect(rect)
     gpos = self.gutter_position
     if gpos is self.TOP:
         grect.setBottom(grect.top() + gutter)
         rect.setTop(rect.top() + gutter)
     elif gpos is self.BOTTOM:
         grect.setTop(grect.bottom() - gutter + self.MARGIN)
         rect.setBottom(rect.bottom() - gutter)
     elif gpos is self.LEFT:
         grect.setRight(grect.left() + gutter)
         rect.setLeft(rect.left() + gutter)
     else:
         grect.setLeft(grect.right() - gutter + self.MARGIN)
         rect.setRight(rect.right() - gutter)
     horizontal = gpos in (self.TOP, self.BOTTOM)
     painter.save()
     painter.setClipRect(grect)
     try:
         for i, emblem in enumerate(emblems):
             delta = 0 if i == 0 else self.emblem_size + self.MARGIN
             grect.moveLeft(grect.left() + delta) if horizontal else grect.moveTop(grect.top() + delta)
             rect = QRect(grect)
             rect.setWidth(int(emblem.width() / emblem.devicePixelRatio())), rect.setHeight(int(emblem.height() / emblem.devicePixelRatio()))
             painter.drawPixmap(rect, emblem)
     finally:
         painter.restore()
示例#6
0
 def paint_emblems(self, painter, rect, emblems):
     gutter = self.emblem_size + self.MARGIN
     grect = QRect(rect)
     gpos = self.gutter_position
     if gpos is self.TOP:
         grect.setBottom(grect.top() + gutter)
         rect.setTop(rect.top() + gutter)
     elif gpos is self.BOTTOM:
         grect.setTop(grect.bottom() - gutter + self.MARGIN)
         rect.setBottom(rect.bottom() - gutter)
     elif gpos is self.LEFT:
         grect.setRight(grect.left() + gutter)
         rect.setLeft(rect.left() + gutter)
     else:
         grect.setLeft(grect.right() - gutter + self.MARGIN)
         rect.setRight(rect.right() - gutter)
     horizontal = gpos in (self.TOP, self.BOTTOM)
     painter.save()
     painter.setClipRect(grect)
     try:
         for i, emblem in enumerate(emblems):
             delta = 0 if i == 0 else self.emblem_size + self.MARGIN
             grect.moveLeft(grect.left() + delta) if horizontal else grect.moveTop(grect.top() + delta)
             rect = QRect(grect)
             rect.setWidth(int(emblem.width() / emblem.devicePixelRatio())), rect.setHeight(int(emblem.height() / emblem.devicePixelRatio()))
             painter.drawPixmap(rect, emblem)
     finally:
         painter.restore()