コード例 #1
0
void KItemListGroupHeader::updateCache()
{
    Q_ASSERT(m_dirtyCache);

    // Calculate the role- and line-color. No alphablending is used for
    // performance reasons.
    const QColor c1 = textColor();
    const QColor c2 = baseColor();
    m_separatorColor = mixedColor(c1, c2, 10);
    m_roleColor = mixedColor(c1, c2, 60);

    const int padding = qMax(1, m_styleOption.padding);
    const int horizontalMargin = qMax(2, m_styleOption.horizontalMargin);

    const QFontMetrics fontMetrics(m_styleOption.font);
    const qreal roleHeight = fontMetrics.height();

    const int y = (m_scrollOrientation == Qt::Vertical) ? padding : horizontalMargin;

    m_roleBounds = QRectF(horizontalMargin + padding,
                          y,
                          size().width() - 2 * padding - horizontalMargin,
                          roleHeight);

    m_dirtyCache = false;
}
コード例 #2
0
ファイル: psitiplabel.cpp プロジェクト: psi-im/psi
void PsiTipLabel::init(const QString& text)
{
    setText(text);
    initUi();
    resize(sizeHint());
    qApp->installEventFilter(this);
    startHideTimer();
    setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0);
    setForegroundRole(QPalette::ToolTipText);
    setBackgroundRole(QPalette::ToolTipBase);
    setPalette(QToolTip::palette());

    enableColoring_ = PsiOptions::instance()->getOption("options.ui.look.colors.tooltip.enable").toBool();
    if(enableColoring_){
        QColor textColor(PsiOptions::instance()->getOption("options.ui.look.colors.tooltip.text").toString());
        QColor baseColor(PsiOptions::instance()->getOption("options.ui.look.colors.tooltip.background").toString());
        if(textColor.isValid() && baseColor.isValid() && textColor != baseColor) { //looks fine
            QPalette palette(QToolTip::palette());
            palette.setColor(QPalette::ToolTipText, textColor);
            palette.setColor(QPalette::ToolTipBase, baseColor);
            palette.setColor(QPalette::WindowText, textColor);
            palette.setColor(QPalette::Window, baseColor);
            setPalette(palette);
        } else {
            enableColoring_ = false;
        }
    }
    const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.tooltip.css").toString();
    if (!css.isEmpty()) {
        setStyleSheet(css);
    }
}
コード例 #3
0
ファイル: view.cpp プロジェクト: Arcen/MedicalImage
void stateBaseWave::paint()
{
	trackDocument * doc = trackDocument::get();
	static image viewImage;//画面表示用画像
	viewImage.topdown = false;
	viewImage.create( doc->baseWave.w, doc->baseWave.h );
	pixel p( 0, 0, 0, 255 );
	for ( int x = 0; x < viewImage.width; ++x ) {
		int maxValue = doc->maxValues[x];
		for ( int y = 0; y < viewImage.height; ++y ) {
			p.r = p.g = p.b = static_cast<unsigned char>( clamp<int>( 0, double( doc->baseWave( x, y ) ) / maxValue * 255, 255 ) );
			viewImage.setInternal( x, y, p );
		}
	}
	array<int>::iterator it( doc->wave );
	pixel c( 0, 255, 255, 255 );
	pixel baseColor( 255, 0, 255, 255 );
	for ( int x = 0; x < viewImage.width && it; ++x, ++it ) {
		int y = doc->waveBias + it();
		if ( x == doc->baseIndex ) {
			viewImage.set( x, y, blend( viewImage.get( x, y ), baseColor ) );
		} else {
			viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
		}
	}
	stateDocument::paint( viewImage );
}
コード例 #4
0
void ColorWheel::makeAnalogous()
{
	baseColor();
	colorList[tr("1st. Analogous")] = sampleByAngle(baseAngle + angle);
	colorList[tr("2nd. Analogous")] = sampleByAngle(baseAngle - angle);
	currentType = Analogous;
}
コード例 #5
0
QColor KGlobalSettings::alternateBackgroundColor()
{
    initColors();
    KConfigGroup g( KGlobal::config(), "General" );
    *alternateColor = calculateAlternateBackgroundColor( baseColor() );
    return g.readColorEntry( "alternateBackground", alternateColor );
}
コード例 #6
0
void ColorWheel::makeTriadic()
{
	baseColor();
	colorList[tr("1st. Triadic")] = sampleByAngle(baseAngle + 120);
	colorList[tr("2nd. Triadic")] = sampleByAngle(baseAngle - 120);
	currentType = Triadic;
}
コード例 #7
0
ファイル: stylehelper.cpp プロジェクト: byron90/webdebug
void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored)
{
    if (StyleHelper::usePixmapCache()) {
        QString key;
        QColor keyColor = baseColor(lightColored);
        key.sprintf("mh_horizontal %d %d %d %d %d %d",
            spanRect.width(), spanRect.height(), clipRect.width(),
            clipRect.height(), keyColor.rgb(), spanRect.x());

        QPixmap pixmap;
        if (!QPixmapCache::find(key, pixmap)) {
            pixmap = QPixmap(clipRect.size());
            QPainter p(&pixmap);
            QRect rect = QRect(0, 0, clipRect.width(), clipRect.height());
            horizontalGradientHelper(&p, spanRect, rect, lightColored);
            p.end();
            QPixmapCache::insert(key, pixmap);
        }

        painter->drawPixmap(clipRect.topLeft(), pixmap);

    } else {
        horizontalGradientHelper(painter, spanRect, clipRect, lightColored);
    }
}
const QImage& ImageTransformer::
KNNMFtransform(int size, int K)
{
    std::vector<int> redList;
    std::vector<int> greenList;
    std::vector<int> blueList;

    QImage NewImage(_DataHandled.size(),_DataHandled.format());
    int step = size/2;

    int width = NewImage.width();
    int height = NewImage.height();
    int depth = NewImage.depth();

    if(depth == 32 && size>1 && K<=(step*2+1)*(step*2+1)&&K>0)
    {
        for(int i=0;i<width;++i)
        {
            for(int j=0;j<height;++j)
            {
                redList.clear();
                greenList.clear();
                blueList.clear();

                for(int p=((i-step)>0)?(i-step):0;p<=i+step&&p<width;++p)
                {
                    for(int q=((j-step)>0)?(j-step):0;q<=j+step&&q<height;++q)
                    {
                       QColor neighbor(_DataHandled.pixel(p,q));
                       redList.push_back(neighbor.red());
                       greenList.push_back(neighbor.green());
                       blueList.push_back(neighbor.blue());
                    }
                }
                std::sort(redList.begin(),redList.end()-1);
                std::sort(greenList.begin(),greenList.end()-1);
                std::sort(blueList.begin(),blueList.end()-1);

                if(redList.size()<=K)
                {
                    NewImage.setPixel(i,j,QColor(redList.at(redList.size()/2),
                                                 greenList.at(greenList.size()/2),
                                                 blueList.at(blueList.size()/2)).rgb());
                }
                else
                {
                    QColor baseColor(_DataHandled.pixel(i,j));

                    NewImage.setPixel(i,j,QColor(KNNMFmiddle(redList,baseColor.red(),K),
                                                 KNNMFmiddle(greenList,baseColor.green(),K),
                                                 KNNMFmiddle(blueList,baseColor.blue(),K)).rgb());

                }
            }
        }
        _DataHandled = NewImage;
    }
    return _DataHandled;
}
コード例 #9
0
void ColorWheel::makeTetradic()
{
	baseColor();
	colorList[tr("1st. Tetradic (base opposite)")] = sampleByAngle(baseAngle + 180);
	colorList[tr("2nd. Tetradic (angle)")] = sampleByAngle(baseAngle + angle);
	colorList[tr("3rd. Tetradic (angle opposite)")] = sampleByAngle(baseAngle + angle + 180);
	currentType = Tetradic;
}
コード例 #10
0
ファイル: stylehelper.cpp プロジェクト: Acidburn0zzz/qupzilla
QColor StyleHelper::borderColor(bool lightColored)
{
    QColor result = baseColor(lightColored);
    result.setHsv(result.hue(),
                  result.saturation(),
                  result.value() / 2);
    return result;
}
コード例 #11
0
ファイル: stylehelper.cpp プロジェクト: 01iv3r/OpenPilot
QColor StyleHelper::highlightColor()
{
    QColor result = baseColor();
    result.setHsv(result.hue(),
                  clamp(result.saturation()),
                  clamp(result.value() * 1.16));
    return result;
}
コード例 #12
0
ファイル: stylehelper.cpp プロジェクト: Acidburn0zzz/qupzilla
QColor StyleHelper::shadowColor(bool lightColored)
{
    QColor result = baseColor(lightColored);
    result.setHsv(result.hue(),
                  clamp(result.saturation() * 1.1),
                  clamp(result.value() * 0.70));
    return result;
}
コード例 #13
0
ファイル: stylehelper.cpp プロジェクト: innoink/SiftFaceRec
QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect)
{
    QLinearGradient grad(statusBarRect.topLeft(), QPoint(statusBarRect.center().x(), statusBarRect.bottom()));
    QColor startColor = shadowColor().darker(164);
    QColor endColor = baseColor().darker(130);
    grad.setColorAt(0, startColor);
    grad.setColorAt(1, endColor);
    return grad;
}
コード例 #14
0
void ColorWheel::makeSplit()
{
	baseColor();
	colorList[tr("1st. Split")] = sampleByAngle(baseAngle + angle);
	colorList[tr("2nd. Split")] = sampleByAngle(baseAngle - angle);
	colorList[tr("3rd. Split")] = sampleByAngle(baseAngle + 180 + angle);
	colorList[tr("4th. Split")] = sampleByAngle(baseAngle + 180 - angle);
	currentType = Split;
}
コード例 #15
0
ファイル: stylehelper.cpp プロジェクト: Aceler/Clementine
QColor StyleHelper::highlightColor(bool lightColored) {
  QColor result = baseColor(lightColored);
  if (!lightColored)
    result.setHsv(result.hue(), clamp(result.saturation()),
                  clamp(result.value() * 1.16));
  else
    result.setHsv(result.hue(), clamp(result.saturation()),
                  clamp(result.value() * 1.06));
  return result;
}
コード例 #16
0
void VesselConnectionView::paint(QPainter *painter,
                                 const QStyleOptionGraphicsItem *option,
                                 QWidget *widget)
{
	Q_UNUSED(widget);

	double lod = option->levelOfDetailFromTransform(painter->transform());
	if (lod < minLOD())
		return;

	QColor fill_color = baseColor(option);
	QColor dark_fill_color = fill_color.dark();

	QGradientStops stops;
	stops << QGradientStop(0.038, dark_fill_color)
	      << QGradientStop(0.128, fill_color)
	      << QGradientStop(0.174, fill_color)
	      << QGradientStop(0.174+0.125-0.03, dark_fill_color)
	      << QGradientStop(0.45, fill_color)
	      << QGradientStop(0.55, fill_color)

	      << QGradientStop(1-(0.174+0.125-0.03), dark_fill_color)
	      << QGradientStop(1-0.174, fill_color)
	      << QGradientStop(1-0.128, fill_color)
	      << QGradientStop(1-0.038, dark_fill_color);
	const QRectF &br = boundingRect();
	QLinearGradient gradient(QLineF(br.topLeft(), br.topRight()).pointAt(0.5),
	                         QLineF(br.bottomRight(), br.bottomLeft()).pointAt(0.5));
	gradient.setStops(stops);

	QLinearGradient gradient2(QLineF(br.topLeft(), br.bottomLeft()).pointAt(0.5),
	                          QLineF(br.topRight(), br.bottomRight()).pointAt(0.5));
	QColor transparent_color(fill_color), semi_transparent_color(fill_color);
	transparent_color.setAlpha(0);
	semi_transparent_color.setAlpha(200);

	gradient2.setStops(QGradientStops()
	                   << QGradientStop(0, transparent_color)
	                   << QGradientStop(0.45, semi_transparent_color)
	                   << QGradientStop(0.55, semi_transparent_color)
	                   << QGradientStop(1, transparent_color));

	painter->setPen(QPen(penColor(option), 32/2, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin));
	painter->drawPath(path);

	if (isClearBg()) {
		painter->fillPath(fill, Qt::white);
	}
	else {
		painter->fillPath(fill, gradient);
		painter->fillPath(fill, gradient2);
	}
}
コード例 #17
0
void ColorWheel::makeMonochromatic()
{
	baseColor();
	QColor col(ScColorEngine::getRGBColor(actualColor, currentDoc));
	ScColor l;
	l.fromQColor(col.light());
	l = ScColorEngine::convertToModel(l, currentDoc, currentColorSpace);
	colorList[tr("Monochromatic Light")] = l;
	l.fromQColor(col.dark());
	l = ScColorEngine::convertToModel(l, currentDoc, currentColorSpace);
	colorList[tr("Monochromatic Dark")] = l;
	currentType = Monochromatic;
}
コード例 #18
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();
}
コード例 #19
0
void USObstacleGrid::draw()
{
  DECLARE_DEBUG_DRAWING("representation:USObstacleGrid", "drawingOnField");
  DECLARE_DEBUG_DRAWING("origin:USObstacleGrid", "drawingOnField");
  ORIGIN("origin:USObstacleGrid", drawingOrigin.translation.x,
         drawingOrigin.translation.y, drawingOrigin.rotation);
  COMPLEX_DRAWING("representation:USObstacleGrid",
  {
    unsigned char colorOccupiedStep(255 / cellMaxOccupancy);
    ColorRGBA baseColor(200, 200, 255, 128);
    unsigned char cellsForDrawing[GRID_SIZE];
    for(int i = 0; i < GRID_SIZE; ++i)
      cellsForDrawing[i] = colorOccupiedStep* cells[i].state;
    GRID_MONO("representation:USObstacleGrid", CELL_SIZE, GRID_LENGTH, GRID_LENGTH, baseColor, cellsForDrawing);
    const int gridWidth(GRID_LENGTH* CELL_SIZE);
    const int gridHeight(GRID_LENGTH* CELL_SIZE);
    RECTANGLE("representation:USObstacleGrid", -gridWidth / 2, -gridHeight / 2, gridWidth / 2, gridHeight / 2,
              20, Drawings::ps_solid, ColorRGBA(0, 0, 100));
  });
コード例 #20
0
ファイル: main.cpp プロジェクト: mpvader/qt
static QPixmap createDestPixmap()
{
    const int colorbands = 3;
    const int intensities = 4;
    QPixmap pm( 32, colorbands*intensities*4 );
    QPainter painter;
    painter.begin( &pm );
    for ( int i=0; i<colorbands; i++ ) {
	for ( int j=0; j<intensities; j++ ) {
	    int intensity = 255 * (j+1) / intensities; // 25%, 50%, 75% and 100%
	    for ( int k=0; k<8; k++ ) {
		QColor col = baseColor( k, intensity );
		painter.setPen( QPen( col, 1 ) );
		painter.setBrush( col );
		painter.drawRect( k*4, j*4 + i*intensities*4, 4, 4 );
	    }
	}
    }
    painter.end();
    return pm;
}
コード例 #21
0
void ColorWheel::makeComplementary()
{
	baseColor();
	colorList[tr("Complementary")] = sampleByAngle(baseAngle + 180);
	currentType = Complementary;
}