void PluginSlider::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	
	QColor color = themer()->get_color("PluginSlider:value");
	QColor background = themer()->get_color("PluginSlider:background");
	
	if (highlight) {
		color = color.light(110);
		background = background.light(105);
	}
	
	// avoid painting at 0, it looks bad...
	if (m_xpos <= 1) m_xpos = 2;
	
	painter.setBrush(background);
        painter.setPen(themer()->get_color("PluginSlider:text"));
	QRectF rect(0.0, 0.0, width() - 0.5, height() - 0.5);
	painter.drawRect(rect);
	painter.fillRect(1, 1, m_xpos - 2, height() - 2, QBrush(color));
	if (m_port->get_hint() == PluginPort::INT_CONTROL) {
		painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number((int)m_value));
	} else {
		painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number(m_value, 'f', 2));
	}
}
QPalette CockpitGrid::colorTheme(const QColor &base) const
{
    const QColor background = base.dark(150);
    const QColor foreground = base.dark(200);

    const QColor mid = base.dark(110);
    const QColor dark = base.dark(170);
    const QColor light = base.light(170);
    const QColor text = foreground.light(800);

    QPalette palette;
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
    {
        QPalette::ColorGroup cg = (QPalette::ColorGroup)i;

        palette.setColor(cg, QPalette::Base, base);
        palette.setColor(cg, QPalette::Window, background);
        palette.setColor(cg, QPalette::Mid, mid);
        palette.setColor(cg, QPalette::Light, light);
        palette.setColor(cg, QPalette::Dark, dark);
        palette.setColor(cg, QPalette::Text, text);
        palette.setColor(cg, QPalette::WindowText, foreground);
    }

    return palette;
}
Exemple #3
0
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
	int x = -7;
	int y = -7;
	int width = 20;
	int height = 20;
    
	x  = -10;
	y = -10;

    QColor color;
    QColor colorDark;

    switch(nodeType)
    {
    case InterpPoints:
        color = QColor(Qt::blue);
        colorDark = QColor(Qt::darkBlue);
        break;
    case PseudoPoints:
        color = QColor(Qt::green);
        colorDark = QColor(Qt::darkGreen);
        break;
    case ControlPoints:
		x = -7;
		y = -7;
		width = 15;
		height = 15;
        color = QColor(Qt::yellow);
        colorDark = QColor(Qt::darkYellow);
        break;
	case CurvePoints:
		x = -2;
		y = -2;
		width = 5;
		height = 5;
		color = QColor(Qt::red);
        colorDark = QColor(Qt::darkRed);
		break;
    default:
        color = QColor(Qt::gray);
        colorDark = QColor(Qt::darkGray);
        break;
    }

    QRadialGradient gradient(-3, -3, 10);
    if (option->state & QStyle::State_Sunken) {
        gradient.setCenter(3, 3);
        gradient.setFocalPoint(3, 3);
        gradient.setColorAt(1, color.light(120));
        gradient.setColorAt(0, colorDark.light(120));
    } else {
        gradient.setColorAt(0, color);
        gradient.setColorAt(1, colorDark);
    }
    painter->setBrush(gradient);

    painter->setPen(QPen(Qt::black, 0));
    painter->drawEllipse(x, y, width, height);
}
Exemple #4
0
/*!
    Draw the needle

    \param painter Painter
    \param length Length of the needle
    \param colorGroup Color group, used for painting
*/
void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, 
    double length, QPalette::ColorGroup colorGroup ) const
{
    if ( d_style == ThinStyle )
    {
        const double width = qMax( length / 6.0, 3.0 );

        const int colorOffset = 10;

        const QColor light = palette().color( colorGroup, QPalette::Light );
        const QColor dark = palette().color( colorGroup, QPalette::Dark );

        qwtDrawShadedPointer( painter,
            dark.light( 100 + colorOffset ),
            dark.dark( 100 + colorOffset ),
            length, width );
        
        painter->rotate( 180.0 );
    
        qwtDrawShadedPointer( painter,
            light.light( 100 + colorOffset ),
            light.dark( 100 + colorOffset ),
            length, width );
        
        const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
        drawKnob( painter, width, baseBrush, true );
    }
    else
    {
        qwtDrawTriangleNeedle( painter, palette(), colorGroup, length );
    }
}
Exemple #5
0
void KoContextBarButton::paintEvent(QPaintEvent*)
{
    QStylePainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QStyleOptionToolButton opt;
    initStyleOption(&opt);

    const QColor bgColor = palette().color(QPalette::Highlight);
    QColor color = bgColor.dark(CONTEXTBAR_BACKGROUND_DARKNESS);
    QColor borderColor = bgColor.light(CONTEXTBAR_BORDER_LIGHTNESS);

    if (opt.state & QStyle::State_MouseOver && opt.state & QStyle::State_Enabled) {
            color = color.light(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
            borderColor = borderColor.lighter(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
    }

    const QRectF rectF = QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5);
    QPainterPath path;
    path.addRoundRect(rectF, CONTEXTBAR_RADIUS, CONTEXTBAR_RADIUS);

    if (m_fadingValue < 255) {
        color.setAlpha(m_fadingValue);
    }

    // Background
    painter.fillPath(path, color);

    if (opt.state & QStyle::State_Raised && opt.state & QStyle::State_Enabled) {
        // Bottom shadow
        QLinearGradient gradient(rectF.bottomLeft(), rectF.bottomLeft() - QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.bottomLeft() + QPoint(3, 0));
        painter.fillPath(path, gradient);
    }
    else {
        // Top shadow
        QLinearGradient gradient(rectF.topLeft(), rectF.topLeft() + QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.topLeft() + QPoint(5, 0));
        painter.fillPath(path, gradient);
    }

    // Border
    painter.setPen(QPen(borderColor, 0));
    painter.drawPath(path);

    // Content
    painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
}
Exemple #6
0
void BBTCOView::paintEvent( QPaintEvent * )
{
	QPainter p( this );

	QColor col = m_bbTCO->m_useStyleColor 
		? p.pen().brush().color()
		: m_bbTCO->colorObj();

	if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
	{
		col = QColor( 160, 160, 160 );
	}
	if( isSelected() == true )
	{
		col = QColor( qMax( col.red() - 128, 0 ),
					qMax( col.green() - 128, 0 ), 255 );
	}

	QLinearGradient lingrad( 0, 0, 0, height() );
	lingrad.setColorAt( 0, col.light( 130 ) );
	lingrad.setColorAt( 1, col.light( 70 ) );
	p.fillRect( rect(), lingrad );

	tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
	if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
	{
		for( int x = static_cast<int>( t * pixelsPerTact() );
								x < width()-2;
			x += static_cast<int>( t * pixelsPerTact() ) )
		{
			p.setPen( col.light( 80 ) );
			p.drawLine( x, 1, x, 5 );
			p.setPen( col.light( 120 ) );
			p.drawLine( x, height() - 6, x, height() - 2 );
		}
	}

	p.setPen( col.lighter( 130 ) );
	p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 );

	p.setPen( col.darker( 300 ) );
	p.drawRect( 0, 0, rect().right(), rect().bottom() );

	p.setFont( pointSize<8>( p.font() ) );
	
	p.setPen( QColor( 0, 0, 0 ) );
	p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
	p.setPen( textColor() );
	p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
	
	if( m_bbTCO->isMuted() )
	{
		p.drawPixmap( 3, p.fontMetrics().height() + 1,
				embed::getIconPixmap( "muted", 16, 16 ) );
	}
}
void SpreadSheet::updateColor(QTableWidgetItem *item)
{
    QPixmap pix(16, 16);
    QColor col;
    if (item)
        col = item->backgroundColor();
    if (!col.isValid())
        col = palette().base().color();

    QPainter pt(&pix);
    pt.fillRect(0, 0, 16, 16, col);

    QColor lighter = col.light();
    pt.setPen(lighter);
    QPoint lightFrame[] = { QPoint(0, 15), QPoint(0, 0), QPoint(15, 0) };
    pt.drawPolyline(lightFrame, 3);

    pt.setPen(col.dark());
    QPoint darkFrame[] = { QPoint(1, 15), QPoint(15, 15), QPoint(15, 1) };
    pt.drawPolyline(darkFrame, 3);

    pt.end();

    colorAction->setIcon(pix);
}
void NumberedTextView::textChanged( int pos, int removed, int added )
{
    Q_UNUSED( pos );

    if ( removed == 0 && added == 0 )
	return;

    QTextBlock block = highlight.block();
    QTextBlockFormat fmt = block.blockFormat();
    QColor bg = view->palette().base().color();
    fmt.setBackground( bg );
    highlight.setBlockFormat( fmt );

    int lineCount = 1;
    for ( QTextBlock block = view->document()->begin();
	  block.isValid(); block = block.next(), ++lineCount ) 
    {
        if ( lineCount == markedLine )
        {
            fmt = block.blockFormat();
            QColor bg = Qt::red;
            fmt.setBackground( bg.light(150) );

            highlight = QTextCursor( block );
            highlight.movePosition( QTextCursor::EndOfBlock, QTextCursor::KeepAnchor );
            highlight.setBlockFormat( fmt );

            break;
        }
    }
}
Exemple #9
0
QPixmap colorPixmap(int w, int h, QColor c)
{
  static QPixmap* pixs[37];
  static QColor cols[37];
  static bool inited = false;

  if (!inited) {
    for (int i=0;i<37;i++) pixs[i]=0;
    inited = true;
  }
  int hash = (w+h+c.red()+c.green()+c.blue()) % 37;
  if (pixs[hash]) {
    if ((pixs[hash]->width() == w) &&
        (pixs[hash]->height() == h) &&
        (cols[hash] == c))
      return *pixs[hash];

    delete pixs[hash];
  }


  QPixmap* pix = new QPixmap(w, h);
  pix->fill(c);
  QPainter p(pix);
  p.setPen(c.light());
  p.drawLine(0, 0, w-1, 0);
  p.drawLine(0, 0, 0, h-1);
  p.setPen(c.dark());
  p.drawLine(w-1, 0, w-1, h-1);
  p.drawLine(0, h-1, w-1, h-1);

  pixs[hash] = pix;
  cols[hash] = c;
  return *pix;
}
void Snake::paintEvent(QPaintEvent *event)
{//Paint the screen
    QPainter painter(this);
    QRect rect = QRect(10,10,600,600);
    painter.fillRect(rect,Qt::white);
    //painter.setRenderHint(QPainter::Antialiasing);
    for(int i = header_Index;i != tail_Index;i=(i+1)%Max)//Draw the snake
    {
        int sx=SnakeBody[i][0]*step+10;
        int sy=SnakeBody[i][1]*step+10;
        QBrush brush;QPen pen;
        QColor color =Qt::green;
        painter.setBrush(color);
        painter.drawRect(sx,sy,step,step);

        pen.setColor(color.light(200));
        pen.setWidth(1);
        painter.setPen(pen);
        painter.drawLine(sx,sy,sx,sy+step);
        painter.drawLine(sx,sy+step,sx+step,sy+step);
        painter.drawLine(sx,sy,sx+step,sy);
        painter.drawLine(sx+step,sy,sx+step,sy+step);

    }
    painter.setPen(Qt::NoPen);
    painter.setBrush(getColor());
    if(timer->isActive())//Draw food
        painter.drawRect(eat_X*step+10,eat_Y*step+10,step,step);
}
void
ResizeCorner::setColor(const QColor &c)
{
    QColor bgc = (c.value() > 100) ? c.dark(130) : c.light(120);
    QPalette pal = palette();
    pal.setColor(backgroundRole(), bgc);
    setPalette(pal);
}
Exemple #12
0
void KNoteTip::setColor(const QColor &fg, const QColor &bg)
{
    QPalette newpalette = palette();
    newpalette.setColor(QColorGroup::Background, bg);
    newpalette.setColor(QColorGroup::Foreground, fg);
    newpalette.setColor(QColorGroup::Base,       bg);   // text background
    newpalette.setColor(QColorGroup::Text,       fg);   // text color
    newpalette.setColor(QColorGroup::Button,     bg);

    // the shadow
    newpalette.setColor(QColorGroup::Midlight, bg.light(110));
    newpalette.setColor(QColorGroup::Shadow, bg.dark(116));
    newpalette.setColor(QColorGroup::Light, bg.light(180));
    newpalette.setColor(QColorGroup::Dark, bg.dark(108));
    setPalette(newpalette);

    // set the text color
    mPreview->setColor(fg);
}
Exemple #13
0
static QGradient gradient(const QColor &color, const QRect &rect)
{
    QColor c = color;
    c.setAlpha(160);
    QLinearGradient result(rect.topLeft(), rect.bottomRight());
    result.setColorAt(0, c.dark(150));
    result.setColorAt(0.5, c.light(200));
    result.setColorAt(1, c.dark(150));
    return result;
}
Exemple #14
0
void LineChart::setColor(const QColor &symbolColor)
{
  setRenderHint(QwtPlotCurve::RenderAntialiased);
  QColor color = symbolColor;
  QPen pen = QPen(color);
  pen.setWidthF(PEN_WIDTH);
  setPen(pen);
  setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
          symbolColor.light(150), symbolColor, QSize(8, 8)));
}
Exemple #15
0
void QGILineBinder::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
	if( ! this->isValid() ) return;// schedule our own destruction here.
	QVariant var;
	static const double Pi = 3.14159265358979323846264338327950288419717;
	static double TwoPi = 2.0 * Pi;
	var = this->property("width");
	qreal lineWidth = (var.isValid() ? var.toDouble() : 2.0);
	var = this->property("color");
	QColor lineColor = (var.isValid() ? var.value<QColor>() : Qt::black);
	var = this->property("style");
	int lineStyle = (var.isValid() ? var.toInt() : Qt::SolidLine);
	if( Qt::NoPen == lineStyle ) lineStyle = Qt::SolidLine;


	Qt::PenCapStyle capS(Qt::RoundCap);
	Qt::PenJoinStyle joinS(Qt::RoundJoin);

	// Draw the line itself
	QLineF line(impl->pts.first, impl->pts.second);
	var = this->property("alpha");
	if( var.isValid() ) lineColor.setAlpha( var.toInt() ); 
	painter->save();
	painter->setPen(QPen(lineColor, lineWidth, Qt::PenStyle(lineStyle), capS, joinS));
	painter->drawLine(line);
	painter->restore();

	if( this->property("drawArrows").toInt() )
	{
		var = this->property("arrowSize");
		qreal arrowSize = var.isValid() ? var.toDouble() : Impl::defaultArrowSize;
		// Draw the arrows if there's enough room
		double angle = std::acos(line.dx() / line.length());
		if (line.dy() >= 0)
		{
			angle = TwoPi - angle;
		}		
		QPointF sourceArrowP1 = impl->pts.first + QPointF(std::sin(angle + Pi / 3) * arrowSize,
			std::cos(angle + Pi / 3) * arrowSize);
		QPointF sourceArrowP2 = impl->pts.first + QPointF(std::sin(angle + Pi - Pi / 3) * arrowSize,
			std::cos(angle + Pi - Pi / 3) * arrowSize);   
		QPointF destArrowP1 = impl->pts.second + QPointF(std::sin(angle - Pi / 3) * arrowSize,
			std::cos(angle - Pi / 3) * arrowSize);
		QPointF destArrowP2 = impl->pts.second + QPointF(std::sin(angle - Pi + Pi / 3) * arrowSize,
			std::cos(angle - Pi + Pi / 3) * arrowSize);
		painter->setPen(QPen(lineColor, 2, Qt::SolidLine, capS, joinS ));
		painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2, Qt::WindingFill);
		painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2, Qt::WindingFill);
	}
	if( this->isSelected() )
	{ // doesn't seem to do what i want?
		painter->setPen( QPen(lineColor.light(), 1, Qt::DotLine, capS, joinS));
		painter->drawLine( line );
	}
}
Exemple #16
0
void CommonItemMECS::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color;
    if (option->state & QStyle::State_MouseOver)
        fillColor = fillColor.light(125);

    QPen oldPen = painter->pen();
    QPen pen = oldPen;
    int width = 0;
    if (option->state & QStyle::State_Selected)
        width += 2;

    pen.setWidth(width);
    pen.setColor(Qt::white);
    QBrush b = painter->brush();
    if (m_backgroundImage.isEmpty())
    {
        painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100)));
        painter->drawRect(boundingRect());
        painter->setBrush(b);
    }
    else
    {
        QPen oldPenBorder = painter->pen();
        QPen *penBorder = new QPen(Qt::red);
        penBorder->setWidth(3);
        penBorder->setStyle(Qt::DotLine);
        painter->setPen(*penBorder);
        painter->drawRect(boundingRect());
        painter->drawImage(boundingRect().topLeft(), *m_backGroundImageCache);
        painter->setPen(oldPenBorder);
    }

    painter->setPen(pen);
    painter->drawText(boundingRect(), m_itemFlags, m_text);
    painter->setPen(oldPen);

    if (m_removed)
    {
        QPen oldPenBorder = painter->pen();
        QPen *penBorder = new QPen(Qt::red);
        penBorder->setWidth(3);
        penBorder->setStyle(Qt::SolidLine);
        painter->setPen(*penBorder);
        painter->drawLine(boundingRect().topLeft(), boundingRect().bottomRight());
        painter->drawLine(boundingRect().bottomLeft(), boundingRect().topRight());
        painter->setPen(oldPenBorder);
    }

return;

}
Exemple #17
0
void KLed::paintLed(Shape shape, Look look)
{
    if (paintCachedPixmap()) {
        return;
    }

    QSize size(width() - 2, height() - 2);
    if (shape == Circular) {
        const int width = ledWidth();
        size = QSize(width, width);
    }
    QPointF center(size.width() / 2.0, size.height() / 2.0);
    const int smallestSize = qMin(size.width(), size.height());
    QPainter painter;

    QImage image(size, QImage::Format_ARGB32_Premultiplied);
    image.fill(0);

    QRadialGradient fillGradient(center, smallestSize / 2.0, QPointF(center.x(), size.height() / 3.0));
    const QColor fillColor = d->state != Off ? d->color : d->color.dark(d->darkFactor);
    fillGradient.setColorAt(0.0, fillColor.light(250));
    fillGradient.setColorAt(0.5, fillColor.light(130));
    fillGradient.setColorAt(1.0, fillColor);

    QConicalGradient borderGradient(center, look == Sunken ? 90 : -90);
    QColor borderColor = palette().color(QPalette::Dark);
    if (d->state == On) {
        QColor glowOverlay = fillColor;
        glowOverlay.setAlpha(80);
        borderColor = KColorUtils::overlayColors(borderColor, glowOverlay);
    }
    borderGradient.setColorAt(0.2, borderColor);
    borderGradient.setColorAt(0.5, palette().color(QPalette::Light));
    borderGradient.setColorAt(0.8, borderColor);

    painter.begin(&image);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setBrush(look == Flat ? QBrush(fillColor) : QBrush(fillGradient));
    const QBrush penBrush = (look == Flat) ? QBrush(borderColor) : QBrush(borderGradient);
    const qreal penWidth = smallestSize / 8.0;
    painter.setPen(QPen(penBrush, penWidth));
    QRectF r(penWidth / 2.0, penWidth / 2.0, size.width() - penWidth, size.height() - penWidth);
    if (shape == Rectangular) {
        painter.drawRect(r);
    } else {
        painter.drawEllipse(r);
    }
    painter.end();

    d->cachedPixmap[d->state] = QPixmap::fromImage(image);
    painter.begin(this);
    painter.drawPixmap(1, 1, d->cachedPixmap[d->state]);
    painter.end();
}
Exemple #18
0
QPalette CockpitGrid::colorTheme( const QColor &base ) const
{
    QPalette palette;
    palette.setColor( QPalette::Base, base );
    palette.setColor( QPalette::Window, base.dark( 150 ) );
    palette.setColor( QPalette::Mid, base.dark( 110 ) );
    palette.setColor( QPalette::Light, base.light( 170 ) );
    palette.setColor( QPalette::Dark, base.dark( 170 ) );
    palette.setColor( QPalette::Text, base.dark( 200 ).light( 800 ) );
    palette.setColor( QPalette::WindowText, base.dark( 200 ) );

    return palette;
}
Exemple #19
0
static void qwtDrawTriangleNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    double length )
{
    const double width = qRound( length / 3.0 );

    QPainterPath path[4];

    path[0].lineTo( length, 0.0 );
    path[0].lineTo( 0.0, width / 2 );

    path[1].lineTo( length, 0.0 );
    path[1].lineTo( 0.0, -width / 2 );

    path[2].lineTo( -length, 0.0 );
    path[2].lineTo( 0.0, width / 2 );

    path[3].lineTo( -length, 0.0 );
    path[3].lineTo( 0.0, -width / 2 );


    const int colorOffset =  10;
    const QColor darkColor = palette.color( colorGroup, QPalette::Dark );
    const QColor lightColor = palette.color( colorGroup, QPalette::Light );

    QColor color[4];
    color[0] = darkColor.light( 100 + colorOffset );
    color[1] = darkColor.dark( 100 + colorOffset );
    color[2] = lightColor.light( 100 + colorOffset );
    color[3] = lightColor.dark( 100 + colorOffset );

    painter->setPen( Qt::NoPen );

    for ( int i = 0; i < 4; i++ )
    {
        painter->setBrush( color[i] );
        painter->drawPath( path[i] );
    }
}
Exemple #20
0
void HDDRank::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    QColor c = (load > 60)? Qt::red : Qt::green;

    c = (option->state & QStyle::State_Selected) ? c.dark(150) : c;
    if (option->state & QStyle::State_MouseOver)
        c = c.light(125);

    painter->drawRect(QRectF(0, 0, 60, 100));
    painter->fillRect(QRectF(0, 100-load, 60, load), c);
}
Exemple #21
0
void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const
{
    QColor highlight = qxt_p().palette().color(QPalette::Highlight);
    QLinearGradient gradient(x1, y1, x2, y2);
    gradient.setColorAt(0, highlight.dark(120));
    gradient.setColorAt(1, highlight.light(108));
    painter->setBrush(gradient);

    if (orientation == Qt::Horizontal)
        painter->setPen(QPen(highlight.dark(130), 0));
    else
        painter->setPen(QPen(highlight.dark(150), 0));
}
void ProcessorStatusGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                        QWidget* widget) {
    qreal ledRadius = size_ / 2.0f;
    QColor baseColor(0, 170, 0);

    QColor ledColor;
    QColor borderColor;

    switch (state_) {
        case State::Ready:
            ledColor = baseColor;
            borderColor = QColor(124, 124, 124);
            break;
        case State::Running:
            ledColor = Qt::yellow;
            borderColor = QColor(124, 124, 124);
            break;
        case State::Invalid:
            ledColor = baseColor.dark(400);
            borderColor = QColor(64, 64, 64);
            break;
    }
    current_ = state_;

    // initialize painter
    p->save();
    p->setPen(QPen(borderColor, 3.0));
    p->setRenderHint(QPainter::Antialiasing, true);
    p->setBrush(QBrush(ledColor));
    // draw base shape
    p->drawEllipse(QPointF(0.0f, 0.0f), ledRadius, ledRadius);
    // draw light highlight
    QPointF highLightPos = QPointF(0.0f, 0.0f);
    p->setPen(Qt::NoPen);

    while (ledRadius > 0.0) {
        ledColor = ledColor.light(120);
        p->setBrush(QBrush(ledColor));
        p->drawEllipse(highLightPos, ledRadius, ledRadius);
        ledRadius -= 0.25;
        p->drawEllipse(highLightPos, ledRadius, ledRadius);
        ledRadius -= 0.25;
        p->drawEllipse(highLightPos, ledRadius, ledRadius);
        ledRadius -= 0.25;
        highLightPos.setX(highLightPos.x() - 0.25);
        highLightPos.setY(highLightPos.y() - 0.25);
    }

    // deinitialize painter
    p->restore();
}
Exemple #23
0
void PaletteEditor::buildInactiveEffect()
{
    QColorGroup cg = editPalette.inactive();

    QColor light, midlight, mid, dark, shadow;
    QColor btn = cg.color( QColorGroup::Button );

    light = btn.light(150);
    midlight = btn.light(115);
    mid = btn.dark(150);
    dark = btn.dark();
    shadow = black;

    cg.setColor( QColorGroup::Light, light );
    cg.setColor( QColorGroup::Midlight, midlight );
    cg.setColor( QColorGroup::Mid, mid );
    cg.setColor( QColorGroup::Dark, dark );
    cg.setColor( QColorGroup::Shadow, shadow );

    editPalette.setInactive( cg );
    setPreviewPalette( editPalette );
    updateStyledButtons();
}
void CSliderMultiPos::setupPainter(QPainter* painter,QPointF point1,QPointF point2,QColor color){

    QLinearGradient gradient(point1,point2);
    gradient.setColorAt(0, color.dark(120));
    gradient.setColorAt(1, color.light(108));
    painter->setBrush(gradient);

    if( this->orientation()==Qt::Horizontal) {
        painter->setPen(QPen(color.dark(130), 0));
    }
    else{
        painter->setPen(QPen(color.dark(150), 0));
    }
}
Exemple #25
0
void DSS::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    QColor fillColor = (option->state & QStyle::State_Selected) ? health.dark(150) : health;
    if (option->state & QStyle::State_MouseOver)
        fillColor = fillColor.light(125);

    const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform());
    if (lod < 2)
    {
        painter->fillRect(QRectF(0, 0, 140, 200), fillColor);


        if(lod > 0.5)
        {
            QFont font("Times", 10);
            font.setStyleStrategy(QFont::ForceOutline);
            painter->setFont(font);
            painter->save();
            painter->drawText(40, 180, name);
            painter->restore();
        }


        return;
    }

    if ( lod >= 2)
    {
        (health == Qt::red)? painter->fillRect(QRectF(0, 0, 70, 100),Qt::red) : painter->drawRect(QRectF(0, 0, 70, 100));
        painter->drawRect(QRectF(70, 0, 70, 100));
        painter->drawRect(QRectF(0, 100, 70, 100));
        painter->drawRect(QRectF(70, 100, 70, 100));


        QFont font("Times", 10);
        font.setStyleStrategy(QFont::ForceOutline);
        painter->setFont(font);
        painter->save();
        painter->drawText(144, 16, name + " Type: XP7");

        painter->drawText(18, 55,  " HDD");
        painter->drawText(88, 55, " HDD");
        painter->drawText(18, 155, " FMD");
        painter->drawText(88, 155,  " SSD");

        painter->restore();
    }
}
void PaletteEditorAdvanced::buildDisabledEffect()
{
    QColorGroup cg = editPalette.disabled();

    QColor light, midlight, mid, dark, shadow;
    QColor btn = cg.color( QColorGroup::Button );

    light = btn.light(150);
    midlight = btn.light(115);
    mid = btn.dark(150);
    dark = btn.dark();
    shadow = black;

    cg.setColor( QColorGroup::Light, light );
    cg.setColor( QColorGroup::Midlight, midlight );
    cg.setColor( QColorGroup::Mid, mid );
    cg.setColor( QColorGroup::Dark, dark );
    cg.setColor( QColorGroup::Shadow, shadow );

    editPalette.setDisabled( cg );
    setPreviewPalette( editPalette );
    updateColorButtons();
}
Exemple #27
0
void QGILineNode::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
	painter->setPen(Qt::NoPen);
	painter->setBrush(Qt::darkGray);
	painter->drawEllipse(-7, -7, 20, 20);
	QRadialGradient gradient(-3, -3, 10);
	QVariant var = this->property("color");
	QColor color = (var.isValid() ? var.value<QColor>() : Qt::yellow);
	QColor darker = color.darker();
	//if (option->state & QStyle::State_Sunken) {
	if( this->m_active ){
		gradient.setCenter(3, 3);
		gradient.setFocalPoint(3, 3);
		gradient.setColorAt(1, color.light(150));
		gradient.setColorAt(0, darker.light(150));
	} else {
		gradient.setColorAt(0, color);
		gradient.setColorAt(1, darker);
	}
	painter->setBrush(gradient);
	painter->setPen(QPen(Qt::black, 0));
	painter->drawEllipse(-10, -10, 20, 20);
	// FIXME: render some notification when selected.
}
Exemple #28
0
QColor KGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
{
    if (base == Qt::white)
        return QColor(238,246,255);
    else
    {
        int h, s, v;
        base.hsv( &h, &s, &v );
        if (v > 128)
            return base.dark(106);
        else if (base != Qt::black)
            return base.light(110);

        return QColor(32,32,32);
    }
}
void CompositionRenderer::drawSource(QPainter &p)
{
    p.setPen(Qt::NoPen);
    p.setRenderHint(QPainter::Antialiasing);
    p.setCompositionMode(m_composition_mode);

    QRectF circle_rect = rectangle_around(m_circle_pos);
    QColor color = QColor::fromHsvF(m_circle_hue / 360.0, 1, 1, m_circle_alpha / 255.0);
    QLinearGradient circle_gradient(circle_rect.topLeft(), circle_rect.bottomRight());
    circle_gradient.setColorAt(0, color.light());
    circle_gradient.setColorAt(0.5, color);
    circle_gradient.setColorAt(1, color.dark());
    p.setBrush(circle_gradient);

    p.drawEllipse(circle_rect);
}
Exemple #30
0
void Building::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    this->setToolTip(_building.getAddress());

    QColor currColor = (_isHighlight ? ColorTheme().buildingSelected : ColorTheme().building);
    QColor fillColor = (option->state & QStyle::State_Selected) ? currColor.dark(150) : currColor;
    const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform());

    if (option->state & QStyle::State_MouseOver)
        fillColor = fillColor.light(125);

    auto path = _building.toPolygonF();
    QPainterPath polygonPath;

    polygonPath.addPolygon(path);
    painter->setPen(QPen(ColorTheme().buildingBorder, 0.5));

    if (lod > 1.5)
        painter->drawPolygon(path);

    painter->fillPath(polygonPath, fillColor);

    if (_isHighlight)
    {
        painter->setPen(QPen(Qt::blue, 0.05));

        for (NearRoad road: _building.nearRoads)
            painter->drawLine(road.nearLine);
    }

    if (lod >= 2.8)
    {
        QFont font("Times", 2);

        font.setStyleStrategy(QFont::ForceOutline);
        painter->setPen(QPen(Qt::black, 0.5));
        painter->setFont(font);

        QPointF centerP = _building.housenumberPos;
        QPointF deltaP(100., 100.);

        painter->drawText(QRectF(centerP - deltaP, centerP + deltaP), Qt::AlignCenter | Qt::AlignHCenter, QString(_building.housenumber.c_str()));
    }
}