def __init__(self, title=None):
		super(TitleWidget, self).__init__()

		if sys.platform.startswith("darwin"):
			color1 = QColor(230, 230, 230, 255)
			color2 = QColor(177, 177, 177, 255)

			gradient = QLinearGradient()
			gradient.setStart(0, 0)
			gradient.setFinalStop(0, TitleWidget.TitleHeight)
			gradient.setColorAt(0, color1)
			gradient.setColorAt(1, color2)

			brush = QBrush(gradient)
			palette = QPalette()
			palette.setBrush(QPalette.Background, brush)
			self.setPalette(palette)
			self.setAutoFillBackground(True)

		self.setMaximumHeight(TitleWidget.TitleHeight)
		self.setMinimumHeight(TitleWidget.TitleHeight)

		self.titleLabel = QLabel("", parent=self)
		font = self.titleLabel.font()
		font.setPixelSize(11)
		self.titleLabel.setFont(font)
		self.titleLabel.setAlignment(Qt.AlignCenter)
		self.titleLabel.setText(title)

		layout = QVBoxLayout()
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.titleLabel)
		self.setLayout(layout)
Ejemplo n.º 2
0
    def drawSpan(self, painter, rect):
        opt = QStyleOptionSlider()
        QSlider.initStyleOption(self, opt)

        # area
        groove = self.style().subControlRect(QStyle.CC_Slider, opt,
                                             QStyle.SC_SliderGroove, self)
        if opt.orientation == QtCore.Qt.Horizontal:
            groove.adjust(0, 0, -1, 0)
        else:
            groove.adjust(0, 0, 0, -1)

        # pen & brush
        painter.setPen(QPen(self.gradientLeftColor, 0))
        if opt.orientation == QtCore.Qt.Horizontal:
            self.setupPainter(painter, opt.orientation,
                              groove.center().x(), groove.top(),
                              groove.center().x(), groove.bottom())
        else:
            self.setupPainter(painter, opt.orientation, groove.left(),
                              groove.center().y(), groove.right(),
                              groove.center().y())

        # draw groove
        intersected = QtCore.QRectF(rect.intersected(groove))
        gradient = QLinearGradient(intersected.topLeft(),
                                   intersected.topRight())
        gradient.setColorAt(0, self.gradientLeft)
        gradient.setColorAt(1, self.gradientRight)
        painter.fillRect(intersected, gradient)
Ejemplo n.º 3
0
    def __init__(self, title=None):
        super(TitleWidget, self).__init__()

        if sys.platform.startswith("darwin"):
            color1 = QColor(230, 230, 230, 255)
            color2 = QColor(177, 177, 177, 255)

            gradient = QLinearGradient()
            gradient.setStart(0, 0)
            gradient.setFinalStop(0, TitleWidget.TitleHeight)
            gradient.setColorAt(0, color1)
            gradient.setColorAt(1, color2)

            brush = QBrush(gradient)
            palette = QPalette()
            palette.setBrush(QPalette.Background, brush)
            self.setPalette(palette)
            self.setAutoFillBackground(True)

        self.setMaximumHeight(TitleWidget.TitleHeight)
        self.setMinimumHeight(TitleWidget.TitleHeight)

        self.titleLabel = QLabel("", parent=self)
        font = self.titleLabel.font()
        font.setPixelSize(11)
        self.titleLabel.setFont(font)
        self.titleLabel.setAlignment(Qt.AlignCenter)
        self.titleLabel.setText(title)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.titleLabel)
        self.setLayout(layout)
 def paintEvent(self, pe):
   painter = QPainter(self)
   painter.save()
   gradient = QLinearGradient()
   gradient.setStart(self._grad_start)
   gradient.setFinalStop(self._grad_end)
   gradient.setColorAt(0, QColor(230, 230, 230))
   gradient.setColorAt(1, QColor(247, 247, 247))
   brush = QBrush(gradient)
   painter.setBrush(brush)
   pen = QPen(Qt.black)
   pen.setWidth(1)
   painter.setPen(pen)
   painter.drawPath(self._painter_path)
   painter.restore()
   font = QFont()
   font.setFamily("Tahoma")
   font.setPixelSize(11)
   font.setBold(True)
   pen = QPen(Qt.darkGray)
   painter.setPen(pen)
   painter.setFont(font)
   self_rect = QRect(self.rect())
   self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
   painter.drawText(self_rect, Qt.AlignLeft, self._text)
Ejemplo n.º 5
0
 def paintEvent(self, pe):
     painter = QPainter(self)
     painter.save()
     gradient = QLinearGradient()
     gradient.setStart(self._grad_start)
     gradient.setFinalStop(self._grad_end)
     gradient.setColorAt(0, QColor(230, 230, 230))
     gradient.setColorAt(1, QColor(247, 247, 247))
     brush = QBrush(gradient)
     painter.setBrush(brush)
     pen = QPen(Qt.black)
     pen.setWidth(1)
     painter.setPen(pen)
     painter.drawPath(self._painter_path)
     painter.restore()
     font = QFont()
     font.setFamily("Tahoma")
     font.setPixelSize(11)
     font.setBold(True)
     pen = QPen(Qt.darkGray)
     painter.setPen(pen)
     painter.setFont(font)
     self_rect = QRect(self.rect())
     self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
     painter.drawText(self_rect, Qt.AlignLeft, self._text)
Ejemplo n.º 6
0
    def setupPainter(self, painter, orientation, x1, y1, x2, y2):
        highlight = self.palette().color(QPalette.Highlight)
        gradient = QLinearGradient(x1, y1, x2, y2)
        gradient.setColorAt(0, highlight.darker(120))
        gradient.setColorAt(1, highlight.lighter(108))
        painter.setBrush(gradient)

        if orientation == QtCore.Qt.Horizontal:
            painter.setPen(QPen(highlight.darker(130), 0))
        else:
            painter.setPen(QPen(highlight.darker(150), 0))
Ejemplo n.º 7
0
    def realRender(self, painter, renderPath):  # TODO/PORT: Still needs work.
        """
        TOWRITE

        :param `painter`: TOWRITE
        :type `painter`: `QPainter`_
        :param `renderPath`: TOWRITE
        :type `renderPath`: `QPainterPath`_
        """
        color1 = self.objectColor()  #QColor  # lighter color
        color2 = color1.darker(150)  #QColor  # darker color

        # If we have a dark color, lighten it
        darkness = color1.lightness() #int
        threshold = 32 #int   #TODO: This number may need adjusted or maybe just add it to settings.
        if darkness < threshold:
            color2 = color1
            if not darkness:
                color1 = QColor(threshold, threshold, threshold)  # lighter() does not affect pure black
            else :
                color1 = color2.lighter(100 + threshold)

        count = renderPath.elementCount()  # int
        for i in range(0, count - 1):  # for(int i = 0; i < count-1; ++i);

            elem = renderPath.elementAt(i)      # QPainterPath::Element
            next = renderPath.elementAt(i + 1)  # QPainterPath::Element

            if next.isMoveTo():
                continue

            elemPath = QPainterPath()
            elemPath.moveTo(elem.x, elem.y)
            elemPath.lineTo(next.x, next.y)

            renderPen = QPen(QColor(0, 0, 0, 0))
            renderPen.setWidthF(0)
            painter.setPen(renderPen)
            stroker = QPainterPathStroker()
            stroker.setWidth(0.35)
            stroker.setCapStyle(Qt.RoundCap)
            stroker.setJoinStyle(Qt.RoundJoin)
            realPath = stroker.createStroke(elemPath)  # QPainterPath
            painter.drawPath(realPath)

            grad = QLinearGradient(elemPath.pointAtPercent(0.5), elemPath.pointAtPercent(0.0))
            grad.setColorAt(0, color1)
            grad.setColorAt(1, color2)
            grad.setSpread(QGradient.ReflectSpread)

            painter.fillPath(realPath, QBrush(grad))
Ejemplo n.º 8
0
def glass_path(scene, x, y, w, h, colr):

    qp = QPainterPath()
    qp.addRoundedRect(x, y, w, h, 5, 5)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, colr)
    gradient.setColorAt(1, colr.lighter(150))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(qp)
    item.setBrush(brush)
    scene.addItem(item)

    # Draw glass reflection

    glass = QPainterPath()
    r = 3
    glass.addRoundedRect(x + r, y + r, w - 2 * r, 2 * r, r, r)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, QColor(255, 255, 255, 188))
    gradient.setColorAt(1, QColor(255, 255, 255, 0))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(glass)
    item.setBrush(brush)
    item.setPen(QPen(Qt.transparent))
    scene.addItem(item)
Ejemplo n.º 9
0
    def verticalGradientHelper(p, spanRect, rect, lightColored):
        highlight = StyleHelper.highlightColor(lightColored)
        shadow = StyleHelper.shadowColor(lightColored)
        grad = QLinearGradient(spanRect.topRight(), spanRect.topLeft())
        grad.setColorAt(0, highlight.lighter(117))
        grad.setColorAt(1, shadow.darker(109))
        p.fillRect(rect, grad)

        light = QColor(255, 255, 255, 80)
        p.setPen(light)
        p.drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0))
        dark = QColor(0, 0, 0, 90)
        p.setPen(dark)
        p.drawLine(rect.topLeft(), rect.bottomLeft())
Ejemplo n.º 10
0
    def __init__(self, mw, parent=None):
        """
        Default class constructor.

        :param `mw`: Pointer to a application main window instance.
        :type `mw`: `MainWindow`_
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(MdiArea, self).__init__(parent)

        self.mainWin = mw
        self.gSpiralsImgPath = mw.gImgDir + os.sep + 'texture-spirals.png'
        self.gLogoSpiralsImgPath = mw.gImgDir + os.sep + 'logo-spirals.png'

        try:  #if QT_VERSION >= 0x040800
            self.setTabsClosable(True)
        except AttributeError:
            pass

        self.useLogo = False
        self.useTexture = False
        self.useColor = False

        self.bgLogo = QPixmap()
        self.bgTexture = QPixmap(self.gSpiralsImgPath)
        self.bgColor = QColor()

        self.bgLogo = QPixmap(self.gLogoSpiralsImgPath)

        # Brushes
        self.colorBrush = QBrush(QColor(EMBROIDERBLUE1))
        self.backgroundBrush = QBrush(QPixmap(self.gSpiralsImgPath))
        linearGrad = QLinearGradient(QPointF(0, 0), QPointF(400, 400))
        linearGrad.setColorAt(0, QColor(EMBROIDERBLUE1))
        linearGrad.setColorAt(1, QColor(EMBROIDERBLUE2))
        self.gradientBrush = QBrush(linearGrad)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setActivationOrder(QMdiArea.ActivationHistoryOrder)

        self.setFocusPolicy(Qt.WheelFocus)
        self.setFocus()

        self.setAcceptDrops(True)
        self.doSetDocumentMode(True)
Ejemplo n.º 11
0
    def __init__(self, mw, parent=None):
        """
        Default class constructor.

        :param `mw`: Pointer to a application main window instance.
        :type `mw`: `MainWindow`_
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(MdiArea, self).__init__(parent)

        self.mainWin = mw
        self.gSpiralsImgPath = mw.gImgDir + os.sep + 'texture-spirals.png'
        self.gLogoSpiralsImgPath = mw.gImgDir + os.sep + 'logo-spirals.png'

        try:  #if QT_VERSION >= 0x040800
            self.setTabsClosable(True)
        except AttributeError:
            pass

        self.useLogo = False
        self.useTexture = False
        self.useColor = False

        self.bgLogo = QPixmap()
        self.bgTexture = QPixmap(self.gSpiralsImgPath)
        self.bgColor = QColor()

        self.bgLogo = QPixmap(self.gLogoSpiralsImgPath)

        # Brushes
        self.colorBrush = QBrush(QColor(EMBROIDERBLUE1))
        self.backgroundBrush = QBrush(QPixmap(self.gSpiralsImgPath))
        linearGrad = QLinearGradient(QPointF(0, 0), QPointF(400, 400))
        linearGrad.setColorAt(0, QColor(EMBROIDERBLUE1))
        linearGrad.setColorAt(1, QColor(EMBROIDERBLUE2))
        self.gradientBrush = QBrush(linearGrad)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setActivationOrder(QMdiArea.ActivationHistoryOrder)

        self.setFocusPolicy(Qt.WheelFocus)
        self.setFocus()

        self.setAcceptDrops(True)
        self.doSetDocumentMode(True)
	def initUI(self):
		"""
		Initializes UI. Creates a horizontal layout
		to which buttons can be added.
		"""
		if self._osx:
			# Mimic the style of buttons underneath a list view
			gradient = QLinearGradient()
			gradient.setStart(0, 0)
			gradient.setFinalStop(0, self.Height)

			colorTop = QColor(250, 250, 250, 255)
			colorMid = QColor(244, 244, 244, 255)
			colorInBetween = QColor(238, 238, 238, 255)
			colorMidLow = QColor(234, 234, 234, 255)
			colorLow = QColor(239, 239, 239, 255)
			gradient.setColorAt(0, colorTop)
			gradient.setColorAt(0.45, colorMid)
			gradient.setColorAt(0.5, colorInBetween)
			gradient.setColorAt(0.55, colorMidLow)
			gradient.setColorAt(1, colorLow)

			brush = QBrush(gradient)
			palette = QPalette()
			palette.setBrush(QPalette.Background, brush)

			self.setAutoFillBackground(True)
			self.setPalette(palette)

		# Use a horizontal layout in which to keep
		# buttons. Initialize with an empty QWidget to
		# make the buttons align to the left
		if self.orientation == Qt.Horizontal:
			self.layout = QHBoxLayout()
		else:
			self.layout = QVBoxLayout()
		self.layout.setSpacing(0)
		self.layout.setContentsMargins(0, 0, 0, 0)
		self.layout.addWidget(QWidget())
		self.setLayout(self.layout)
    def initUI(self):
        """
		Initializes UI. Creates a horizontal layout
		to which buttons can be added.
		"""
        if self._osx:
            # Mimic the style of buttons underneath a list view
            gradient = QLinearGradient()
            gradient.setStart(0, 0)
            gradient.setFinalStop(0, self.Height)

            colorTop = QColor(250, 250, 250, 255)
            colorMid = QColor(244, 244, 244, 255)
            colorInBetween = QColor(238, 238, 238, 255)
            colorMidLow = QColor(234, 234, 234, 255)
            colorLow = QColor(239, 239, 239, 255)
            gradient.setColorAt(0, colorTop)
            gradient.setColorAt(0.45, colorMid)
            gradient.setColorAt(0.5, colorInBetween)
            gradient.setColorAt(0.55, colorMidLow)
            gradient.setColorAt(1, colorLow)

            brush = QBrush(gradient)
            palette = QPalette()
            palette.setBrush(QPalette.Background, brush)

            self.setAutoFillBackground(True)
            self.setPalette(palette)

        # Use a horizontal layout in which to keep
        # buttons. Initialize with an empty QWidget to
        # make the buttons align to the left
        if self.orientation == Qt.Horizontal:
            self.layout = QHBoxLayout()
        else:
            self.layout = QVBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(QWidget())
        self.setLayout(self.layout)
Ejemplo n.º 14
0
def getgradient(*args):
  ret = QLinearGradient(*args)
  ret.setColorAt(0, QColor(0,0,0))
  ret.setColorAt(.5, QColor(255,255,255))
  #ret.setColorAt(1, QColor(255,255,255))
  return ret
    def paintEvent(self, event):
        painter = qg.QPainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height()
        width = option.rect.width()
        painter.setRenderHint(qg.QPainter.Antialiasing)

        gradient = QRadialGradient(float(width / 2), float(height / 2),
                                   float(height / 2), float(width / 2),
                                   float(height / 2))
        #################################

        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)
        inner_gradient = QLinearGradient(0, 0, height, 0)
        inner_gradient.setColorAt(0, QColor(255, 255, 255, 35))
        inner_gradient.setColorAt(1, QColor(1, 1, 1, 100))
        gradient.setColorAt(0.0, self.col1)
        gradient.setColorAt(0.2, self.col2)
        gradient.setColorAt(0.5, self.col3)
        gradient.setColorAt(0.7, self.col4)
        gradient.setColorAt(1.0, self.col5)

        painter.setOpacity(1.0)
        painter.fillRect(x, y, width, height, gradient)

        painter.fillRect(x, y, width, height, self.MAINBRUSH)
        #painter.setOpacity(0.5)
        painter.fillRect(x, y, width, height, inner_gradient)

        painter.setBrush(self._brushClear)

        line_path = qg.QPainterPath()
        line_path.moveTo(x, height)
        line_path.lineTo(
            width,
            height,
        )
        self.penTick.setCapStyle(qc.Qt.RoundCap)
        self._pen_line.setCapStyle(qc.Qt.RoundCap)

        painter.setPen(self._pen_text)
        painter.drawPath(line_path)
        painter.setPen(self.penTick)
        painter.drawPath(line_path)

        offset_y = 1
        offset_x = 6

        line_path_2 = qg.QPainterPath()
        line_path_2.moveTo(offset_x, 50 - offset_y)
        line_path_2.lineTo((width - offset_x), 50 - offset_y)
        painter.setOpacity(0.85)

        painter.setPen(self._pen_line)
        painter.drawPath(line_path_2)

        painter.setBrush(self._brushClear)
        painter.end()
Ejemplo n.º 16
0
 def menuGradientHelper(p, spanRect, rect):
     grad = QLinearGradient(spanRect.topLeft(), spanRect.bottomLeft())
     menuColor = StyleHelper.mergedColors(StyleHelper.baseColor(), QColor(244, 244, 244), 25)
     grad.setColorAt(0, menuColor.lighter(112))
     grad.setColorAt(1, menuColor)
     p.fillRect(rect, grad)
Ejemplo n.º 17
0
    def horizontalGradientHelper(p, spanRect, rect, lightColored):
        if lightColored:
            shadowGradient = QLinearGradient(rect.topLeft(), rect.bottomLeft())
            shadowGradient.setColorAt(0, 0xF0F0F0)
            shadowGradient.setColorAt(1, 0xCFCFCF)
            p.fillRect(rect, shadowGradient)
            return

        base = StyleHelper.baseColor(lightColored)
        highlight = StyleHelper.highlightColor(lightColored)
        shadow = StyleHelper.shadowColor(lightColored)
        grad = QLinearGradient(rect.topLeft(), rect.bottomLeft())
        grad.setColorAt(0, highlight.lighter(120))
        if rect.height() == StyleHelper.navigationWidgetHeight():
            grad.setColorAt(0.4, highlight)
            grad.setColorAt(0.401, base)

        grad.setColorAt(1, shadow)
        p.fillRect(rect, grad)

        shadowGradient = QLinearGradient(spanRect.topLeft(), spanRect.topRight())
        shadowGradient.setColorAt(0, QColor(0, 0, 0, 30))

        if not lightColored:
            lighterHighlight = highlight.lighter(130)
        else:
            lighterHighlight = highlight.lighter(90)
        lighterHighlight.setAlpha(100)
        shadowGradient.setColorAt(0.7, lighterHighlight)
        shadowGradient.setColorAt(1, QColor(0, 0, 0, 40))
        p.fillRect(rect, shadowGradient)
Ejemplo n.º 18
0
    def paint(self, painter, option, index):
        name_rect = option.rect.adjusted(4, 0, -4, 0)
        item_rect = option.rect.adjusted(1, 1, -1, 0)

        painter.fillRect(item_rect, QColor(index.data(item_background)))

        if option.state & QStyle.State_Selected:
            g_selected = QLinearGradient(0, item_rect.y(), 0,
                                         item_rect.y() + item_rect.height())
            g_selected.setColorAt(0.0, QColor(100, 100, 100, 200))
            g_selected.setColorAt(1.0 / item_rect.height(),
                                  QColor(100, 200, 255, 255))
            g_selected.setColorAt(1.0 - 1.0 / item_rect.height(),
                                  QColor(100, 200, 255, 255))
            g_selected.setColorAt(1.0, QColor(255, 255, 255, 0))
            g_selected.setSpread(QGradient.ReflectSpread)
            painter.fillRect(item_rect, g_selected)

        elif option.state & QStyle.State_MouseOver:
            g_hover = QLinearGradient(0, item_rect.y(), 0,
                                      item_rect.y() + item_rect.height())
            g_hover.setColorAt(0.0, QColor(255, 255, 255, 200))
            g_hover.setColorAt(1.0 / item_rect.height(),
                               QColor(255, 255, 255, 50))
            g_hover.setColorAt(1.0 - 1.0 / item_rect.height(),
                               QColor(255, 255, 255, 0))
            g_hover.setColorAt(1.0, QColor(100, 100, 100, 200))
            painter.fillRect(item_rect, g_hover)

        painter.save()
        painter.setPen(
            QPen(
                QColor(
                    index.data(item_color) if self.role ==
                    file_convert else '#000')))
        painter.drawText(name_rect, Qt.AlignVCenter, index.data(self.role))
        painter.restore()