コード例 #1
0
ファイル: popup.py プロジェクト: kovidgoyal/vise
 def paint_background(self, painter):
     br = 12  # border_radius
     bw = 1  # border_width
     c = QColor('#fdfd96')
     p = QPainterPath()
     p.addRoundedRect(QRectF(self.rect()), br, br)
     painter.fillPath(p, c)
     p.addRoundedRect(QRectF(self.rect()).adjusted(bw, bw, -bw, -bw), br, br)
     painter.fillPath(p, QColor('black'))
コード例 #2
0
ファイル: tab_tree.py プロジェクト: joanma100/vise
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     hovering = index.data(HOVER_ROLE) is True
     painter.save()
     rect = option.rect
     is_current = index.data(Qt.FontRole) is not None
     if not hovering and is_current:
         qpp = QPainterPath()
         qpp.addRoundedRect(QRectF(rect), 6, 6)
         painter.fillPath(qpp, self.current_background)
     icon_rect = QRect(rect.left() + self.MARGIN, rect.top() + self.MARGIN, ICON_SIZE, ICON_SIZE)
     left = icon_rect.right() + 2 * self.MARGIN
     text_rect = QRect(left, icon_rect.top(), rect.width() - left + rect.left(), icon_rect.height())
     mark = index.data(MARK_ROLE)
     if hovering or mark:
         text_rect.adjust(0, 0, -text_rect.height(), 0)
     text = index.data(DISPLAY_ROLE) or ''
     font = index.data(Qt.FontRole)
     if font:
         painter.setFont(font)
     text_flags = Qt.AlignVCenter | Qt.AlignLeft | Qt.TextSingleLine
     text = elided_text(text, font, text_rect.width(), 'right')
     if option.state & QStyle.State_Selected:
         painter.setPen(QPen(self.highlighted_text))
     painter.drawText(text_rect, text_flags, text)
     if mark:
         hrect = QRect(text_rect.right(), text_rect.top(), text_rect.height(), text_rect.height())
         painter.fillRect(hrect, QColor('#ffffaa'))
         painter.drawText(hrect, Qt.AlignCenter, mark)
     elif hovering:
         hrect = QRect(text_rect.right(), text_rect.top(), text_rect.height(), text_rect.height())
         close_hover = index.data(CLOSE_HOVER_ROLE) is True
         if close_hover:
             pen = painter.pen()
             pen.setColor(QColor('red'))
             painter.setPen(pen)
         painter.drawText(hrect, Qt.AlignCenter, '✖ ')
     if index.data(LOADING_ROLE):
         if not self.errored_out:
             angle = index.data(ANGLE_ROLE)
             try:
                 draw_snake_spinner(painter, icon_rect, angle, self.light, self.dark)
             except Exception:
                 import traceback
                 traceback.print_exc()
                 self.errored_out = True
     else:
         icurl = index.data(URL_ROLE)
         if icurl == WELCOME_URL:
             icon = welcome_icon()
         elif icurl == DOWNLOADS_URL:
             icon = downloads_icon()
         else:
             icon = index.data(DECORATION_ROLE)
         icon.paint(painter, icon_rect)
     painter.restore()
コード例 #3
0
 def paint_background(self, painter):
     br = 12  # border_radius
     bw = 1  # border_width
     c = QColor('#fdfd96')
     p = QPainterPath()
     p.addRoundedRect(QRectF(self.rect()), br, br)
     painter.fillPath(p, c)
     p.addRoundedRect(
         QRectF(self.rect()).adjusted(bw, bw, -bw, -bw), br, br)
     painter.fillPath(p, QColor('black'))
コード例 #4
0
ファイル: proceed.py プロジェクト: j-howell/calibre
 def paint_background(self, painter):
     br = 12  # border_radius
     bw = 1  # border_width
     pal = self.palette()
     c = pal.color(pal.Window)
     c.setAlphaF(0.9)
     p = QPainterPath()
     p.addRoundedRect(QRectF(self.rect()), br, br)
     painter.fillPath(p, c)
     p.addRoundedRect(QRectF(self.rect()).adjusted(bw, bw, -bw, -bw), br, br)
     painter.fillPath(p, pal.color(pal.WindowText))
コード例 #5
0
ファイル: proceed.py プロジェクト: yipeng0428/calibre
 def paint_background(self, painter):
     br = 12  # border_radius
     bw = 1  # border_width
     pal = self.palette()
     c = pal.color(QPalette.ColorRole.Window)
     c.setAlphaF(0.9)
     p = QPainterPath()
     p.addRoundedRect(QRectF(self.rect()), br, br)
     painter.fillPath(p, c)
     p.addRoundedRect(QRectF(self.rect()).adjusted(bw, bw, -bw, -bw), br, br)
     painter.fillPath(p, pal.color(QPalette.ColorRole.WindowText))
コード例 #6
0
ファイル: covers.py プロジェクト: artbycrunk/calibre
 def __call__(self, painter, rect, color_theme, title_block, subtitle_block, footer_block):
     painter.fillRect(rect, self.color1)
     r = QRect(0, int(title_block.position.y), rect.width(),
               title_block.height + subtitle_block.height + subtitle_block.line_spacing // 2 + title_block.leading)
     painter.save()
     p = QPainterPath()
     p.addRoundedRect(QRectF(r), 10, 10 * r.width()/r.height(), Qt.RelativeSize)
     painter.setClipPath(p)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.fillRect(r, self.color2)
     painter.restore()
     r = QRect(0, 0, int(title_block.position.x), rect.height())
     painter.fillRect(r, self.color2)
     return self.ccolor2, self.ccolor2, self.ccolor1
コード例 #7
0
 def __call__(self, painter, rect, color_theme, title_block, subtitle_block, footer_block):
     painter.fillRect(rect, self.color1)
     r = QRect(0, int(title_block.position.y), rect.width(),
               title_block.height + subtitle_block.height + subtitle_block.line_spacing // 2 + title_block.leading)
     painter.save()
     p = QPainterPath()
     p.addRoundedRect(QRectF(r), 10, 10 * r.width()/r.height(), Qt.RelativeSize)
     painter.setClipPath(p)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.fillRect(r, self.color2)
     painter.restore()
     r = QRect(0, 0, int(title_block.position.x), rect.height())
     painter.fillRect(r, self.color2)
     return self.ccolor2, self.ccolor2, self.ccolor1
コード例 #8
0
ファイル: project_list.py プロジェクト: MoonShineVFX/4drec
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.drawPixmap(0, 0, self._pixmap)
        painter.fillRect(self.rect(), self.palette().midlight().color())

        round_path = QPainterPath()
        round_path.addRoundedRect(0, 0, self.width(), self.height(), 5, 5)
        sq_path = QPainterPath()
        sq_path.addRect(0, 0, 10, self.height())
        draw_path = sq_path - round_path
        painter.setPen(Qt.NoPen)
        painter.setBrush(self.palette().dark().color())
        painter.drawPath(draw_path)
コード例 #9
0
    def _contour(self):
        """Returns contour path."""
        ppath = QPainterPath()
        rect = self.contentsRect()
        margin = 5
        ppath.addRoundedRect(rect.left() - margin, rect.top() - margin,
                             rect.width() + 2 * margin,
                             rect.height() + 2 * margin, 15, 15)

        arrowpath = QPainterPath()
        arrowpath.moveTo(rect.center().x(), self.height())
        arrowpath.lineTo(rect.center().x() - 10, rect.bottom())
        arrowpath.lineTo(rect.center().x() + 10, rect.bottom())
        arrowpath.lineTo(rect.center().x(), self.height())

        ppath = ppath.united(arrowpath)
        return ppath