Esempio n. 1
0
    def __init__(self,
                 txt='',
                 font_size=12,
                 set_bold=False,
                 color=QtGui.QColor(255, 255, 255),
                 pm_node=False):
        super(StandardItem, self).__init__()

        fnt = QtGui.QFont("Open Sans", font_size)
        fnt.setBold(set_bold)

        self.setEditable(False)
        self.setForeground(color)
        self.setFont(fnt)
        self.setText(txt)
        self.pm_node = pm_node
Esempio n. 2
0
    def __drawTriangle(self, painter, x, y):
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 160),
                             QtCore.Qt.SolidPattern)
        if not self.isCollapsed():
            tl, tr, tp = (QtCore.QPoint(x + 9,
                                        y + 8), QtCore.QPoint(x + 19, y + 8),
                          QtCore.QPoint(x + 14, y + 13.0))
            points = [tl, tr, tp]
            triangle = QtGui.QPolygon(points)
        else:
            tl, tr, tp = QtCore.QPoint(x + 11, y + 6), QtCore.QPoint(
                x + 16, y + 11), QtCore.QPoint(x + 11, y + 16.0)
            points = [tl, tr, tp]
            triangle = QtGui.QPolygon(points)

        currentBrush = painter.brush()
        painter.setBrush(brush)
        painter.drawPolygon(triangle)
        painter.setBrush(currentBrush)
Esempio n. 3
0
    def paintEvent(self, event):
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(painter.Antialiasing)
        font = painter.font()
        font.setBold(True)
        painter.setFont(font)

        x = self.rect().x()
        y = self.rect().y()
        w = self.rect().width() - 1
        h = self.rect().height() - 1
        r = 8

        # draw a rounded style
        if self._rolloutStyle == 2:
            # draw the text
            painter.drawText(x + 33, y + 3, w, 16,
                             QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop,
                             self.title())

            # draw the triangle
            self.__drawTriangle(painter, x, y)

            # draw the borders
            pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light))
            pen.setWidthF(0.6)
            painter.setPen(pen)

            painter.drawRoundedRect(x + 1, y + 1, w - 1, h - 1, r, r)

            pen.setColor(self.palette().color(QtGui.QPalette.Shadow))
            painter.setPen(pen)

            painter.drawRoundedRect(x, y, w - 1, h - 1, r, r)

        # draw a square style
        if self._rolloutStyle == 3:
            # draw the text
            painter.drawText(x + 33, y + 3, w, 16,
                             QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop,
                             self.title())

            self.__drawTriangle(painter, x, y)

            # draw the borders
            pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light))
            pen.setWidthF(0.6)
            painter.setPen(pen)

            painter.drawRect(x + 1, y + 1, w - 1, h - 1)

            pen.setColor(self.palette().color(QtGui.QPalette.Shadow))
            painter.setPen(pen)

            painter.drawRect(x, y, w - 1, h - 1)

        # draw a Maya style
        if self._rolloutStyle == 4:
            # draw the text
            painter.drawText(x + 33, y + 3, w, 16,
                             QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop,
                             self.title())

            painter.setRenderHint(QtGui.QPainter.Antialiasing, False)

            self.__drawTriangle(painter, x, y)

            # draw the borders - top
            headerHeight = 20

            headerRect = QtCore.QRect(x + 1, y + 1, w - 1, headerHeight)
            headerRectShadow = QtCore.QRect(x - 1, y - 1, w + 1,
                                            headerHeight + 2)

            # Highlight
            pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light))
            pen.setWidthF(0.4)
            painter.setPen(pen)

            painter.drawRect(headerRect)
            painter.fillRect(headerRect, QtGui.QColor(255, 255, 255, 18))

            # Shadow
            pen.setColor(self.palette().color(QtGui.QPalette.Dark))
            painter.setPen(pen)
            painter.drawRect(headerRectShadow)

            if not self.isCollapsed():
                # draw the lover border
                pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Dark))
                pen.setWidthF(0.8)
                painter.setPen(pen)

                offSet = headerHeight + 3
                bodyRect = QtCore.QRect(x, y + offSet, w, h - offSet)
                bodyRectShadow = QtCore.QRect(x + 1, y + offSet, w + 1,
                                              h - offSet + 1)
                painter.drawRect(bodyRect)

                pen.setColor(self.palette().color(QtGui.QPalette.Light))
                pen.setWidthF(0.4)
                painter.setPen(pen)

                painter.drawRect(bodyRectShadow)

        # draw a boxed style
        elif self._rolloutStyle == 1:
            if self.isCollapsed():
                arect = QtCore.QRect(x + 1, y + 9, w - 1, 4)
                brect = QtCore.QRect(x, y + 8, w - 1, 4)
                text = '+'
            else:
                arect = QtCore.QRect(x + 1, y + 9, w - 1, h - 9)
                brect = QtCore.QRect(x, y + 8, w - 1, h - 9)
                text = '-'

            # draw the borders
            pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light))
            pen.setWidthF(0.6)
            painter.setPen(pen)

            painter.drawRect(arect)

            pen.setColor(self.palette().color(QtGui.QPalette.Shadow))
            painter.setPen(pen)

            painter.drawRect(brect)

            painter.setRenderHint(painter.Antialiasing, False)
            painter.setBrush(self.palette().color(
                QtGui.QPalette.Window).darker(120))
            painter.drawRect(x + 10, y + 1, w - 20, 16)
            painter.drawText(x + 16, y + 1, w - 32, 16,
                             QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter,
                             text)
            painter.drawText(x + 10, y + 1, w - 20, 16, QtCore.Qt.AlignCenter,
                             self.title())

        if self.dragDropMode():
            rect = self.dragDropRect()

            # draw the lines
            l = rect.left()
            r = rect.right()
            cy = rect.center().y()

            for y in (cy - 3, cy, cy + 3):
                painter.drawLine(l, y, r, y)

        painter.end()