WSOverlayScreenShotAnimation::WSOverlayScreenShotAnimation()
{
	setVisible(false);

	const HostInfo& info = HostBase::instance()->getInfo();
	int width = info.displayWidth;
	int height = info.displayHeight;

	setPos(width/2, height/2);

	int r = qMin(width, height);
	r = r/2;

	m_boundingRect = QRectF(-width/2, -height/2, width, height);
    m_gradient = QRadialGradient(0, 0, r, 0, 0);

	QGradientStops stops;
	stops.append(QGradientStop(0, QColor(0xFF,0xFF,0xFF,0xFF)));
	stops.append(QGradientStop(0.15, QColor(0xFF, 0xFF, 0xFF, 0xC0)));
	stops.append(QGradientStop(0.5, QColor(0xFF, 0xFF ,0xD0, 0xF0)));
	stops.append(QGradientStop(0.75, QColor(0xFF, 0xFF, 0xD0, 0x0F)));
	stops.append(QGradientStop(1.0,  QColor(0xFF, 0xFF, 0xD0, 0x00)));
	m_gradient.setStops(stops);

	connect(WindowServer::instance(), SIGNAL(signalAboutToTakeScreenShot()),
			SLOT(stop()));
	connect(WindowServer::instance(), SIGNAL(signalTookScreenShot()),
			SLOT(start()));
}
Esempio n. 2
0
QRadialGradient ControlSlider::backgroundGradient()
{
	QRadialGradient gradient(0.5,0.5,1.0,0.5,0.5);
	gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
	QGradientStops stops;
	stops.append(QPair<qreal,QColor>(0.0, Qt::white));
	stops.append(QPair<qreal,QColor>(0.8, backgroundColor()));
	stops.append(QPair<qreal,QColor>(1.0, Qt::white));
	gradient.setStops(stops);
	return gradient;
}
void ContextPaneWidgetRectangle::onGradientClicked()
{
    if (ui->colorGradient->isChecked()) {
        m_hasGradient = true;
        QLinearGradient gradient;
        QGradientStops stops;
        stops.append(QGradientStop(0, ui->colorColorButton->convertedColor()));
        stops.append(QGradientStop(1, Qt::white));
        gradient.setStops(stops);
        ui->gradientLine->setEnabled(true);
        ui->gradientLine->setGradient(gradient);
    }
}
Esempio n. 4
0
Ui::ShadowedWidget<__Base>::ShadowedWidget(QWidget* _parent, int _tailLen, double _alphaFrom, double _alphaTo)
    : __Base(_parent)
    , tailLenPx_(_tailLen)
{

    QGradientStops stops;
    QColor voipShadowColor("#000000");
    voipShadowColor.setAlphaF(_alphaFrom);
    stops.append(qMakePair(0.0f, voipShadowColor));
    voipShadowColor.setAlphaF(_alphaTo);
    stops.append(qMakePair(1.0f, voipShadowColor));

    linearGradient_.setStops(stops);
}
Esempio n. 5
0
 void updateGradient()
 {
     static const double n_colors = 6;
     QGradientStops colors;
     colors.reserve(n_colors+1);
     for ( int i = 0; i <= n_colors; ++i )
         colors.append(QGradientStop(i/n_colors, QColor::fromHsvF(i/n_colors, saturation, value)));
     w->setColors(colors);
 }
Esempio n. 6
0
//-----------------------------------------------------------------------------
void
HeaderItem::paint(QPainter* painter, 
                 const QStyleOptionGraphicsItem* option,
                 QWidget* widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    painter->setRenderHint(QPainter::Antialiasing);

    QFont font = painter->font();
    font.setBold(true);
    font.setPointSize(static_cast<int>(font.pointSize() * 1.4));
    painter->setFont(font);

    QRectF frame(QPoint(0, 0), geometry().size());

    // paint the background
    QGradientStops stops;
    stops.append(QGradientStop(0.0, QColor(40, 57, 74)));
    stops.append(QGradientStop(0.5, QColor(0, 0, 0)));
    stops.append(QGradientStop(1.0, QColor(10, 16, 23)));

    QLinearGradient gradient(frame.topLeft(), frame.bottomLeft());
    gradient.setStops(stops);
   
    painter->setPen(QColor(56, 73, 93));
    painter->setBrush(QBrush(gradient));

    QPainterPath path;
    path.moveTo(0, 20);
    path.arcTo(0, 0, 40, 40, 180, -90);
    path.lineTo(frame.right() - 20, 0);
    path.arcTo(frame.right() - 40, 0, 40, 40, 90, -90);
    path.lineTo(frame.right(), frame.bottom());
    path.lineTo(0, frame.bottom());
    path.lineTo(0, 20);
    path.closeSubpath();

    painter->drawPath(path);

    painter->setPen(Qt::white);
    painter->drawText(frame, Qt::AlignCenter, title);
}
    void saveGradientStops(QTextStream &str, const QGradient *g) {
        QGradientStops stops = g->stops();

        if (g->interpolationMode() == QGradient::ColorInterpolation) {
            bool constantAlpha = true;
            int alpha = stops.at(0).second.alpha();
            for (int i = 1; i < stops.size(); ++i)
                constantAlpha &= (stops.at(i).second.alpha() == alpha);

            if (!constantAlpha) {
                const qreal spacing = qreal(0.02);
                QGradientStops newStops;
                QRgb fromColor = PREMUL(stops.at(0).second.rgba());
                QRgb toColor;
                for (int i = 0; i + 1 < stops.size(); ++i) {
                    int parts = qCeil((stops.at(i + 1).first - stops.at(i).first) / spacing);
                    newStops.append(stops.at(i));
                    toColor = PREMUL(stops.at(i + 1).second.rgba());

                    if (parts > 1) {
                        qreal step = (stops.at(i + 1).first - stops.at(i).first) / parts;
                        for (int j = 1; j < parts; ++j) {
                            QRgb color = INV_PREMUL(INTERPOLATE_PIXEL_256(fromColor, 256 - 256 * j / parts, toColor, 256 * j / parts));
                            newStops.append(QGradientStop(stops.at(i).first + j * step, QColor::fromRgba(color)));
                        }
                    }
                    fromColor = toColor;
                }
                newStops.append(stops.back());
                stops = newStops;
            }
        }

        foreach(QGradientStop stop, stops) {
            QString color =
                QString::fromLatin1("#%1%2%3")
                .arg(stop.second.red(), 2, 16, QLatin1Char('0'))
                .arg(stop.second.green(), 2, 16, QLatin1Char('0'))
                .arg(stop.second.blue(), 2, 16, QLatin1Char('0'));
            str << QLatin1String("    <stop offset=\"")<< stop.first << QLatin1String("\" ")
                << QLatin1String("stop-color=\"") << color << QLatin1String("\" ")
                << QLatin1String("stop-opacity=\"") << stop.second.alphaF() <<QLatin1String("\" />\n");
        }
Esempio n. 8
0
void GradientLine::updateGradient()
{
    if (m_useGradient) {
        QGradientStops stops;
        for (int i = 0; i < m_stops.size(); i++) {
            stops.append(QPair<qreal, QColor>(m_stops.at(i), m_colorList.at(i)));
        }
        m_gradient.setStops(stops);
    } else {
        if (!active())
            return;
    }
}
Esempio n. 9
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);
}
Esempio n. 10
0
QBrush XMLParseBase::parseGradient(const QDomElement &element)
{
    QLinearGradient gradient;
    QString gradientStart = element.attribute("start", "");
    QString gradientEnd = element.attribute("end", "");
    int gradientAlpha = element.attribute("alpha", "255").toInt();
    QString direction = element.attribute("direction", "vertical");

    float x1, y1, x2, y2 = 0.0;
    if (direction == "vertical")
    {
        x1 = 0.5;
        x2 = 0.5;
        y1 = 0.0;
        y2 = 1.0;
    }
    else if (direction == "diagonal")
    {
        x1 = 0.0;
        x2 = 1.0;
        y1 = 0.0;
        y2 = 1.0;
    }
    else
    {
        x1 = 0.0;
        x2 = 1.0;
        y1 = 0.5;
        y2 = 0.5;
    }

    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient.setStart(x1, y1);
    gradient.setFinalStop(x2, y2);

    QGradientStops stops;

    if (!gradientStart.isEmpty())
    {
        QColor startColor = QColor(gradientStart);
        startColor.setAlpha(gradientAlpha);
        QGradientStop stop(0.0, startColor);
        stops.append(stop);
    }

    if (!gradientEnd.isEmpty())
    {
        QColor endColor = QColor(gradientEnd);
        endColor.setAlpha(gradientAlpha);
        QGradientStop stop(1.0, endColor);
        stops.append(stop);
    }

    for (QDomNode child = element.firstChild(); !child.isNull();
        child = child.nextSibling())
    {
        QDomElement childElem = child.toElement();
        if (childElem.tagName() == "stop")
        {
            float position = childElem.attribute("position", "0").toFloat();
            QString color = childElem.attribute("color", "");
            int alpha = childElem.attribute("alpha", "-1").toInt();
            if (alpha < 0)
                alpha = gradientAlpha;
            QColor stopColor = QColor(color);
            stopColor.setAlpha(alpha);
            QGradientStop stop((position / 100), stopColor);
            stops.append(stop);
        }
    }

    gradient.setStops(stops);

    return QBrush(gradient);
}
Esempio n. 11
0
void Project::MatchColors(QAction *action)
{
	if (action)
	{
		QString selectedDomainName = action->text();
		Domain* selectedDomain = DetermineDomain(selectedDomainName);
		if (selectedDomain && visibleDomain)
		{
			// Get the active shader types
			ShaderType outlineType = selectedDomain->GetTerrainOutlineType();
			ShaderType fillType = selectedDomain->GetTerrainFillType();

			if (outlineType == SolidShaderType)
			{
				// Copy the solid outline color from the selected domain
				QColor solidOutline = selectedDomain->GetTerrainSolidOutline();
				visibleDomain->SetTerrainSolidOutline(solidOutline);
			}
			else if (outlineType == GradientShaderType)
			{
				// Copy the outline gradient from the selected domain
				// Convert percentages in gradient stops to elevation values
				// Convert these elevation values back into percentages in the range of the selected domain
				float selectedRange[2] = {selectedDomain->GetTerrainMinZ(), selectedDomain->GetTerrainMaxZ()};
				float currentRange[2] = {visibleDomain->GetTerrainMinZ(), visibleDomain->GetTerrainMaxZ()};
				QGradientStops selectedGradientOutline = selectedDomain->GetTerrainGradientOutline();
				QGradientStops newStopsOutline;
				for (int i=0; i<selectedGradientOutline.count(); ++i)
				{
					QGradientStop currentStop = selectedGradientOutline[i];
					float percentage = currentStop.first;
					QColor color = currentStop.second;

					float selectedValue = selectedRange[1] - percentage*(selectedRange[1] - selectedRange[0]);
					if (selectedValue >= currentRange[0] && selectedValue <= currentRange[1])
					{
						QGradientStop newStop;
						newStop.first = (currentRange[1] - selectedValue) / (currentRange[1] - currentRange[0]);
						newStop.second = color;
						newStopsOutline.append(newStop);
					}
				}
				visibleDomain->SetTerrainGradientOutline(newStopsOutline);
			}

			if (fillType == SolidShaderType)
			{
				// Copy the solid fill color from the selected domain
				QColor solidFill = selectedDomain->GetTerrainSolidFill();
				visibleDomain->SetTerrainSolidFill(solidFill);
			}
			else if (fillType == GradientShaderType)
			{
				// Copy the fill gradient from the selected domain
				// Convert percentages in gradient stops to elevation values
				// Convert these elevation values back into percentages in the range of the selected domain
				float selectedRange[2] = {selectedDomain->GetTerrainMinZ(), selectedDomain->GetTerrainMaxZ()};
				float currentRange[2] = {visibleDomain->GetTerrainMinZ(), visibleDomain->GetTerrainMaxZ()};
				QGradientStops selectedGradientFill = selectedDomain->GetTerrainGradientFill();
				QGradientStops newStopsFill;
				for (int i=0; i<selectedGradientFill.count(); ++i)
				{
					QGradientStop currentStop = selectedGradientFill[i];
					float percentage = currentStop.first;
					QColor color = currentStop.second;

					float selectedValue = selectedRange[1] - percentage*(selectedRange[1] - selectedRange[0]);
					if (selectedValue >= currentRange[0] && selectedValue <= currentRange[1])
					{
						QGradientStop newStop;
						newStop.first = (currentRange[1] - selectedValue) / (currentRange[1] - currentRange[0]);
						newStop.second = color;
						newStopsFill.append(newStop);
					}
				}
				visibleDomain->SetTerrainGradientFill(newStopsFill);
			}
		}
	}
}