Пример #1
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)
Пример #2
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())
Пример #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)
Пример #4
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)
Пример #5
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 __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)
Пример #8
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)
Пример #9
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))
Пример #10
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))
    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()
	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)
Пример #14
0
class DT_Button(QtGui.QPushButton , base.Base):
	_gradient = {NORMAL:{} , DOWN:{} , DISABLED:{}}
		
	inner_gradient = QLinearGradient(0, 3, 0, 24)
	inner_gradient.setColorAt(0, QColor(53, 57, 60))
	inner_gradient.setColorAt(1, QColor(33, 34, 36))
	_gradient[NORMAL][INNER] = QBrush(inner_gradient)
	
	outer_gradient = QLinearGradient(0, 2, 0, 25)
	outer_gradient.setColorAt(0, QColor(69, 73, 76))
	outer_gradient.setColorAt(1, QColor(17, 18, 20))
	_gradient[NORMAL][OUTER] = QBrush(outer_gradient)
	
	inner_gradient_down = QLinearGradient(0, 3, 0, 24)
	inner_gradient_down.setColorAt(0, QColor(20, 21, 23))
	inner_gradient_down.setColorAt(1, QColor(48, 49, 51))
	_gradient[DOWN][INNER] = QBrush(inner_gradient_down)
	
	outer_gradient_down = QLinearGradient(0, 2, 0, 25)
	outer_gradient_down.setColorAt(0, QColor(36, 37, 39))
	outer_gradient_down.setColorAt(1, QColor(32, 33, 35))
	_gradient[DOWN][OUTER] = QBrush(outer_gradient_down)
	
	inner_gradient_disabled = QLinearGradient(0, 3, 0, 24)
	inner_gradient_disabled.setColorAt(0, QColor(33, 37, 40))
	inner_gradient_disabled.setColorAt(1, QColor(13, 14, 16))
	_gradient[DISABLED][INNER] = QBrush(inner_gradient_disabled)
	
	outer_gradient_disabled = QLinearGradient(0, 2, 0, 25)
	outer_gradient_disabled.setColorAt(0, QColor(49, 53, 56))
	outer_gradient_disabled.setColorAt(1, QColor( 9, 10, 12))
	_gradient[DISABLED][OUTER] = QBrush(outer_gradient_disabled)
	
	
	def __init__(self,*args , **kwargs):
		QtGui.QPushButton.__init__(self , *args , **kwargs)
		base.Base.__init__(self)
		self.setFixedHeight(27)
		
		self._radius = 5
		
		self.font_metrics = QtGui.QFontMetrics(self.font())

	def paintEvent(self , event):
		painter = QtGui.QStylePainter(self)
		option = QtGui.QStyleOption()
		option.initFrom(self)

		x = option.rect.x()
		y = option.rect.y()
		height = option.rect.height() - 1
		width = option.rect.width() - 1 
		
		painter.setRenderHint(QtGui.QPainter.Antialiasing)
		
		radius = self._radius
		
		gradient = self._gradient[NORMAL]
		offset = 0
		if self.isDown():
			gradient = self._gradient[DOWN]
		elif not self.isEnabled():
			gradient = self._gradient[DISABLED]
		
		painter.setBrush(self._brush_border)
		painter.setPen(self._pens_border)
		painter.drawRoundedRect(QtCore.QRect(x+1 , y+1 , width-1 , height-1) , radius , radius)
		
		painter.setPen(self._pens_clear)
		
		painter.setBrush(gradient[OUTER])
		painter.drawRoundedRect(QtCore.QRect(x+2 , y+2 , width-3 , height-3) , radius , radius)
		
		painter.setBrush(gradient[INNER])
		painter.drawRoundedRect(QtCore.QRect(x+3 , y+3 , width-5 , height-5) , radius-1, radius-1)
		
		painter.setBrush(self._brush_clear)
		
		text = self.text()
		font = self.font()
		
		text_width = self.font_metrics.width(text)
		text_height = font.pointSize()
		
		text_path = QtGui.QPainterPath()
		text_path.addText((width - text_width)/2 , height-((height-text_height)/2)-1+offset , font ,text)
		
		glow_index = self._glow_index 
		glow_pens = self._glow_pens
		
		alignment = (QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
		
		if self.isEnabled():
			painter.setPen(self._pens_shadow)
			painter.drawPath(text_path)
			
			painter.setPen(self._pens_text)
			painter.drawText(x , y+offset , width , height , alignment , text)
			
			if glow_index > 0:
				for index in range(3):
					painter.setPen(glow_pens[glow_index][index])
					painter.drawPath(text_path)
					
				painter.setPen(glow_pens[glow_index][3])
				painter.drawText(x , y+offset , width , height , alignment , text)
		
		else:
			painter.setPen(self._pens_shadow_disabled)
			painter.drawPath(text_path)
			
			painter.setPen(self._pens_text_disabled)
			painter.drawText(x , y+offset , width , height , alignment , text)

	def enterEvent(self , event):
		#print 'enter'
		#super(self.__class__ , self).enterEvent(event)
		
		if not self.isEnabled(): return
		
		self._hover = True
		self._startAnim()
	
	def leaveEvent(self , event):
		#print 'leave'
		#super(self.__class__ , self).leaveEvent(event)
		
		if not self.isEnabled(): return
		
		self._hover = False
		self._startAnim()
Пример #15
0
class DT_Slider(QtGui.QSlider, base.Base):
    _glow_brushes = {}
    for index in range(1, 11):
        _glow_brushes[index] = [
            QBrush(QColor(0, 255, 0, 1 * index)),
            QBrush(QColor(0, 255, 0, 3 * index)),
            QBrush(QColor(0, 255, 0, 8 * index)),
            QBrush(QColor(0, 255, 0, 25.5 * index)),
            QBrush(QColor(0, 255, 0, 15 * index)),
        ]

    _pens_dark = QPen(QColor(0, 5, 9), 1, QtCore.Qt.SolidLine)
    _pens_light = QPen(QColor(16, 17, 19), 1, QtCore.Qt.SolidLine)

    _gradient_inner = QLinearGradient(0, 9, 0, 15)
    _gradient_inner.setColorAt(0, QColor(69, 73, 76))
    _gradient_inner.setColorAt(1, QColor(17, 18, 20))

    _gradient_outer = QLinearGradient(0, 9, 0, 15)
    _gradient_outer.setColorAt(0, QColor(53, 57, 60))
    _gradient_outer.setColorAt(1, QColor(33, 34, 36))

    def __init__(self, *args, **kwargs):
        QtGui.QSlider.__init__(self, *args, **kwargs)

        self._hover = False
        self._glow_index = 0
        self._anim_timer = QtCore.QTimer()
        self._anim_timer.timeout.connect(self._animateGlow)

        self.setOrientation(QtCore.Qt.Horizontal)
        self.setFixedHeight(22)
        self.setMinimumWidth(50)

        self._track = False
        self._tracking_point = {}

        self._anim_follow_timer = QtCore.QTimer()
        self._anim_follow_timer.timeout.connect(self._removeTrackingPoints)

        self.valueChanged.connect(self._trackChanges)
        self._updateTracking()

    def setRange(self, *args, **kwargs):
        QtGui.QSlider.setRange(self, *args, **kwargs)
        self._updateTracking()

    def setMinimum(self, *args, **kwargs):
        QtGui.QSlider.setMinimum(self, *args, **kwargs)
        self._updateTracking()

    def setMaximum(self, *args, **kwargs):
        QtGui.QSlider.setMaximum(self, *args, **kwargs)
        self._updateTracking()

    def _updateTracking(self):
        self._tracking_points = [0
                                 ] * (abs(self.maximum() - self.minimum()) + 1)

    def setValue(self, *args, **kwargs):
        QtGui.QSlider.setValue(self, *args, **kwargs)
        for index in range(len(self._tracking_points)):
            self._tracking_points[index] = 0

    def mouseMoveEvent(self, event):
        QtGui.QSlider.mouseMoveEvent(self, event)

        if self._anim_follow_timer.isActive():
            return

        self._anim_follow_timer.start(30)

    def _trackChanges(self, value):
        value = value - self.minimum()
        self._tracking_points[value] = 10

    def _removeTrackingPoints(self):
        self._track = False
        for index, value in enumerate(self._tracking_points):
            if value > 0:
                self._tracking_points[index] -= 1
                self._track = True

        if self._track is False:
            self._anim_follow_timer.stop()

        utils.executeDeferred(self.update)

    def paintEvent(self, event):
        painter = QtGui.QStylePainter(self)
        option = QtGui.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        width = option.rect.width() - 1
        height = option.rect.height() - 1

        orientation = self.orientation()

        painter.setRenderHint(QtGui.QPainter.Antialiasing)

        painter.setPen(self._pens_shadow)
        painter.setBrush(self._brush_border)
        painter.drawRoundedRect(
            QtCore.QRect(x + 1, y + 1, width - 1, height - 1), 10, 10)

        mid_height = (height / 2) + 1
        painter.setPen(self._pens_dark)
        painter.drawLine(10, mid_height, width - 8, mid_height)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, False)
        painter.setPen(self._pens_light)
        painter.drawLine(10, mid_height, width - 10, mid_height)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, True)

        minimum = self.minimum()
        maximum = self.maximum()
        value_range = maximum - minimum
        value = self.value() - minimum

        increment = ((width - 20) / float(value_range))
        center = 10 + (increment * value)
        center_point = QtCore.QPoint(x + center, y + mid_height)

        painter.setPen(self._pens_clear)

        glow_index = self._glow_index
        glow_brushes = self._glow_brushes

        if self._track is True:
            for index, track_value in enumerate(self._tracking_points):
                if track_value == 0: continue
                track_center = 10 + (increment * index)
                painter.setBrush(glow_brushes[track_value][4])
                painter.drawEllipse(QtCore.QPoint(track_center, mid_height), 7,
                                    7)

        if glow_index > 0:
            for index, size in zip(range(4), range(10, 6, -1)):
                painter.setBrush(glow_brushes[glow_index][index])
                painter.drawEllipse(center_point, size, size)

        painter.setBrush(QtGui.QBrush(self._gradient_outer))
        painter.drawEllipse(center_point, 6, 6)

        painter.setBrush(QtGui.QBrush(self._gradient_inner))
        painter.drawEllipse(center_point, 5, 5)

    def enterEvent(self, event):

        if not self.isEnabled(): return

        self._hover = True
        self._startAnim()

    def leaveEvent(self, event):

        if not self.isEnabled(): return

        self._hover = False
        self._startAnim()
Пример #16
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
Пример #17
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()
Пример #18
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)
Пример #19
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)
class CustomButton(qg.QPushButton):

    _pen_text = QPen(QColor(125, 200, 100), 1, qc.Qt.SolidLine)
    _pen_textHover = QPen(QColor(150, 225, 125), 1, qc.Qt.SolidLine)
    _pen_Ticktext = QPen(QColor(125, 200, 100), 1.5, qc.Qt.SolidLine)
    _pen_TickHover = QPen(QColor(255, 0, 0), 1.5, qc.Qt.SolidLine)
    _pen_TickPressed = QPen(QColor(1, 1, 1), 2, qc.Qt.SolidLine)
    _pen_Shadow = QPen(QColor(9, 10, 12), 1, qc.Qt.SolidLine)
    _pen_border = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_clear = QPen(QColor(0, 0, 0, 0), 1, qc.Qt.SolidLine)

    _penText_disable = QPen(QColor(102, 107, 110), 1, qc.Qt.SolidLine)
    _penShadow_disable = QPen(QColor(0, 0, 0), 1, qc.Qt.SolidLine)

    _brushClear = QBrush(QColor(0, 0, 0, 0))
    _brushBorder = QBrush(QColor(9, 10, 12))

    _gradient = {NORMAL: {}, DOWN: {}, DISABLE: {}}

    inner_gradient = QLinearGradient(0, 3, 0, 24)
    inner_gradient.setColorAt(0, QColor(53, 57, 60))
    inner_gradient.setColorAt(1, QColor(33, 34, 36))
    _gradient[NORMAL][INNER] = QBrush(inner_gradient)

    outer_gradient = QLinearGradient(0, 2, 0, 25)
    outer_gradient.setColorAt(0, QColor(69, 73, 76))
    outer_gradient.setColorAt(1, QColor(17, 18, 20))
    _gradient[NORMAL][OUTER] = QBrush(outer_gradient)

    inner_gradientDown = QLinearGradient(0, 3, 0, 24)
    inner_gradientDown.setColorAt(0, QColor(20, 21, 23))
    inner_gradientDown.setColorAt(1, QColor(48, 49, 51))
    _gradient[DOWN][INNER] = QBrush(inner_gradientDown)

    outer_gradientDown = QLinearGradient(0, 2, 0, 25)
    outer_gradientDown.setColorAt(0, QColor(20, 21, 23))
    outer_gradientDown.setColorAt(1, QColor(32, 33, 35))
    _gradient[DOWN][OUTER] = QBrush(outer_gradientDown)

    inner_gradientDisable = QLinearGradient(0, 3, 0, 24)
    inner_gradientDisable.setColorAt(0, QColor(33, 37, 39))
    inner_gradientDisable.setColorAt(1, QColor(13, 14, 16))
    _gradient[DISABLE][INNER] = QBrush(inner_gradientDisable)

    outer_gradientDisable = QLinearGradient(0, 2, 0, 25)
    outer_gradientDisable.setColorAt(0, QColor(49, 53, 56))
    outer_gradientDisable.setColorAt(1, QColor(9, 10, 12))
    _gradient[DISABLE][OUTER] = QBrush(outer_gradientDisable)

    def __init__(self, *args, **kwargs):
        qg.QPushButton.__init__(self, *args, **kwargs)

        font = qg.QFont()
        font.setPointSize(10)
        font.setFamily('Helvetic')
        self.setFont(font)

        self.hover = False
        self._glow_index = 0
        self._anim_timer = qc.QTimer()
        self._anim_timer.timeout.connect(self._animateGlow)
        self.setFixedHeight(27)

        self.fontMetrics = qg.QFontMetrics(font)
        self.radius = 5

    def _animateGlow(self):
        print " ANIMATE GLOW METHOD "

        if self.hover:
            if self._glow_index >= 10:
                self._glow_index = 10
                self._anim_timer.stop()

            else:
                self._glow_index += 1

        else:
            if self._glow_index <= 0:
                self._glow_index = 0
                self._anim_timer.stop()

            else:
                self._glow_index -= 1
        print self._glow_index
        utils.executeDeferred(self.update)


#-----------------------------------------------------------------------------------------------#

    def enterEvent(self, event):
        print 'Base enterEvent'

        if not self.isEnabled():
            return

        self.hover = True
        self.startAnim()

    def leaveEvent(self, event):
        print 'Base leaveEvent'

        if not self.isEnabled():
            return

        self.hover = False
        self.startAnim()

    def startAnim(self):
        if self._anim_timer.isActive():
            return

        self._anim_timer.start(20)

    def paintEvent(self, event):

        painter = qg.QStylePainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height() - 1
        width = option.rect.width() - 1

        painter.setRenderHint(qg.QPainter.Antialiasing)
        radius = 10
        offSet = 0
        gradient = self._gradient[NORMAL]

        if self.isDown():
            gradient = self._gradient[DOWN]
            offSet = 1

        elif not self.isEnabled():
            gradient = self._gradient[DISABLE]

        painter.setBrush(self._brushBorder)
        painter.setPen(self._pen_border)
        painter.drawRoundedRect(qc.QRect(x + 1, y + 1, width - 1, height - 1),
                                radius, radius)

        painter.setPen(self._pen_clear)
        painter.setBrush(gradient[OUTER])
        painter.drawRoundedRect(qc.QRect(x + 2, y + 2, width - 3, height - 3),
                                radius, radius)

        painter.setBrush(gradient[INNER])
        painter.drawRoundedRect(qc.QRect(x + 3, y + 3, width - 4, height - 4),
                                radius - 1, radius - 1)

        # draw TEXT
        #

        text = self.text()
        font = self.font()

        text_width = self.fontMetrics.width(text)
        text_height = font.pointSize()

        textPath = qg.QPainterPath()
        textPath.addText(
            (width - text_width) / 2.1,
            height - ((height - text_height) / 2.1) / 1.2 + offSet, font, text)

        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)

        if self.isEnabled():
            painter.setPen(self._pen_Shadow)
            painter.drawPath(textPath)

            painter.setPen(self._pen_text)
            painter.drawText(x, y + offSet, width, height, alignment, text)

        else:
            painter.setPen(self._penShadow_disable)
            painter.drawPath(textPath)

            painter.setPen(self._penText_disable)
            painter.drawText(x, y + offSet, width, height, alignment, text)
        """
Пример #21
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)
Пример #22
0
 def testSetBrushGradient(self):
     painter = QPainter()
     gradient = QLinearGradient(0, 0, 0, 0)
     painter.setBrush(gradient)
Пример #23
0
class CustomButton(qg.QPushButton):
    _glowPens = {}
    for index in range(1, 11):
        _glowPens[index] = [
            QPen(QColor(0, 255, 0, 12 * index), 1, qc.Qt.SolidLine),
            QPen(QColor(0, 255, 0, 5 * index), 1, qc.Qt.SolidLine),
            QPen(QColor(0, 255, 0, 2 * index), 1, qc.Qt.SolidLine),
            QPen(QColor(125, 200, 100), 1, qc.Qt.SolidLine)
        ]

    _pen_text = QPen(QColor(125, 200, 100), 1, qc.Qt.SolidLine)
    _pen_textHover = QPen(QColor(150, 225, 125), 1, qc.Qt.SolidLine)
    _pen_Ticktext = QPen(QColor(125, 200, 100), 2, qc.Qt.SolidLine)
    _pen_TickHover = QPen(QColor(255, 0, 0), 2, qc.Qt.SolidLine)
    _pen_TickPressed = QPen(QColor(1, 1, 1), 3, qc.Qt.SolidLine)
    _pen_Shadow = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_border = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_clear = QPen(QColor(0, 0, 0, 0), 1, qc.Qt.SolidLine)

    _penText_disable = QPen(QColor(102, 107, 110), 1, qc.Qt.SolidLine)
    _penShadow_disable = QPen(QColor(0, 0, 0), 1, qc.Qt.SolidLine)

    _brushClear = QBrush(QColor(0, 0, 0, 0))
    _brushBorder = QBrush(QColor(9, 10, 12))

    _gradient = {NORMAL: {}, DOWN: {}, DISABLE: {}}

    inner_gradient = QLinearGradient(0, 3, 0, 24)
    inner_gradient.setColorAt(0, QColor(53, 57, 60))
    inner_gradient.setColorAt(1, QColor(33, 34, 36))
    _gradient[NORMAL][INNER] = QBrush(inner_gradient)

    outer_gradient = QLinearGradient(0, 2, 0, 25)
    outer_gradient.setColorAt(0, QColor(69, 73, 76))
    outer_gradient.setColorAt(1, QColor(17, 18, 20))
    _gradient[NORMAL][OUTER] = QBrush(outer_gradient)

    inner_gradientDown = QLinearGradient(0, 3, 0, 24)
    inner_gradientDown.setColorAt(0, QColor(20, 21, 23))
    inner_gradientDown.setColorAt(1, QColor(48, 49, 51))
    _gradient[DOWN][INNER] = QBrush(inner_gradientDown)

    outer_gradientDown = QLinearGradient(0, 2, 0, 25)
    outer_gradientDown.setColorAt(0, QColor(20, 21, 23))
    outer_gradientDown.setColorAt(1, QColor(32, 33, 35))
    _gradient[DOWN][OUTER] = QBrush(outer_gradientDown)

    inner_gradientDisable = QLinearGradient(0, 3, 0, 24)
    inner_gradientDisable.setColorAt(0, QColor(33, 37, 39))
    inner_gradientDisable.setColorAt(1, QColor(13, 14, 16))
    _gradient[DISABLE][INNER] = QBrush(inner_gradientDisable)

    outer_gradientDisable = QLinearGradient(0, 2, 0, 25)
    outer_gradientDisable.setColorAt(0, QColor(49, 53, 56))
    outer_gradientDisable.setColorAt(1, QColor(9, 10, 12))
    _gradient[DISABLE][OUTER] = QBrush(outer_gradientDisable)

    _size_y = 27

    def __init__(self, *args, **kwargs):
        qg.QPushButton.__init__(self, *args, **kwargs)

        font = qg.QFont()
        font.setPointSize(12)
        font.setFamily('Calibri')
        font.setLetterSpacing(QFont.AbsoluteSpacing, float(1))

        self.setFont(font)

        self.hover = False
        self._glow_index = 0
        self._anim_timer = qc.QTimer()
        self._anim_timer.timeout.connect(self._animateGlow)
        self.setFixedHeight(self._size_y)

        self.fontMetrics = qg.QFontMetrics(font)
        self.radius = 5

    def _animateGlow(self):
        if self.hover:
            if self._glow_index >= 10:
                self._glow_index = 10
                while self._glow_index > 8:
                    self._glow_index -= 0.25
                    #print self._glow_index
                    if self._glow_index == 8:
                        self._anim_timer.stop()

            else:
                self._glow_index += 1

        else:
            if self._glow_index <= 0:
                self._glow_index = 0
                self._anim_timer.stop()

            else:
                self._glow_index -= 1

        #print self._glow_index

        utils.executeDeferred(self.update)

#-----------------------------------------------------------------------------------------------#

    def enterEvent(self, event):
        if not self.isEnabled():
            return

        self.hover = True
        self.startAnim()

    def leaveEvent(self, event):
        if not self.isEnabled():
            return

        self.hover = False
        self.startAnim()

    def startAnim(self):
        if self._anim_timer.isActive():
            return

        self._anim_timer.start(20)

    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() - 1
        width = option.rect.width() - 1

        painter.setRenderHint(qg.QPainter.Antialiasing)
        radius = 10
        offSet = 1
        gradient = self._gradient[NORMAL]

        glowIndex = self._glow_index
        glowPen = self._glowPens

        if self.isDown():
            gradient = self._gradient[DOWN]
            offSet = -1

        elif not self.isEnabled():
            gradient = self._gradient[DISABLE]

        painter.setBrush(self._brushBorder)
        painter.setPen(self._pen_border)
        painter.drawRoundedRect(qc.QRect(x + 1, y + 1, width - 1, height - 1),
                                radius, radius)

        painter.setPen(self._pen_clear)
        painter.setBrush(gradient[OUTER])
        painter.drawRoundedRect(qc.QRect(x + 2, y + 2, width - 3, height - 3),
                                radius, radius)

        painter.setBrush(gradient[INNER])
        painter.drawRoundedRect(qc.QRect(x + 3, y + 3, width - 4, height - 4),
                                radius - 1, radius - 1)

        painter.setBrush(self._brushClear)

        # draw TEXT
        #
        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)
        text = self.text()
        font = self.font()

        text_width = self.fontMetrics.width(text)
        text_height = font.pointSize()

        textPath = qg.QPainterPath()
        #textPath.addText((width - text_width) * 2 , height - ((height - text_height) * 2) + offSet,font, text)
        textPath.addText(x, y, font, text)

        textPath2 = qg.QPainterPath()
        textPath2.addText((width - text_width) / 2,
                          (height - text_height / 1.5), font, text)

        if self.isEnabled():
            painter.setPen(self._pen_Shadow)
            painter.drawText(x - offSet, y - offSet, width + offSet,
                             height + offSet, alignment, text)

            painter.setPen(self._pen_text)
            painter.drawText(x, y, width, height, alignment, text)

            if glowIndex > 0:
                for index in range(3):
                    painter.setPen(self._pen_clear)
                    painter.drawPath(textPath)
                    painter.setPen(glowPen[glowIndex][index])
                    painter.drawPath(textPath2)

                painter.setPen(self._pen_textHover)
                painter.drawText(x, y, width, height, alignment, text)

        else:
            painter.setPen(self._penShadow_disable)
            painter.drawPath(textPath)

            painter.setPen(self._penText_disable)
            painter.drawText(x, y + offSet, width, height, alignment, text)
class Square_button_blue(qg.QPushButton):
    penTick = QPen(QColor(33, 213, 231), 2, qc.Qt.SolidLine)
    penborder = QPen(QColor(9, 10, 12), 3, qc.Qt.SolidLine)
    _glowPens = {}

    for index in range(1, 11):
        _glowPens[index] = [
            QPen(QColor(33, 213, 231, 5 * index), 2, qc.Qt.SolidLine),
            QPen(QColor(33, 213, 231, 10 * index), 2.5, qc.Qt.SolidLine),
            QPen(QColor(33, 213, 231, 15 * index), 3, qc.Qt.SolidLine),
            QPen(QColor(33, 213, 231, 25.5 * index), 6, qc.Qt.SolidLine)
        ]

    _pen_text = QPen(QColor(125, 200, 100), 1, qc.Qt.SolidLine)
    _pen_textHover = QPen(QColor(150, 225, 125), 1, qc.Qt.SolidLine)
    _pen_Ticktext = QPen(QColor(125, 200, 100), 2, qc.Qt.SolidLine)
    _pen_TickHover = QPen(QColor(255, 0, 0), 2, qc.Qt.SolidLine)
    _pen_TickPressed = QPen(QColor(1, 1, 1), 3, qc.Qt.SolidLine)
    _pen_Shadow = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_border = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_clear = QPen(QColor(0, 0, 0, 0), 1, qc.Qt.SolidLine)

    _penText_disable = QPen(QColor(102, 107, 110), 1, qc.Qt.SolidLine)
    _penShadow_disable = QPen(QColor(0, 0, 0), 1, qc.Qt.SolidLine)

    _brushClear = QBrush(QColor(0, 0, 0, 0))
    _brushBorder = QBrush(QColor(9, 10, 12))

    _gradient = {NORMAL: {}, DOWN: {}, DISABLE: {}}

    inner_gradient = QLinearGradient(0, 3, 0, 24)
    inner_gradient.setColorAt(0, QColor(53, 57, 60))
    inner_gradient.setColorAt(1, QColor(33, 34, 36))
    _gradient[NORMAL][INNER] = QBrush(inner_gradient)

    outer_gradient = QLinearGradient(0, 2, 0, 25)
    outer_gradient.setColorAt(0, QColor(69, 73, 76))
    outer_gradient.setColorAt(1, QColor(17, 18, 20))
    _gradient[NORMAL][OUTER] = QBrush(outer_gradient)

    inner_gradientDown = QLinearGradient(0, 3, 0, 24)
    inner_gradientDown.setColorAt(0, QColor(20, 21, 23))
    inner_gradientDown.setColorAt(1, QColor(48, 49, 51))
    _gradient[DOWN][INNER] = QBrush(inner_gradientDown)

    outer_gradientDown = QLinearGradient(0, 2, 0, 25)
    outer_gradientDown.setColorAt(0, QColor(20, 21, 23))
    outer_gradientDown.setColorAt(1, QColor(32, 33, 35))
    _gradient[DOWN][OUTER] = QBrush(outer_gradientDown)

    inner_gradientDisable = QLinearGradient(0, 3, 0, 24)
    inner_gradientDisable.setColorAt(0, QColor(33, 37, 39))
    inner_gradientDisable.setColorAt(1, QColor(13, 14, 16))
    _gradient[DISABLE][INNER] = QBrush(inner_gradientDisable)

    outer_gradientDisable = QLinearGradient(0, 2, 0, 25)
    outer_gradientDisable.setColorAt(0, QColor(49, 53, 56))
    outer_gradientDisable.setColorAt(1, QColor(9, 10, 12))
    _gradient[DISABLE][OUTER] = QBrush(outer_gradientDisable)

    _size = [35, 35]

    def __init__(self, parent=None, *args, **kwargs):
        super(Square_button_blue, self).__init__(parent, *args, **kwargs)

        font = qg.QFont()
        font.setPointSize(12)
        font.setFamily('Calibri')
        font.setLetterSpacing(QFont.AbsoluteSpacing, float(1))
        self.setFont(font)
        self.hover = False
        self._glow_index = 0
        self._anim_timer = qc.QTimer()
        self._anim_timer.timeout.connect(self._animateGlow)
        self.setFixedSize(self._size[0], self._size[1])

        self.fontMetrics = qg.QFontMetrics(font)
        self.radius = 5
        self.setMouseTracking(True)

        self.setCursor(qg.QCursor(qc.Qt.PointingHandCursor))
        self.parent = parent

    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() - 1
        width = option.rect.width() - 1

        painter.setRenderHint(qg.QPainter.Antialiasing)
        radius = 10
        offSet = 0
        gradient = self._gradient[NORMAL]

        glowIndex = self._glow_index
        glowPen = self._glowPens

        if self.isDown():
            gradient = self._gradient[DOWN]
            offSet = 1

        painter.setBrush(self._brushBorder)
        painter.setPen(self._pen_border)
        painter.drawRoundedRect(qc.QRect(x + 1, y + 1, width - 1, height - 1),
                                radius, radius)
        painter.setPen(self._pen_clear)
        painter.setBrush(gradient[OUTER])
        painter.drawRoundedRect(qc.QRect(x + 2, y + 2, width - 3, height - 3),
                                radius, radius)
        painter.setBrush(gradient[INNER])
        painter.drawRoundedRect(qc.QRect(x + 3, y + 3, width - 4, height - 4),
                                radius - 1, radius - 1)
        painter.setBrush(self._brushClear)
        line_path = qg.QPainterPath()

        #------------------- IK- full ----------#
        # offset
        num_x = 5.5
        num_y = 2.5
        #######################################
        # F
        line_path.moveTo(2 + num_x, 9 + num_y)
        line_path.lineTo(2 + num_x, 21 + num_y)
        line_path.moveTo(3 + num_x, 9 + num_y)
        line_path.lineTo(10 + num_x, 9 + num_y)
        line_path.moveTo(3 + num_x, 15 + num_y)
        line_path.lineTo(8 + num_x, 15 + num_y)
        #########################################
        # K
        num_x = 7
        line_path.moveTo(12 + num_x, 9 + num_y)
        line_path.lineTo(12 + num_x, 21 + num_y)
        line_path.moveTo(15 + num_x, 15 + num_y)
        line_path.lineTo(20 + num_x, 10 + num_y)
        line_path.moveTo(15 + num_x, 15 + num_y)
        line_path.lineTo(20 + num_x, 21 + num_y)

        self.penTick.setCapStyle(qc.Qt.RoundCap)

        if self.isEnabled():
            painter.setPen(self.penborder)
            painter.drawPath(line_path)
            painter.setPen(self.penTick)
            painter.drawPath(line_path)

            if glowIndex > 0:
                for index in range(3):
                    painter.setPen(self._pen_clear)
                    painter.drawPath(line_path)
                    pen = self._glowPens[glowIndex][index]
                    pen.setCapStyle(qc.Qt.RoundCap)
                    painter.setPen(pen)
                    painter.drawPath(line_path)

    #################################################################
    def _animateGlow(self):
        if self.hover:
            if self._glow_index >= 10:
                self._glow_index = 10
                while self._glow_index > 8:
                    self._glow_index -= 0.25
                    #print self._glow_index
                    if self._glow_index == 8:
                        self._anim_timer.stop()

            else:
                self._glow_index += 1

        else:
            if self._glow_index <= 0:
                self._glow_index = 0
                self._anim_timer.stop()

            else:
                self._glow_index -= 1

        utils.executeDeferred(self.update)
#-----------------------------------------------------------------------------------------------#

    def enterEvent(self, event):
        if not self.isEnabled():
            return

        self.hover = True
        self.startAnim()

        try:
            main_par = self.parent.parent()
            getattr(main_par, 'header_label').setText(self.objectName())
        except:
            pass

    def leaveEvent(self, event):
        if not self.isEnabled():
            return

        self.hover = False
        self.startAnim()
        try:
            main_par = self.parent.parent()
            getattr(main_par, 'header_label').setText('')

        except:
            pass

    def startAnim(self):
        if self._anim_timer.isActive():
            return

        self._anim_timer.start(20)