Example #1
0
void UserWidget::updateColors()
{
    QPalette p = palette();

    // Set background to transparent and use the theme to provide contrast with the text
    p.setColor(QPalette::Base, Qt::transparent); // new in Qt 4.5
    p.setColor(QPalette::Window, Qt::transparent); // For Qt 4.4, remove when we depend on 4.5


    QColor text = Theme::defaultTheme()->color(Theme::TextColor);
    QColor link = Theme::defaultTheme()->color(Theme::TextColor);
    link.setAlphaF(qreal(.8));
    QColor linkvisited = Theme::defaultTheme()->color(Theme::TextColor);
    linkvisited.setAlphaF(qreal(.6));

    p.setColor(QPalette::Text, text);
    p.setColor(QPalette::Link, link);
    p.setColor(QPalette::LinkVisited, linkvisited);

    setPalette(p);

    if (m_nameLabel) {
        m_nameLabel->setPalette(p);
        if (m_css) {
            m_nameLabel->setStyleSheet(m_css->styleSheet());
        }
        m_infoView->page()->setPalette(p);
    }
    update();
    // kDebug() << "CSS:" << m_css->styleSheet();
}
Example #2
0
QColor Viewport::determineColor(const QColor &basecolor,
                                float weight, float totalweight,
                                bool highlighted, bool single)
{
	QColor color = basecolor;
	qreal alpha;
	/* TODO: this is far from optimal yet. challenge is to give a good
	   view where important information is not lost, yet not clutter
	   the view with too much low-weight information */
	/* logarithm is used to prevent single data points to get lost.
	   this should be configurable. */
	alpha = useralpha;
	if (drawLog->isChecked())
		alpha *= (0.01 + 0.99*(std::log(weight+1) / std::log(totalweight)));
	else
		alpha *= (0.01 + 0.99*(weight / totalweight));
	color.setAlphaF(std::min(alpha, 1.)); // cap at 1

	if (highlighted) {
		if (basecolor == Qt::white) {
			color = Qt::yellow;
		} else {
			color.setGreen(std::min(color.green() + 195, 255));
			color.setRed(std::min(color.red() + 195, 255));
			color.setBlue(color.blue()/2);
		}
		color.setAlphaF(1.);
	}

	// recolor singleLabel (and make 100% opaque)
	if (single) {
		color.setRgbF(1., 1., 0., 1.);
	}
	return color;
}
Example #3
0
void VariableEditor::paintEvent(QPaintEvent* event)
{
  QWidget::paintEvent(event);

  // draw highlighting rect like in plasma
  if (underMouse()) {
    QPainter painter(this);

    painter.setRenderHint(QPainter::Antialiasing);

    QColor cornerColor = palette().color(QPalette::Highlight);
    cornerColor.setAlphaF(0.2);

    QColor midColor = palette().color(QPalette::Highlight);
    midColor.setAlphaF(0.5);

    QRect highlightRect = rect().adjusted(2, 2, -2, -2);

    QPen outlinePen;
    outlinePen.setWidth(2);

    QLinearGradient gradient(highlightRect.topLeft(), highlightRect.topRight());
    gradient.setColorAt(0, cornerColor);
    gradient.setColorAt(0.3, midColor);
    gradient.setColorAt(1, cornerColor);
    outlinePen.setBrush(gradient);
    painter.setPen(outlinePen);

    const int radius = 5;
    painter.drawRoundedRect(highlightRect, radius, radius);
  }
}
void Layer_list_model::transparency_slider_changed(int) {
	if (l == 0) return;
	QColor color = l->get_color();
	color.setAlphaF(transparency_slider->value_to_float());

	l->set_color(color);
	//std::cout << "Color set with transparency: " << transparency_slider->value_to_float() << std::endl;
	QColor ambient = l->get_ambient();
	ambient.setAlphaF(transparency_slider->value_to_float());
	QColor diffuse = l->get_diffuse();
	l->set_diffuse(diffuse);
	diffuse.setAlphaF(transparency_slider->value_to_float());
	QColor specular = l->get_specular();
	l->set_specular(specular);
	specular.setAlphaF(transparency_slider->value_to_float());
	QColor emission = l->get_emission();
	emission.setAlphaF(transparency_slider->value_to_float());
	l->set_emission(emission);
#ifdef INVALIDATE_CACHE_AT_COLOR_CHANGE
	l->invalidate_cache(); /// \todo why do I need this for colors? it should work without invalidating with the display lists
#endif
	if (l->has_property(Managable_layer::SCALAR_EDITABLE)) {
		l->invalidate_cache();
		l->has_new_range = false;
	}
	emit widget_needs_repaint();
}
Example #5
0
void
Context::Applet::addGradientToAppletBackground( QPainter* p )
{
    // tint the whole applet
    // draw non-gradient backround. going for elegance and style
    const QRectF roundRect = boundingRect().adjusted( 0, 1, -1, -1 );

    p->save();
    p->setRenderHint( QPainter::Antialiasing );
    QPainterPath path;
    path.addRoundedRect( roundRect, 4, 4 );
    QColor highlight = PaletteHandler::highlightColor( 0.4, 1.05 );
    highlight.setAlphaF( highlight.alphaF() * 0.5 );
    p->fillPath( path, highlight );
    p->restore();

    p->save();
    p->setRenderHint( QPainter::Antialiasing );
    p->translate( 0.5, 0.5 );
    QColor col = PaletteHandler::highlightColor( 0.3, 0.5 );
    col.setAlphaF( col.alphaF() * 0.7 );
    p->setPen( col );
    p->drawRoundedRect( roundRect, 4, 4 );
    p->restore();
}
void RatingComboBoxWidget::paintEvent(QPaintEvent* e)
{
    if (m_value >= RatingComboBox::Rating0)
    {
        //kDebug() << "m_value" << m_value << "defaulting paint to parent" << this;
        RatingWidget::paintEvent(e);
    }
    else if (m_value == RatingComboBox::NoRating)
    {
        QPainter p(this);

        QPixmap pix = starPixmap();
        int width = pix.width();
        p.drawPixmap(0, 0, pix);
        // draw red cross
        p.setPen(Qt::red);
        p.drawLine(0, 0, width, width);
        p.drawLine(0, width, width, 0);
    }
    else if (m_value == RatingComboBox::Null)
    {
        QPainter p(this);

        if (underMouse() && isEnabled())
        {
            QPixmap pix = starPixmap();
            int x = 0;

            for (int i = 0; i < RatingMax; ++i)
            {
                p.drawPixmap(x, 0, pix);
                x += pix.width();
            }
        }
        else
        {
            p.setRenderHint(QPainter::Antialiasing, true);
            //pen.setJoinStyle(Qt::MiterJoin);

            QColor foreground = palette().color(QPalette::Active, QPalette::Foreground);
            QColor background = palette().color(QPalette::Active, QPalette::Background);
            foreground.setAlphaF(foreground.alphaF() * 0.5);
            background.setAlphaF(background.alphaF() * 0.5);
            QColor foregroundEnd(foreground), backgroundEnd(background);
            foregroundEnd.setAlphaF(0);
            backgroundEnd.setAlphaF(0);

            QLinearGradient grad(QPointF(0, (double)rect().height() / 2), QPointF(width(), (double)rect().height() / 2));
            grad.setColorAt(0, foreground);
            grad.setColorAt(1, foregroundEnd);
            p.setPen(QPen(grad, 0));

            grad.setColorAt(0, background);
            grad.setColorAt(1, backgroundEnd);
            p.setBrush(grad);

            drawStarPolygons(&p, 5);
        }
    }
}
void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
  QColor penColor = mColor;
  penColor.setAlphaF( context.alpha() );
  mPen.setColor( penColor );
  double scaledWidth = context.outputLineWidth( mWidth );
  mPen.setWidthF( scaledWidth );
  if ( mUseCustomDashPattern && scaledWidth != 0 )
  {
    mPen.setStyle( Qt::CustomDashLine );

    //scale pattern vector
    QVector<qreal> scaledVector;
    QVector<qreal>::const_iterator it = mCustomDashVector.constBegin();
    for ( ; it != mCustomDashVector.constEnd(); ++it )
    {
      //the dash is specified in terms of pen widths, therefore the division
      scaledVector << context.outputLineWidth(( *it ) / scaledWidth );
    }
    mPen.setDashPattern( scaledVector );
  }
  else
  {
    mPen.setStyle( mPenStyle );
  }
  mPen.setJoinStyle( mPenJoinStyle );
  mPen.setCapStyle( mPenCapStyle );

  mSelPen = mPen;
  QColor selColor = context.selectionColor();
  if ( ! selectionIsOpaque )
    selColor.setAlphaF( context.alpha() );
  mSelPen.setColor( selColor );
}
Example #8
0
void WaveformMarkRange::generateImage(int weidth, int height) {
    m_activeImage = QImage(weidth, height, QImage::Format_ARGB32_Premultiplied);
    m_disabledImage = QImage(weidth, height, QImage::Format_ARGB32_Premultiplied);

    // fill needed cause they remain transparent
    m_activeImage.fill(QColor(0,0,0,0).rgba());
    m_disabledImage.fill(QColor(0,0,0,0).rgba());

    QColor activeColor = m_activeColor;
    activeColor.setAlphaF(0.3);
    QBrush brush(activeColor);

    QPainter painter;
    painter.begin(&m_activeImage);
    painter.fillRect(m_activeImage.rect(), brush);
    painter.end();

    QColor disabledColor = m_disabledColor;
    disabledColor.setAlphaF(0.3);
    brush = QBrush(disabledColor);

    painter.begin(&m_disabledImage);
    painter.fillRect(m_disabledImage.rect(), brush);
    painter.end();
}
Example #9
0
QColor ColorRangeBase::toColor(const QVariant &v, ColorRangeBase::ColorModel colormodel)
{
    if ( v.type() == QVariant::Color)
        return QColor(v.value<QColor>());
    else if ( v.type() == QVariant::String){
        QRegExp separ("[(]|,|[)]");
        QStringList parts = (v.toString()).split(separ);
        if(parts.last().isEmpty())
            parts.removeLast();
        QColor clr;
        bool ok1,ok2,ok3,ok4,ok5 =true;
        if ( parts.size() >= 5){
            double component1 = parts[1].toDouble(&ok1);
            double component2 = parts[2].toDouble(&ok2);
            double component3 = parts[3].toDouble(&ok3);
            double component4 = parts[4].toDouble(&ok4);
            double component5 =  parts.size()== 6 ? parts[5].toDouble(&ok5) : rUNDEF;
            if(! (ok1 && ok2 && ok3 && ok4 && ok5))
                return QColor();

            bool isFractional =  component1 <= 1 && component2 <= 1 && component3 <= 1 && component4 <= 1;
            if ( parts[0].toLower() == "rgba"){
                if ( isFractional){
                   clr.setRgbF(component1,component2, component3);
                   clr.setAlphaF(component4);
                }
                else{
                    clr.setRgb(component1,component2, component3);
                    clr.setAlpha(component4);
                }
            }else if ( parts[0].toLower() == "hsla"){
                if ( isFractional){
                   clr.setHslF(component1,component2, component3);
                   clr.setAlphaF(component4);
                }
                else{
                    clr.setHsl(component1,component2, component3);
                    clr.setAlpha(component4);
                }

            } else if ( parts[0].toLower() == "cmyka" && parts.size() == 6){
                if ( isFractional){
                   clr.setCmykF(component1,component2, component3, component4);
                   clr.setAlphaF(component5);
                }
                else{
                    clr.setCmyk(component1,component2, component3, component4);
                    clr.setAlpha(component5);
                }
            }
            return clr;
        }
    } else if( v.type() == QVariant::ULongLong){
        return ColorRangeBase::toColor(v.toULongLong(),colormodel);
    } else if( v.type() == QVariant::Double){
        return ColorRangeBase::toColor(v.toULongLong(),colormodel);
    }

    return QColor();
}
Example #10
0
SelectionDrawer::SelectionDrawer(DrawerInterface *parentDrawer, RootDrawer *rootdrawer, const IOOptions &options) : SimpleDrawer("SelectionDrawer", parentDrawer,rootdrawer, options)
{
    _vertexShader = "featurevertexshader_nvdia.glsl";
    _fragmentShader = "featurefragmentshader_nvdia.glsl";

    QColor clr;
    _colors.resize(13);
    if ( options.contains("areacolor")){
        clr = options["areacolor"].value<QColor>();
    }else {
        clr = QColor(80,80,0);
        clr.setAlphaF(0.15);
    }
    _colors[9] = _colors[10] = _colors[11] = _colors[12] = clr;
    clr.setAlphaF(0.5);
    _colors[5] = _colors[6] = _colors[7] = _colors[8] = clr;

    if ( options.contains("bordercolor")){
        clr = options["bordercolor"].value<QColor>();
    }else {
        clr = QColor(0,0,0);
        clr.setAlphaF(1);
    }
    _colors[0] = _colors[1] = _colors[2] = _colors[3] = _colors[4] = clr;
    QVector3D pos(0,0,0);
    _vertices = { pos,pos,pos,pos,pos, pos,pos,pos,pos, pos,pos,pos,pos};

    _indices.push_back(VertexIndex(0, 5, itLINE, iUNDEF));
    _indices.push_back(VertexIndex(5, 2, itLINE, iUNDEF));
    _indices.push_back(VertexIndex(7, 2, itLINE, iUNDEF));
    _indices.push_back(VertexIndex(9, 4, itPOLYGON, iUNDEF));
}
Example #11
0
void QgsLabelingGui::updatePreview()
{
  scrollPreview();
  lblFontPreview->setFont( mRefFont );
  QFont previewFont = lblFontPreview->font();
  if ( mFontSizeUnitComboBox->currentIndex() == 1 )
  {
    // TODO: maybe match current map zoom level instead?
    previewFont.setPointSize( 24 );
    groupBox_mPreview->setTitle( tr( "Sample @ 24 pts (using map units)" ) );
  }
  else
  {
    previewFont.setPointSize( mFontSizeSpinBox->value() );
    groupBox_mPreview->setTitle( tr( "Sample" ) );
  }
  lblFontPreview->setFont( previewFont );

  QColor prevColor = btnTextColor->color();
  prevColor.setAlphaF(( 100.0 - ( double )( mFontTranspSpinBox->value() ) ) / 100.0 );
  lblFontPreview->setTextColor( prevColor );
  if ( chkBuffer->isChecked() )
  {
    QColor buffColor = btnBufferColor->color();
    buffColor.setAlphaF(( 100.0 - ( double )( mBufferTranspSpinBox->value() ) ) / 100.0 );
    lblFontPreview->setBuffer( spinBufferSize->value(), buffColor );
  }
  else
  {
    lblFontPreview->setBuffer( 0, Qt::white );
  }
}
void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
  QColor fillColor = mColor;
  fillColor.setAlphaF( context.alpha() * mColor.alphaF() );
  mBrush = QBrush( fillColor, mBrushStyle );

  // scale brush content for printout
  double rasterScaleFactor = context.renderContext().rasterScaleFactor();
  if ( rasterScaleFactor != 1.0 )
  {
    mBrush.setMatrix( QMatrix().scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ) );
  }

  QColor selColor = context.selectionColor();
  QColor selPenColor = selColor == mColor ? selColor : mBorderColor;
  if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
  mSelBrush = QBrush( selColor );
  // N.B. unless a "selection line color" is implemented in addition to the "selection color" option
  // this would mean symbols with "no fill" look the same whether or not they are selected
  if ( selectFillStyle )
    mSelBrush.setStyle( mBrushStyle );

  QColor borderColor = mBorderColor;
  borderColor.setAlphaF( context.alpha() * mBorderColor.alphaF() );
  mPen = QPen( borderColor );
  mSelPen = QPen( selPenColor );
  mPen.setStyle( mBorderStyle );
  mPen.setWidthF( context.outputLineWidth( mBorderWidth ) );
}
void BurstShot::draw(QPainter *painter)
{
    painter->save();
    QColor whiteBeam(0,255,255,255);
    QColor blackBeam(255,0,0,255);

    QColor *currentColor = polarity == WHITE? &whiteBeam: &blackBeam;
    currentColor->setAlphaF(0.25f);
    QPen pen(*currentColor, 15, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    painter->setPen(pen);
    drawLines(painter, 15);
    currentColor->setAlphaF(0.5f);
    pen.setColor(*currentColor);
    pen.setWidth(4);
    painter->setPen(pen);
    drawLines(painter, 10);
    pen.setColor(polarity == WHITE? Qt::white : Qt::black);
    pen.setWidth(2);
    painter->setPen(pen);
    drawLines(painter, 5);


    //debug
//    pen.setColor(Qt::green);
//    painter->setPen(pen);
//    painter->drawRect(hitBox);

    painter->restore();
}
void QgsComposerPictureWidget::updateSvgParamGui( bool resetValues )
{
  if ( !mPicture )
    return;

  QString picturePath = mPicture->picturePath();
  if ( !picturePath.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) )
  {
    mFillColorButton->setEnabled( false );
    mStrokeColorButton->setEnabled( false );
    mStrokeWidthSpinBox->setEnabled( false );
    return;
  }

  //activate gui for svg parameters only if supported by the svg file
  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
  QColor defaultFill, defaultStroke;
  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
  QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill,
      hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
      hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
      hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
      hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );

  if ( resetValues )
  {
    QColor fill = mFillColorButton->color();
    double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
    if ( hasDefaultFillColor )
    {
      fill = defaultFill;
    }
    fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
    mFillColorButton->setColor( fill );
  }
  mFillColorButton->setEnabled( hasFillParam );
  mFillColorButton->setAllowOpacity( hasFillOpacityParam );
  if ( resetValues )
  {
    QColor stroke = mStrokeColorButton->color();
    double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
    if ( hasDefaultStrokeColor )
    {
      stroke = defaultStroke;
    }
    stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
    mStrokeColorButton->setColor( stroke );
  }
  mStrokeColorButton->setEnabled( hasStrokeParam );
  mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
  if ( hasDefaultStrokeWidth && resetValues )
  {
    mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
  }
  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
}
void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
  QColor penColor = mColor;
  penColor.setAlphaF( context.alpha() );
  mPen.setWidth( context.outputLineWidth( mWidth ) );
  mPen.setColor( penColor );
  QColor selColor = context.selectionColor();
  if ( ! selectionIsOpaque )
    selColor.setAlphaF( context.alpha() );
  mSelPen.setWidth( context.outputLineWidth( mWidth ) );
  mSelPen.setColor( selColor );
}
void QtWaveformRendererSimpleSignal::onSetup(const QDomNode &node){
    Q_UNUSED(node);

    QColor borderColor = m_pColors->getSignalColor().lighter(125);
    borderColor.setAlphaF(0.5);
    m_borderPen.setColor(borderColor);
    m_borderPen.setWidthF(1.25);

    QColor signalColor = m_pColors->getSignalColor();
    signalColor.setAlphaF(0.8);
    m_brush = QBrush(signalColor);
}
Example #17
0
void SvgStyleParser::parseColorStops(QGradient *gradient, const KoXmlElement &e)
{
    QGradientStops stops;
    QColor c;

    for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
        KoXmlElement stop = n.toElement();
        if (stop.tagName() == "stop") {
            float offset;
            QString temp = stop.attribute("offset");
            if (temp.contains('%')) {
                temp = temp.left(temp.length() - 1);
                offset = temp.toFloat() / 100.0;
            } else
                offset = temp.toFloat();

            QString stopColorStr = stop.attribute("stop-color");
            if (!stopColorStr.isEmpty()) {
                if (stopColorStr == "inherit") {
                    stopColorStr = inheritedAttribute("stop-color", stop);
                }
                parseColor(c, stopColorStr);
            }
            else {
                // try style attr
                QString style = stop.attribute("style").simplified();
                QStringList substyles = style.split(';', QString::SkipEmptyParts);
                for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) {
                    QStringList substyle = it->split(':');
                    QString command = substyle[0].trimmed();
                    QString params  = substyle[1].trimmed();
                    if (command == "stop-color")
                        parseColor(c, params);
                    if (command == "stop-opacity")
                        c.setAlphaF(params.toDouble());
                }

            }
            QString opacityStr = stop.attribute("stop-opacity");
            if (!opacityStr.isEmpty()) {
                if (opacityStr == "inherit") {
                    opacityStr = inheritedAttribute("stop-opacity", stop);
                }
                c.setAlphaF(opacityStr.toDouble());
            }
            stops.append(QPair<qreal, QColor>(offset, c));
        }
    }
    if (stops.count())
        gradient->setStops(stops);
}
void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
  QColor penColor = mColor;
  penColor.setAlphaF( mColor.alphaF() * context.alpha() );

  double width = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
  mPen.setWidth( context.outputLineWidth( width ) );
  mPen.setColor( penColor );
  QColor selColor = context.renderContext().selectionColor();
  if ( ! selectionIsOpaque )
    selColor.setAlphaF( context.alpha() );
  mSelPen.setWidth( context.outputLineWidth( width ) );
  mSelPen.setColor( selColor );
}
Example #19
0
Differ::Differ(
    const Debug debug,
    const InitialComparisonMode comparisonMode,
    const QString &filename1,
    const QString &filename2,
    const PdfDocument &pdf1,
    const PdfDocument &pdf2,
    const QString saveFilename,
    const bool printSeparate,
    const QString pageRangeDoc1,
    const QString pageRangeDoc2,
    const bool useComposition,
    const QPainter::CompositionMode compositionMode,
    const bool combineHighlightedWords,
    const int overlap,
    const int squareSize,
    const int zoom,
    const int opacity,
    const Qt::PenStyle penStyle,
    QColor penColor,
    const Qt::BrushStyle brushStyle,
    QColor brushColor,
    const bool margins,
    const int topMargin,
    const int leftMargin,
    const int rightMargin,
    const int bottomMargin) : pdf1(pdf1), pdf2(pdf2), debug(debug),
        comparisonMode(comparisonMode), filename1(filename1),
        filename2(filename2), saveFilename(saveFilename),
        printSeparate(printSeparate), pageRangeDoc1(pageRangeDoc1),
        pageRangeDoc2(pageRangeDoc2), useComposition(useComposition),
        compositionMode(compositionMode),
        combineHighlightedWords(combineHighlightedWords), overlap(overlap),
        squareSize(squareSize), zoom(zoom), opacity(opacity),
        penStyle(penStyle), penColor(penColor), brushStyle(brushStyle),
        brushColor(brushColor), margins(margins), topMargin(topMargin),
        leftMargin(leftMargin), rightMargin(rightMargin),
        bottomMargin(bottomMargin)
{
    const qreal Alpha = opacity / 100.0;
    penColor.setAlphaF(Alpha);
    brushColor.setAlphaF(Alpha);

    pen.setColor(penColor);
    brush.setColor(brushColor);

    pen.setStyle(penStyle);
    brush.setStyle(brushStyle);
}
Example #20
0
void UrlDialogTreeWidget::paintEvent(QPaintEvent * event)
{
    QPainter * p = new QPainter(viewport());
    QStyleOptionViewItem option = viewOptions();
    QRect rect = event->rect();

#ifdef COMPILE_PSEUDO_TRANSPARENCY
    if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
    {
        p->save();
        p->setCompositionMode(QPainter::CompositionMode_Source);
        QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
        col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
        p->fillRect(rect, col);
        p->restore();
    }
    else if(g_pShadedChildGlobalDesktopBackground)
    {
        QPoint pnt = ((KviWindow *)parent())->isDocked() ? viewport()->mapTo(g_pMainWindow, rect.topLeft()) : viewport()->mapTo((KviWindow *)parent(), rect.topLeft());
        p->drawTiledPixmap(rect, *(g_pShadedChildGlobalDesktopBackground), pnt);
    }
    else
    {
#endif
        //FIXME this is not the treewindowlist
        p->fillRect(rect, KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground));
#ifdef COMPILE_PSEUDO_TRANSPARENCY
    }
#endif

    delete p;

    //call paint on all children
    QTreeWidget::paintEvent(event);
}
Example #21
0
void IndexGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *)
{
	Q_UNUSED(options);
	if(isSilenced()) {
		QPen pen = _pen;
		pen.setStyle(Qt::DashDotDotLine);
		painter->setPen(pen);

		QBrush brush = _brush;
		QColor color = brush.color();
		color.setAlphaF(0.5);
		brush.setColor(color);
		painter->setBrush(brush);
	} else {
		painter->setPen(_pen);
		painter->setBrush(_brush);
	}

	painter->drawRect(_rect);
	if(!_icon.isNull()) {
		if(isSilenced())
			painter->setOpacity(0.5);
		painter->drawPixmap(_rect.topLeft(), _icon);
	}
}
Example #22
0
void QMdPushButton::paintEvent(QPaintEvent *event){
    QPushButton::paintEvent(event);
    if (!showbusyspin&&!spin)
        return;
    int width = qMin(this->width(), this->height());
    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing);

    int outerRadius = (width-1)/3;
    int innerRadius = (width-1)/3/3;

    int capsuleHeight = outerRadius - innerRadius;
    int capsuleWidth  = (width > 32 ) ? capsuleHeight /4 : capsuleHeight /3;
    int capsuleRadius = capsuleWidth/2;

    for (int i=0; i<12; i++)
    {
        QColor color = busyspincolor;
        color.setAlphaF(1.0f - (i/12.0f));
        p.setPen(Qt::NoPen);
        p.setBrush(color);
        p.save();
        p.translate(rect().center());
        p.rotate(angle - i*30.0f);
        p.drawRoundedRect(-capsuleWidth*0.5, -(innerRadius+capsuleHeight), capsuleWidth, capsuleHeight, capsuleRadius, capsuleRadius);
        p.restore();
    }

}
Example #23
0
void KviThemedLineEdit::paintEvent(QPaintEvent * event)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
	QPainter * p = new QPainter(this);
	QPalette pal = palette();

	// In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what.
	qDrawShadePanel(p, 0, 0, width(), height(), palette(), true, 1, nullptr);

	QRect r(1, 1, width() - 2, height() - 2);

	if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
	{
		p->setCompositionMode(QPainter::CompositionMode_Source);
		QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
		col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
		p->fillRect(r, col);
		p->restore();
	}
	else if(g_pShadedChildGlobalDesktopBackground)
	{
		QPoint pnt;
		if(m_pKviWindow)
			pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft());
		else
			pnt = mapToGlobal(event->rect().topLeft());
		p->drawTiledPixmap(r, *(g_pShadedChildGlobalDesktopBackground), pnt);
	}
	delete p;
#endif

	QLineEdit::paintEvent(event);
}
Example #24
0
void Pencil::setHardness(int h)
{
    hardness_ = h;
    QColor c = mainColor;
    c.setAlphaF(this->hardness()/100.0);
    pencil.setColor(c);
}
Example #25
0
void Pencil::setColor(const QColor &color)
{
    QColor c = color;
    c.setAlphaF(this->hardness()/100.0);
    pencil.setColor(c);
    mainColor = color;
}
Example #26
0
        OPENPSTD_SHARED_EXPORT QColor MultiColorGradient::CalcColor(float value)
        {
            auto begin = this->colors.begin();
            if (value <= begin->first)
            {
                return this->colors.begin()->second;
            }
            auto last = this->colors.end();
            last--;
            if (value >= last->first)
            {
                return last->second;
            }
            std::map<float, QColor>::iterator upperBound = this->colors.upper_bound(value);
            std::map<float, QColor>::iterator lowerBound = upperBound;
            lowerBound--;

            QColor result;
            result.setRedF(this->LinearInterpolation(lowerBound->first, lowerBound->second.redF(), upperBound->first,
                                                     upperBound->second.redF(), value));
            result.setGreenF(
                    this->LinearInterpolation(lowerBound->first, lowerBound->second.greenF(), upperBound->first,
                                              upperBound->second.greenF(), value));
            result.setBlueF(this->LinearInterpolation(lowerBound->first, lowerBound->second.blueF(), upperBound->first,
                                                      upperBound->second.blueF(), value));
            result.setAlphaF(
                    this->LinearInterpolation(lowerBound->first, lowerBound->second.alphaF(), upperBound->first,
                                              upperBound->second.alphaF(), value));

            return result;
        }
void ProgressIndicatorBase::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
	p->save();

	int width = qMin(this->width(), this->height());

	p->setRenderHint(QPainter::Antialiasing);

	int outerRadius = (width-1)*0.5;
	int innerRadius = (width-1)*0.5*0.38;

	int capsuleHeight = outerRadius - innerRadius;
	int capsuleWidth  = (width > 32 ) ? capsuleHeight *.23 : capsuleHeight *.35;
	int capsuleRadius = capsuleWidth/2;

	for (int i = 0; i < m_leafCount; i++) {
		QColor color = m_color;
		color.setAlphaF(qMax(m_minimumOpacity, qreal((int(i * m_delta) + m_angle) % 360) / 360));
		p->setPen(Qt::NoPen);
		p->setBrush(color);
		p->save();
		p->translate(boundingRect().center());
		p->rotate(i*m_delta);
		p->drawRoundedRect(-capsuleWidth*0.5, -(innerRadius+capsuleHeight), capsuleWidth, capsuleHeight, capsuleRadius, capsuleRadius);
		p->restore();
	}

	p->restore();
}
Example #28
0
void ShowPaintEffect::paintGL()
{
    GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
    vbo->reset();
    vbo->setUseColor(true);
    if (ShaderManager::instance()->isValid()) {
        ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
    }
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    QColor color = colors[ color_index ];
    color.setAlphaF(0.2);
    vbo->setColor(color);
    QVector<float> verts;
    verts.reserve(painted.rects().count() * 12);
    foreach (const QRect & r, painted.rects()) {
        verts << r.x() + r.width() << r.y();
        verts << r.x() << r.y();
        verts << r.x() << r.y() + r.height();
        verts << r.x() << r.y() + r.height();
        verts << r.x() + r.width() << r.y() + r.height();
        verts << r.x() + r.width() << r.y();
    }
    vbo->setData(verts.count() / 2, 2, verts.data(), NULL);
    vbo->render(GL_TRIANGLES);
    if (ShaderManager::instance()->isValid()) {
        ShaderManager::instance()->popShader();
    }
    glDisable(GL_BLEND);
}
Example #29
0
void ProgressIndicator::paintEvent(QPaintEvent * /*event*/)
{
    if (!m_displayedWhenStopped && !isAnimated())
        return;

    int width = qMin(this->width(), this->height());

    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing);

    int outerRadius = (width-1)*0.5;
    int innerRadius = (width-1)*0.5*0.38;

    int capsuleHeight = outerRadius - innerRadius;
    int capsuleWidth  = (width > 32 ) ? capsuleHeight *.23 : capsuleHeight *.35;
    int capsuleRadius = capsuleWidth/2;

    for (int i=0; i<12; i++)
    {
        QColor color = m_color;
        color.setAlphaF(1.0f - (i/12.0f));
        p.setPen(Qt::NoPen);
        p.setBrush(color);
        p.save();
        p.translate(rect().center());
        p.rotate(m_angle - i*30.0f);
        p.drawRoundedRect(-capsuleWidth*0.5, -(innerRadius+capsuleHeight), capsuleWidth, capsuleHeight, capsuleRadius, capsuleRadius);
        p.restore();
    }
}
Example #30
0
void Lighting::animate()
{
    angle += (M_PI / 30);
    qreal xs = 200 * sin(angle) - 40 + 25;
    qreal ys = 200 * cos(angle) - 40 + 25;
    m_lightSource->setPos(xs, ys);

    for (int i = 0; i < m_items.size(); ++i) {
        QGraphicsItem *item = m_items.at(i);
        Q_ASSERT(item);

        QGraphicsDropShadowEffect *effect = static_cast<QGraphicsDropShadowEffect *>(item->graphicsEffect());
        Q_ASSERT(effect);

        QPointF delta(item->x() - xs, item->y() - ys);
        effect->setOffset(delta.toPoint() / 30);

        qreal dx = delta.x();
        qreal dy = delta.y();
        qreal dd = sqrt(dx * dx + dy * dy);
        QColor color = effect->color();
        color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7));
        effect->setColor(color);
    }

    m_scene.update();
}