void OCView_MainWin::showT2(void) { QPalette palette = lblTemp2->palette();; QColor colorTxt;//(0,0,0,0); QColor colorBack;//(255,255,255,0); if (m_data->vehicule.engine.temperature[1].value()>=100) { //colorTxt = Qt::black; colorBack = Qt::red; colorBack = colorBack.darker(120); } else { //colorTxt = Qt::black; colorBack = this->palette().color(QPalette::Window); } colorTxt = QColor(255-colorBack.red(),255-colorBack.green(),255-colorBack.blue()); palette.setColor(QPalette::WindowText, colorTxt); // text (setBrush or setColor) palette.setColor(lblTemp1->backgroundRole(), colorBack); // background lblTemp2->setAutoFillBackground( true ); lblTemp2->setPalette(palette); // apply the palette to the label //lblTemp2->setText(m_data->vehicule.engine.temperature_2.getStr()); lblTemp2->setText(m_data->vehicule.engine.temperature[1].getStr()); }
void DiffSplitterHandle::paintEvent(QPaintEvent *event) { QPainter painter(this); int lineHeight = renderer()->lineHeight(); /*QBrush brush = QBrush(QColor(0, 0, 0), Qt::BrushStyle::SolidPattern);*/ painter.fillRect(event->rect(), QBrush()); const QSize& size = this->size(); QRect paintRect = event->rect(); // QRect translatedRect( clipRect.x()+offsetX, clipRect.y()+offsetY, clipRect.width(), clipRect.height() ); //paintRect.adjust(0, top_, 0, top_); renderer()->renderBegin(paintRect); int startLine = renderer()->startLine(); int endLine = renderer()->endLine(); QColor baseColor = renderer()->theme()->backgroundColor(); QColor changedColor = baseColor.darker(120); for (int line = startLine; line <= endLine; ++line) { int changeType = getLineStatus(line); if (changeType > 0) { painter.fillRect(0, line*lineHeight, size.width(), lineHeight, changedColor); } } renderer()->renderEnd(paintRect); }
PanelsWidget::PanelsWidget(QWidget *parent) : QScrollArea(parent), m_root(new RootWidget(this)) { // We want a 900px wide widget with and the scrollbar at the // side of the screen. m_root->setFixedWidth(900); m_root->setContentsMargins(0, 0, 40, 0); QPalette pal = m_root->palette(); QColor background = Utils::StyleHelper::mergedColors( palette().window().color(), Qt::white, 85); pal.setColor(QPalette::All, QPalette::Window, background.darker(102)); setPalette(pal); pal.setColor(QPalette::All, QPalette::Window, background); m_root->setPalette(pal); // The layout holding the individual panels: m_layout = new QGridLayout(m_root); m_layout->setColumnMinimumWidth(0, ICON_SIZE + 4); m_layout->setSpacing(0); setWidget(m_root); setFrameStyle(QFrame::NoFrame); setWidgetResizable(true); }
PanelsWidget::PanelsWidget( QWidget * parent ) : QScrollArea( parent ) , root_( new RootWidget( this ) ) { // We want a 900px wide widget with and the scrollbar at the // side of the screen. //root_->setMaximumWidth( 900 ); root_->setContentsMargins( 0, 0, 40, 0 ); QPalette pal; QColor background = Utils::StyleHelper::mergedColors( palette().window().color(), Qt::white, 85); pal.setColor(QPalette::All, QPalette::Window, background.darker(102)); setPalette(pal); pal.setColor(QPalette::All, QPalette::Window, background); root_->setPalette(pal); // The layout holding the individual panels: QVBoxLayout *topLayout = new QVBoxLayout(root_); topLayout->setMargin(0); topLayout->setSpacing(0); layout_ = new QGridLayout; layout_->setColumnMinimumWidth( 0, Constants::ICON_SIZE + 4 ); layout_->setSpacing( 0 ); topLayout->addLayout( layout_ ); //topLayout->addStretch( 1 ); setWidget(root_); setFrameStyle(QFrame::NoFrame); setWidgetResizable(true); setFocusPolicy(Qt::NoFocus); }
void TvolumeView::paintEvent(QPaintEvent* ) { QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); painter.setPen(Qt::NoPen); QColor noteColor = qApp->palette().text().color(); if (m_alpha) { // Background if note is detected m_pitchColor.setAlpha(m_alpha); painter.setBrush(QBrush(m_pitchColor)); noteColor = qApp->palette().highlightedText().color(); painter.drawRoundedRect(painter.viewport(), 4, 4); } painter.setFont(nootFont); QString nSymbol = (m_activePause && m_paused) ? "o" : "n"; QRect nRect = painter.fontMetrics().boundingRect(nSymbol); if (m_drawPaused) { // Stop/start highlight painter.setBrush(m_overNote ? qApp->palette().highlightedText().color().darker(95) : qApp->palette().highlight().color()); painter.drawRoundedRect(width() - nRect.width() * 1.8, 0, nRect.width() * 1.8, height(), 50, 50, Qt::RelativeSize); } if (m_drawPaused) // and note symbol painter.setPen(m_overNote ? qApp->palette().highlight().color() : qApp->palette().highlightedText().color()); else if (m_alpha) painter.setPen(noteColor); else painter.setPen(tc); painter.drawText(0, 0, width() - nRect.width() * 0.3, height(), Qt::AlignRight, nSymbol); qreal tickWidth = TICK_WIDTH - 1.0; for (int i = 1; i < m_ticksCount - 2; i++) { // volume ticks if (i >= m_ticksCount * m_minVolume) tickWidth = TICK_WIDTH; if (m_activePause && m_paused) painter.setPen(QPen(disabledColor, tickWidth, Qt::SolidLine, Qt::RoundCap)); else if (m_volume * m_ticksCount >= i) painter.setPen(QPen(m_tickColors[i], tickWidth, Qt::SolidLine, Qt::RoundCap)); else painter.setPen(QPen(tc, tickWidth, Qt::SolidLine, Qt::RoundCap)); float ticH = (((float)i * m_hiTickStep + 1.0)); painter.drawLine(QLineF((i + 1) * (TICK_GAP + TICK_WIDTH) - TICK_WIDTH, (height() - ticH) / 2, (i + 1) * (TICK_GAP + TICK_WIDTH) - TICK_WIDTH, height() - (height() - ticH) / 2)); } if (m_drawKnob) { // volume knob painter.setPen(Qt::NoPen); QColor knobBrush = qApp->palette().highlight().color(), shade = qApp->palette().text().color(); if (m_leftButton) knobBrush = knobBrush.lighter(); shade.setAlpha(150); painter.setBrush(shade); float xPos = (float)(width() - m_noteWidth) * m_minVolume; painter.drawEllipse(QRectF(xPos - height() * 0.5, height() * 0.1, height() * 0.9, height() * 0.9)); // shade QLinearGradient lg(xPos, 0, xPos, height()); lg.setColorAt(0, knobBrush); lg.setColorAt(0.3, knobBrush); lg.setColorAt(0.8, knobBrush.darker()); painter.setBrush(QBrush(lg)); painter.drawEllipse(QRectF(xPos - height() * 0.5, height() * 0.05, height() * 0.9, height() * 0.9)); painter.setBrush(qApp->palette().highlightedText()); painter.setPen(QPen(shade, 0.7)); painter.drawEllipse(QRectF(xPos - height() * 0.27, height() * 0.27, height() * 0.45, height() * 0.45)); } }
void CaptureDialog::initWarning(RDLabel *warning) { if(!warning) return; if(warning->devicePixelRatio() >= 2) warning->setText(warning->text().replace(lit(".png"), lit("@2x.png"))); auto calcPaletteFromStyle = [warning](QEvent *) { QPalette pal = warning->palette(); QColor base = pal.color(QPalette::ToolTipBase); pal.setColor(QPalette::Foreground, pal.color(QPalette::ToolTipText)); pal.setColor(QPalette::Window, base); pal.setColor(QPalette::Base, base.darker(120)); warning->setPalette(pal); }; calcPaletteFromStyle(NULL); warning->setBackgroundRole(QPalette::Window); warning->setForegroundRole(QPalette::Foreground); QObject::connect(warning, &RDLabel::mouseMoved, [warning](QMouseEvent *) { warning->setBackgroundRole(QPalette::Base); }); QObject::connect(warning, &RDLabel::leave, [warning]() { warning->setBackgroundRole(QPalette::Window); }); QObject::connect(warning, &RDLabel::styleChanged, calcPaletteFromStyle); warning->setAutoFillBackground(true); warning->setMouseTracking(true); warning->setVisible(false); }
void OverlayAnimator::setActiveAppearance( bool active ) { QColor color = mEditor->palette().color(QPalette::Base); if(color.lightness() >= 128) color = color.darker(60); else color = color.lighter(50); if (active) color.setAlpha(0); else color.setAlpha(mEditor->inactiveFadeAlpha()); mBackgroundAnimation.stop(); if (mEditor->isVisible()) { mBackgroundAnimation.setDuration(500); mBackgroundAnimation.setEasingCurve( QEasingCurve::OutCubic ); mBackgroundAnimation.setStartValue( backgroundColor() ); mBackgroundAnimation.setEndValue( color ); mBackgroundAnimation.start(); } else { setBackgroundColor(color); } }
void ItemLibraryTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option) { painter->save(); QLinearGradient gradient; QColor highlight = option.palette.highlight().color(); gradient.setColorAt(0, highlight.lighter(130)); gradient.setColorAt(1, highlight.darker(130)); gradient.setStart(option.rect.topLeft()); gradient.setFinalStop(option.rect.bottomLeft()); painter->fillRect(option.rect, gradient); painter->setPen(highlight.lighter()); painter->drawLine(option.rect.topLeft(),option.rect.topRight()); painter->setPen(highlight.darker()); painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight()); painter->restore(); }
void caScriptButton::setBackground(QColor c) { thisBackColor = c; thisHoverColor = c.lighter(120); thisBorderColor = c.darker(150); setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor); }
//! [5] void VibrationSurface::paintEvent(QPaintEvent *) { QPainter painter(this); QRect rect = geometry(); int dx = 0, dy = 0; if (height() > width()) { dy = height() / NumberOfLevels; rect.setHeight(dy); } else { dx = width() / NumberOfLevels; rect.setWidth(dx); } //! [5] //! [6] for (int i = 0; i < NumberOfLevels; i++) { int x = i * dx; int y = i * dy; int intensity = getIntensity(x, y); QColor color = QColor(40, 80, 10).lighter(100 + intensity); rect.moveTo(x, y); painter.fillRect(rect, color); painter.setPen(color.darker()); painter.drawText(rect, Qt::AlignCenter, QString::number(intensity)); } }
void TargetSelectorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &) const { painter->save(); painter->setClipping(false); if (selectionGradient.isNull()) selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png")); if (option.state & QStyle::State_Selected) { QColor color =(option.state & QStyle::State_HasFocus) ? option.palette.highlight().color() : option.palette.dark().color(); painter->fillRect(option.rect, color.darker(140)); Utils::StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5); painter->setPen(QColor(255, 255, 255, 60)); painter->drawLine(option.rect.topLeft(), option.rect.topRight()); painter->setPen(QColor(255, 255, 255, 30)); painter->drawLine(option.rect.bottomLeft() - QPoint(0,1), option.rect.bottomRight() - QPoint(0,1)); painter->setPen(QColor(0, 0, 0, 80)); painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); } painter->restore(); }
void BinClockWidget::setColor(int i, QColor & c) { palettes[i].setColor(QPalette::Background, c); palettes[i].setColor(QPalette::Light, c.lighter()); palettes[i].setColor(QPalette::QPalette::Dark, c.darker()); }
void Peg::setAppearance(const QColor& color) { QRadialGradient gradient(QPointF(10,10), 10, QPoint(10,13)); gradient.setColorAt(0, color); gradient.setColorAt(1, color.darker()); setBrush(gradient); }
void LocationBar::paintEvent(QPaintEvent *event) { QPalette p = palette(); QColor defaultBaseColor = QApplication::palette().color(QPalette::Base); QColor backgroundColor = defaultBaseColor; if (m_webView && m_webView->url().scheme() == QLatin1String("https") && p.color(QPalette::Text).value() < 128) { QColor lightYellow(248, 248, 210); backgroundColor = lightYellow; } // set the progress bar if (m_webView) { int progress = m_webView->progress(); if (progress == 0) { p.setBrush(QPalette::Base, backgroundColor); } else { QColor loadingColor = QColor(116, 192, 250); if (p.color(QPalette::Text).value() >= 128) loadingColor = defaultBaseColor.darker(200); QLinearGradient gradient(0, 0, width(), 0); gradient.setColorAt(0, loadingColor); gradient.setColorAt(((double)progress)/100, backgroundColor); p.setBrush(QPalette::Base, gradient); } setPalette(p); } LineEdit::paintEvent(event); }
void KisInfinityManager::drawDecoration(QPainter& gc, const QRectF& updateArea, const KisCoordinatesConverter *converter, KisCanvas2 *canvas) { Q_UNUSED(updateArea); Q_UNUSED(converter); Q_UNUSED(canvas); if (!m_filteringEnabled) return; gc.save(); gc.setTransform(QTransform(), false); KisConfig cfg; QColor color = cfg.canvasBorderColor(); gc.fillPath(m_decorationPath, color.darker(115)); QPainterPath p; p.moveTo(5, 2); p.lineTo(-3, 8); p.lineTo(-5, 5); p.lineTo( 2, 0); p.lineTo(-5,-5); p.lineTo(-3,-8); p.lineTo( 5,-2); p.arcTo(QRectF(3, -2, 4, 4), 90, -180); foreach (const QTransform &t, m_handleTransform) { gc.fillPath(t.map(p), color); }
void caMessageButton::setBackground(QColor c) { thisBackColor = c; thisHoverColor = c.lighter(120); thisBorderColor = c.darker(150); setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor, thisDisabledForeColor); }
void MixerNode::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { QString text = QString().sprintf("%.2f", value()); painter->setFont(graph->font()); if (drawNode) { QRadialGradient gradient(-3, -3, 10); QColor color; if (value() < 0) { color = negativeColor; } else if (value() == 0) { color = neutralColor; } else { color = positiveColor; } if (option->state & QStyle::State_Sunken) { gradient.setCenter(3, 3); gradient.setFocalPoint(3, 3); QColor selColor = color.darker(); gradient.setColorAt(1, selColor.darker()); gradient.setColorAt(0, selColor); } else { gradient.setColorAt(0, graph->isEnabled() ? color : disabledColor); gradient.setColorAt(1, graph->isEnabled() ? color.darker() : disabledColor); } painter->setBrush(gradient); painter->setPen(graph->isEnabled() ? QPen(Qt::black, 0) : QPen(disabledTextColor)); painter->drawEllipse(boundingRect()); if (!image.isNull()) { painter->drawImage(boundingRect().adjusted(1, 1, -1, -1), image); } } if (drawText) { if (graph->isEnabled()) { painter->setPen(QPen(drawNode ? Qt::white : Qt::black, 0)); } else { painter->setPen(QPen(disabledTextColor)); } painter->drawText((value() < 0) ? -10 : -8, 3, text); } }
void LocationBar::paintEvent(QPaintEvent* event) { LineEdit::paintEvent(event); // Show loading progress if (qzSettings->showLoadingProgress && m_progressVisible) { QStyleOptionFrame option; initStyleOption(&option); int lm, tm, rm, bm; getTextMargins(&lm, &tm, &rm, &bm); QRect contentsRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this); contentsRect.adjust(lm, tm, -rm, -bm); QColor bg = m_progressColor; if (!bg.isValid() || bg.alpha() == 0) { bg = Colors::mid(palette().color(QPalette::Base), palette().color(QPalette::Text), m_progressStyle > 0 ? 4 : 8, 1); } QPainter p(this); p.setBrush(QBrush(bg)); // We are painting over text, make sure the text stays visible p.setOpacity(0.5); QPen outlinePen(bg.darker(110), 0.8); p.setPen(outlinePen); switch (m_progressStyle) { case ProgressFilled: { QRect bar = contentsRect.adjusted(0, 1, 0, -1); bar.setWidth(bar.width() * m_loadProgress / 100); const int roundness = bar.height() / 4.0; p.drawRoundedRect(bar, roundness, roundness); break; } case ProgressBottom: { outlinePen.setWidthF(0.3); outlinePen.setColor(outlinePen.color().darker(130)); p.setPen(outlinePen); QRect bar(contentsRect.x(), contentsRect.bottom() - 3, contentsRect.width() * m_loadProgress / 100.0, 3); p.drawRoundedRect(bar, 1, 1); break; } case ProgressTop: { outlinePen.setWidthF(0.3); outlinePen.setColor(outlinePen.color().darker(130)); p.setPen(outlinePen); QRect bar(contentsRect.x(), contentsRect.top() + 1, contentsRect.width() * m_loadProgress / 100.0, 3); p.drawRoundedRect(bar, 1, 1); break; } default: break; } } }
void QSegmentWidget::DrawCenterText(QPainter *painter) { painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->setWindow( -(BM_OSIZE / 2), -(BM_OSIZE / 2), BM_OSIZE, BM_OSIZE); int fontHeight = 30; int shadowDepth = 3; int fontBorder = 1; QColor colorText = QColor(255,255,255); QColor colorBorder = QColor(200, 200, 200); QColor colorShadow = QColor(60,60,60); QFont fontText("Arial", fontHeight, 200); QString text = QString::number(m_textValue); QString symbol("%"); QPainterPath pathText, pathTextShadow, pathSymbol, pathSymbolShadow; QPen pen; painter->setFont(fontText); #if (QT_VERSION >= QT_VERSION_CHECK(5, 11 , 0)) int lenText = painter->fontMetrics().horizontalAdvance(text); int lenSymb = painter->fontMetrics().horizontalAdvance(symbol); #else int lenText = painter->fontMetrics().width(text); int lenSymb = painter->fontMetrics().width(symbol); #endif pen.setWidth(fontBorder); pen.setColor(colorBorder); painter->setPen(colorShadow.darker(200)); painter->setBrush(colorShadow); // shadow symbol painter->setTransform(QTransform(1.5, 0, 0, 1.5, 0, 0)); pathSymbolShadow.addText(((lenText)/2)-(lenSymb/2)+(fontBorder*2)+3+shadowDepth, (fontHeight+shadowDepth), fontText, symbol); painter->drawPath(pathSymbolShadow); // shadow text painter->setTransform(QTransform(2.0, 0, 0, 3, 0, 0)); pathTextShadow.addText(-((lenText+lenSymb)/2)+3+shadowDepth, (fontHeight/2)+shadowDepth, fontText, text); painter->drawPath(pathTextShadow); painter->setPen(pen); painter->setBrush(colorText); // symbol painter->setTransform(QTransform(1.5, 0, 0, 1.5, 0, 0)); pathSymbol.addText(((lenText)/2)-(lenSymb/2)+(fontBorder*2)+3, (fontHeight), fontText, symbol); painter->drawPath(pathSymbol); // text painter->setTransform(QTransform(2.0, 0, 0, 3, 0, 0)); pathText.addText(-((lenText+lenSymb)/2)+3, (fontHeight/2), fontText, text); painter->drawPath(pathText); }
void NavigatorTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option) { painter->save(); QLinearGradient gradient; QColor highlightColor = Utils::StyleHelper::notTooBrightHighlightColor(); gradient.setColorAt(0, highlightColor.lighter(130)); gradient.setColorAt(1, highlightColor.darker(130)); gradient.setStart(option.rect.topLeft()); gradient.setFinalStop(option.rect.bottomLeft()); painter->fillRect(option.rect, gradient); painter->setPen(highlightColor.lighter()); painter->drawLine(option.rect.topLeft(),option.rect.topRight()); painter->setPen(highlightColor.darker()); painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight()); painter->restore(); }
void OCView_MainWin::showT1(void) { QPalette palette = lblTemp1->palette();; QColor colorTxt;//(0,0,0,0); QColor colorBack;//(255,255,255,0); //QGradient gradient; //QLinearGradient gradient(0, 0, width(), 0); //gradient.setColorAt(0.0, Qt::green); //gradient.setColorAt(0.8, Qt::yellow); //gradient.setColorAt(1.0, Qt::red); /* ToDo : a better gradient that fit with temperature measurements cold is blue - hot/warm is red see colormap (in geography / maps) */ //QPen pen(gradient, 0); // no contour //color = gradient.getColorAt(0.5); // unfortunately it doesn't exist ! ToDo /* Look into the QT source for gradient qt4/src/gui/painting/brush.h & .cpp */ if (m_data->vehicule.engine.temperature[0].value()>=100) { //colorTxt = Qt::black; colorBack = Qt::red; colorBack = colorBack.darker(120); } else { //colorTxt = Qt::black; //colorBack = Qt::white; colorBack = this->palette().color(QPalette::Window); } colorTxt = QColor(255-colorBack.red(),255-colorBack.green(),255-colorBack.blue()); palette.setColor(QPalette::WindowText, colorTxt); // text (setBrush or setColor) palette.setColor(lblTemp1->backgroundRole(), colorBack); // background lblTemp1->setAutoFillBackground( true ); lblTemp1->setPalette(palette); // apply the palette to the label //lblTemp1->setText(m_data->vehicule.engine.temperature_1.getStr()); lblTemp1->setText(m_data->vehicule.engine.temperature[0].getStr()); //QPen pen; //pen.setColor(color); //std::cout << "color for temperature" << std::endl; //lblTemp1->setStyleSheet("color: blue; background-color: yellow"); //lblTemp1->setStyleSheet("background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);"); //lblTemp1->setStyleSheet("color: #FF0000;"); //lblTemp1->setStyleSheet("background-color: " + colorBack.name()+ ";"); // ok /* see also QTextFormat / QTextDocument / QTextEdit void QTextFormat::setForeground ( const QBrush & brush ) void QTextFormat::setBackground ( const QBrush & brush ) */ }
/*! draw item */ void CQPropertyDelegate:: paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QTreeWidgetItem *item = getModelItem(index); assert(item); //--- bool inside = tree_->isMouseInd(index); QBrush b; if (inside) { QVariant value = index.data(Qt::BackgroundRole); if (value.canConvert<QBrush>()) b = qvariant_cast<QBrush>(value); QColor c = option.palette.color(QPalette::Window); QBrush b1(c.darker(110)); item->setData(0, Qt::BackgroundRole, b1); item->setData(1, Qt::BackgroundRole, b1); } //--- if (CQPropertyItem::isType(item->type())) { CQPropertyItem *item1 = dynamic_cast<CQPropertyItem *>(item); assert(item1); QStyleOptionViewItem option1 = option; if (! item1->isWritable()) { option1.font.setItalic(true); } if (index.column() == 1) { if (! item1->paint(this, painter, option1, index)) QItemDelegate::paint(painter, option1, index); } else { QItemDelegate::paint(painter, option1, index); } } else QItemDelegate::paint(painter, option, index); //--- if (inside) { item->setData(0, Qt::BackgroundRole, b); item->setData(1, Qt::BackgroundRole, b); } }
void UIBar::paintContent(QPainter *pPainter) { QSize s = size(); QPalette pal = palette(); QColor base = pal.color(QPalette::Active, QPalette::Window); QLinearGradient lg(0, 1, 0, s.height() - 2); lg.setColorAt(0, base); lg.setColorAt(.49, base.darker(102)); lg.setColorAt(.50, base.darker(104)); lg.setColorAt(1., base.darker(106)); pPainter->setPen(base.darker(60)); pPainter->drawLine(0, 0, s.width(), 0); pPainter->setPen(base.darker(125)); pPainter->drawLine(0, s.height()-1, s.width(), s.height()-1); pPainter->setPen(Qt::NoPen); pPainter->setBrush(lg); pPainter->drawRect(0, 1, s.width(), s.height()-2); }
void PreviewWidget::drawShadow(QPainter &painter, QRectF rect) { // Shadow width int width = qBound(4, int(qMax(rect.height(), rect.width())) / 100, 7); painter.save(); painter.setClipRect(rect.adjusted(0, 0, width, width)); QColor lightColor = this->palette().color(QPalette::Background); QColor darkColor = lightColor.darker(160); QRectF shadowRect = rect.adjusted(0, 0, width, width); QLinearGradient lg; lg.setColorAt(0.0, darkColor); lg.setColorAt(1.0, lightColor); QRadialGradient rg; rg.setColorAt(0, darkColor); rg.setColorAt(1, lightColor); rg.setRadius(width); // Right lg.setStart(QPointF(rect.right(), rect.center().y())); lg.setFinalStop(QPointF(shadowRect.right(), rect.center().y())); painter.fillRect(rect.right(), rect.top() + width, width, rect.height() - width, lg); // Bottom lg.setStart(rect.center().x(), rect.bottom()); lg.setFinalStop(rect.center().x(), rect.bottom() + width); painter.fillRect(rect.left() + width, rect.bottom(), rect.width() - width, width, lg); //TopRight QPointF p; p = rect.bottomRight(); rg.setCenter(p); rg.setFocalPoint(p); painter.fillRect(rect.right(), rect.bottom(), width, width, rg); // BottomRight p = rect.topRight(); p.ry() += width; rg.setCenter(p); rg.setFocalPoint(p); painter.fillRect(rect.right(), rect.top(), width, width, rg); //BottomLeft p = rect.bottomLeft(); p.rx() += width; rg.setCenter(p); rg.setFocalPoint(p); painter.fillRect(rect.left(), rect.bottom(), width, width, rg); painter.restore(); }
void UIMiniToolBar::paintEvent(QPaintEvent*) { /* Prepare painter: */ QPainter painter(this); /* Fill background: */ if (!m_shape.isEmpty()) { painter.setRenderHint(QPainter::Antialiasing); painter.setClipPath(m_shape); } QRect backgroundRect = rect(); QColor backgroundColor = palette().color(QPalette::Window); QLinearGradient headerGradient(backgroundRect.bottomLeft(), backgroundRect.topLeft()); headerGradient.setColorAt(0, backgroundColor.darker(120)); headerGradient.setColorAt(1, backgroundColor.darker(90)); painter.fillRect(backgroundRect, headerGradient); }
void LongPressSpinner::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { painter->save(); //painter->setClipRect( option->exposedRect ); int iconSize = boundingRect().size().toSize().width(); //painter->translate(-iconSize/2,-iconSize/2); if(m_goodPressFlag) { // Draw inner gradient QColor centerColor = Qt::green; QRadialGradient rg(boundingRect().center(),iconSize); rg.setColorAt(0, centerColor/*.lighter(100)*/); rg.setColorAt(1, centerColor.darker(500)); //p.setPen(Qt::black); painter->setBrush(QBrush(rg)); //painter->setPen(QPen(Qt::black,3)); painter->drawEllipse(boundingRect()); } else { painter->setOpacity(0.75); // Draw inner gradient QColor centerColor("#0277fd"); // cream blue QRadialGradient rg(boundingRect().center(),iconSize); rg.setColorAt(0, centerColor/*.lighter(100)*/); rg.setColorAt(1, centerColor.darker(500)); //p.setPen(Qt::black); painter->setBrush(QBrush(rg)); //qDebug() << "LongPressSpinner::paint(): progress:"<<m_progress<<", rect:"<<boundingRect()<<", iconSize:"<<iconSize; QPainterPath outerPath; outerPath.addEllipse(boundingRect()); QPainterPath innerPath; innerPath.addEllipse(boundingRect().adjusted(12.5,12.5,-12.5,-12.5)); // Clip center of circle painter->setClipPath(outerPath.subtracted(innerPath)); // Draw outline painter->setPen(QPen(Qt::black,3)); //painter->drawEllipse(0,0,iconSize,iconSize); painter->drawChord(boundingRect().adjusted(3,3,-3,-3), 0, -(int)(360 * 16 * m_progress)); // clockwise painter->setBrush(Qt::white); painter->drawChord(boundingRect().adjusted(10,10,-10,-10), 0, -(int)(360 * 16 * m_progress)); // clocwise } painter->restore(); }
void UIPopupBox::paintEvent(QPaintEvent *pEvent) { /* Create painter: */ QPainter painter(this); painter.setClipRect(pEvent->rect()); QPalette pal = palette(); painter.setClipPath(*m_pLabelPath); QColor base = pal.color(QPalette::Active, QPalette::Window); QRect rect = QRect(QPoint(0, 0), size()).adjusted(0, 0, -1, -1); /* Base background */ painter.fillRect(QRect(QPoint(0, 0), size()), pal.brush(QPalette::Active, QPalette::Base)); /* Top header background */ const int iMaxHeightHint = qMax(m_pTitleLabel->sizeHint().height(), m_pTitleIcon->sizeHint().height()); QLinearGradient lg(rect.x(), rect.y(), rect.x(), rect.y() + 2 * 5 + iMaxHeightHint); lg.setColorAt(0, base.darker(95)); lg.setColorAt(1, base.darker(110)); int theight = rect.height(); if (m_fOpen) theight = 2 * 5 + iMaxHeightHint; painter.fillRect(QRect(rect.x(), rect.y(), rect.width(), theight), lg); /* Outer round rectangle line */ painter.setClipping(false); painter.strokePath(*m_pLabelPath, base.darker(110)); /* Arrow */ if (m_fHeaderHover) { painter.setBrush(base.darker(106)); painter.setPen(QPen(base.darker(128), 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QSizeF s = m_arrowPath.boundingRect().size(); if (m_fOpen) { painter.translate(rect.x() + rect.width() - s.width() - 10, rect.y() + theight / 2 + s.height() / 2); /* Flip */ painter.scale(1, -1); } else painter.translate(rect.x() + rect.width() - s.width() - 10, rect.y() + theight / 2 - s.height() / 2 + 1); painter.setRenderHint(QPainter::Antialiasing); painter.drawPath(m_arrowPath); } }
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 MapView::fillCircle(QPainter &painter, const QPoint ¢er, int diameter, const QColor &color) { QPainterPath path, patho; path.addEllipse(center, diameter, diameter); painter.fillPath(path, QBrush(color.darker())); patho.addEllipse(center, diameter / 1.1, diameter / 1.1); painter.fillPath(patho, QBrush(color)); }
SegmentInfo::SegmentInfo(const BinaryImageTreeItem *s): gammaStartIndex(0), gammaEndIndex(0), segment(s), arterySegment(NULL), sampleCurve(s->getName()), gammaCurve(s->getName()+ QObject::tr(" Gamma Fit")), patlakCurve(s->getName()), patlakRegression(s->getName() + QObject::tr(" linear Regression")), patlakCreated(false) { //get color of the segment QColor color = s->getColor(); //set color to the curve sampleCurve.setPen(QPen(color)); sampleCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); QwtSymbol symbol; //class for drawing symbols symbol.setStyle( QwtSymbol::Ellipse ); symbol.setSize(8); symbol.setPen(QPen(color)); symbol.setBrush(QBrush(color.darker(130))); //set the symbol to the curve sampleCurve.setSymbol( symbol ); //initialize curve data sampleCurve.setData( TimeDensityData() ); //create pen for gamma curve with dotted line QPen pen(color); pen.setStyle(Qt::DotLine); //set pen to gamma curve gammaCurve.setPen(pen); gammaCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); //initialize gamma curve data and hide it gammaCurve.setData( GammaFitData() ); gammaCurve.setVisible(false); //set style of the patlak curve patlakCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); patlakCurve.setStyle(QwtPlotCurve::NoCurve); symbol.setStyle( QwtSymbol::XCross ); symbol.setSize(8); symbol.setPen(QPen(color)); symbol.setBrush(QBrush(color.darker(130))); patlakCurve.setSymbol( symbol ); patlakRegression.setRenderHint(QwtPlotItem::RenderAntialiased, true); }