void PostWindow::applySettings(Settings::Manager * settings) { int scrollback = settings->value("IDE/postWindow/scrollback").toInt(); QFont font = settings->codeFont(); QPalette palette; settings->beginGroup("IDE/editor/colors"); if (settings->contains("text")) { QTextCharFormat format = settings->value("text").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Base, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::Text, fg); } settings->endGroup(); // colors bool lineWrap = settings->value("IDE/postWindow/lineWrap").toBool(); setMaximumBlockCount(scrollback); setFont(font); setPalette(palette); setLineWrap( lineWrap ); }
void PostWindow::applySettings(Settings::Manager * settings) { int scrollback = settings->value("IDE/postWindow/scrollback").toInt(); QFont font = settings->codeFont(); QPalette palette; settings->beginGroup("IDE/editor/colors"); if (settings->contains("text")) { QTextCharFormat format = settings->value("text").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Base, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::Text, fg); } settings->endGroup(); // colors bool lineWrap = settings->value("IDE/postWindow/lineWrap").toBool(); setMaximumBlockCount(scrollback); setFont(font); setPalette(palette); setLineWrap( lineWrap ); QFontMetrics metrics (font); QString stringOfSpaces (settings->value("IDE/editor/indentWidth").toInt(), QChar(' ')); setTabStopWidth(metrics.width(stringOfSpaces)); updateActionShortcuts(settings); }
QString PlotCurve::saveCurveLayout() { Plot *plot = static_cast<Plot *>(this->plot()); Graph *g = static_cast<Graph *>(plot->parent()); int index = g->curveIndex(static_cast<QwtPlotCurve *>(this)); int style = g->curveType(index); QString s = "<Style>" + QString::number(style) + "</Style>\n"; if (style == Graph::Spline) s += "<LineStyle>5</LineStyle>\n"; else if (style == Graph::VerticalSteps) s += "<LineStyle>6</LineStyle>\n"; else s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n"; QPen pen = this->pen(); if (pen.style() != Qt::NoPen){ s += "<Pen>\n"; s += "\t<Color>" + pen.color().name() + "</Color>\n"; s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n"; s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n"; s += "</Pen>\n"; } QBrush brush = this->brush(); if (brush.style() != Qt::NoBrush){ s += "<Brush>\n"; s += "\t<Color>" + brush.color().name() + "</Color>\n"; s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n"; s += "</Brush>\n"; } const QwtSymbol symbol = this->symbol(); if (symbol.style() != QwtSymbol::NoSymbol){ s += "<Symbol>\n"; s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n"; s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n"; s += "\t<SymbolPen>\n"; s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n"; s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n"; s += "\t</SymbolPen>\n"; brush = this->brush(); if (brush.style() != Qt::NoBrush){ s += "\t<SymbolBrush>\n"; s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n"; s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n"; s += "\t</SymbolBrush>\n"; } s += "</Symbol>\n"; } s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n"; s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n"; s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n"; return s; }
void QJsonPaintEngine::updateBackground(Qt::BGMode bgMode, const QBrush &bgBrush) { Q_D(QJsonPaintEngine); #ifdef QT_PICTURE_DEBUG qDebug() << " -> updateBackground(): mode:" << bgMode << "style:" << bgBrush.style(); #endif d->s << QString("\t{\"b\": { \"m\": \"%1\", \"b\": {\"c\": \"%2\", \"s\": \"%3\"}}},\r\n") .arg(bgMode) .arg(bgBrush.color().name()) .arg(bgBrush.style()); }
void createBrushNode( QDomDocument& doc, QDomNode& parent, const QString& elementName, const QBrush& brush ) { QDomElement brushElement = doc.createElement( elementName ); parent.appendChild( brushElement ); createColorNode( doc, brushElement, "Color", brush.color() ); createStringNode( doc, brushElement, "Style", KDGanttXML::brushStyleToString( brush.style() ) ); if( brush.style() == Qt::CustomPattern && brush.pixmap() ) createPixmapNode( doc, brushElement, "Pixmap", *brush.pixmap() ); }
QString KoOdfGraphicStyles::saveOdfGradientStyle(KoGenStyles &mainStyles, const QBrush &brush) { KoGenStyle gradientStyle; if (brush.style() == Qt::RadialGradientPattern) { const QRadialGradient *gradient = static_cast<const QRadialGradient*>(brush.gradient()); gradientStyle = KoGenStyle(KoGenStyle::RadialGradientStyle /*no family name*/); gradientStyle.addAttributePercent("svg:cx", gradient->center().x() * 100); gradientStyle.addAttributePercent("svg:cy", gradient->center().y() * 100); gradientStyle.addAttributePercent("svg:r", gradient->radius() * 100); gradientStyle.addAttributePercent("svg:fx", gradient->focalPoint().x() * 100); gradientStyle.addAttributePercent("svg:fy", gradient->focalPoint().y() * 100); } else if (brush.style() == Qt::LinearGradientPattern) { const QLinearGradient *gradient = static_cast<const QLinearGradient*>(brush.gradient()); gradientStyle = KoGenStyle(KoGenStyle::LinearGradientStyle /*no family name*/); gradientStyle.addAttributePercent("svg:x1", gradient->start().x() * 100); gradientStyle.addAttributePercent("svg:y1", gradient->start().y() * 100); gradientStyle.addAttributePercent("svg:x2", gradient->finalStop().x() * 100); gradientStyle.addAttributePercent("svg:y2", gradient->finalStop().y() * 100); } else if (brush.style() == Qt::ConicalGradientPattern) { const QConicalGradient * gradient = static_cast<const QConicalGradient*>(brush.gradient()); gradientStyle = KoGenStyle(KoGenStyle::ConicalGradientStyle /*no family name*/); gradientStyle.addAttributePercent("svg:cx", gradient->center().x() * 100); gradientStyle.addAttributePercent("svg:cy", gradient->center().y() * 100); gradientStyle.addAttribute("draw:angle", QString("%1").arg(gradient->angle())); } const QGradient * gradient = brush.gradient(); if (gradient->spread() == QGradient::RepeatSpread) gradientStyle.addAttribute("svg:spreadMethod", "repeat"); else if (gradient->spread() == QGradient::ReflectSpread) gradientStyle.addAttribute("svg:spreadMethod", "reflect"); else gradientStyle.addAttribute("svg:spreadMethod", "pad"); if (! brush.transform().isIdentity()) { gradientStyle.addAttribute("svg:gradientTransform", saveTransformation(brush.transform())); } QBuffer buffer; buffer.open(QIODevice::WriteOnly); KoXmlWriter elementWriter(&buffer); // TODO pass indentation level // save stops QGradientStops stops = gradient->stops(); Q_FOREACH (const QGradientStop & stop, stops) { elementWriter.startElement("svg:stop"); elementWriter.addAttribute("svg:offset", QString("%1").arg(stop.first)); elementWriter.addAttribute("svg:stop-color", stop.second.name()); if (stop.second.alphaF() < 1.0) elementWriter.addAttribute("svg:stop-opacity", QString("%1").arg(stop.second.alphaF())); elementWriter.endElement(); }
bool QBrushPropertyItem::hasChildren() { if (!m_childrenSet) { m_childrenSet = true; QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject())); QPropertyItem* width = new QPropertyItem(brush.color(), "Color", this); m_children.append(width); connect(width, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); int index = staticQtMetaObject.indexOfEnumerator("BrushStyle"); QMetaEnum enumeration = staticQtMetaObject.enumerator(index); QChildEnumPropertyItem* brushStyle = new QChildEnumPropertyItem((int)brush.style(), "Brush Style",enumeration , this); m_children.append(brushStyle); connect(brushStyle, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); QChildImagePropertyItem* textureImage = new QChildImagePropertyItem(brush.texture(), "Texture", this); m_children.append(textureImage); connect(textureImage, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); return true; }
void QBrushPropertyItem::setChildValues() { if (!m_isSettingChildren) { m_isSettingChildren = true; QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject())); for (int i = 0; i < m_children.count(); i++) { QPropertyItem* child = m_children[i]; QString propertyName = child->name(); QVariant tval; if (propertyName == "Color") { tval = brush.color(); } else if (propertyName == "Brush Style") { tval = (int)brush.style(); } else if (propertyName == "Texture") { tval = brush.texture(); } m_model->setData(child->index(), tval); } m_isSettingChildren = false; } }
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF())//copy from QPlainTextEditor from 4.8.1 { p->save(); if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) { if (!gradientRect.isNull()) { QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top()); m.scale(gradientRect.width(), gradientRect.height()); brush.setTransform(m); const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode); } } else { p->setBrushOrigin(rect.topLeft()); } p->fillRect(rect, brush); p->restore(); }
void EventItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { painter->save(); QStyleOptionViewItemV4 opt = option; initStyleOption(&opt, index); QVariant value = index.data(); QBrush bgBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)); QBrush fgBrush = qvariant_cast<QBrush>(index.data(Qt::ForegroundRole)); painter->setClipRect( opt.rect ); painter->setBackgroundMode(Qt::OpaqueMode); painter->setBackground(Qt::transparent); painter->setBrush(bgBrush); if (bgBrush.style() != Qt::NoBrush) { QPen bgPen; bgPen.setColor(bgBrush.color().darker(250)); bgPen.setStyle(Qt::SolidLine); bgPen.setWidth(1); painter->setPen(bgPen); painter->drawRoundedRect(opt.rect.x(), opt.rect.y(), opt.rect.width() - bgPen.width(), opt.rect.height() - bgPen.width(), 3.0, 3.0); } QTextDocument doc; doc.setDocumentMargin(3); doc.setDefaultStyleSheet("* {color: " + fgBrush.color().name() + ";}"); doc.setHtml("<html><qt></head><meta name=\"qrichtext\" content=\"1\" />" + displayText(value, QLocale::system()) + "</qt></html>"); QAbstractTextDocumentLayout::PaintContext context; doc.setPageSize( opt.rect.size()); painter->translate(opt.rect.x(), opt.rect.y()); doc.documentLayout()->draw(painter, context); painter->restore(); }
void QTableModelWordMLWriter::writeBackgroundColor(QXmlStreamWriter & stream, const QBrush & b) { if (b.style() != Qt::NoBrush){ //stream.writeEmptyElement("w:color"); stream.writeAttribute("w:fill", b.color().name()); } }
static inline void qwtFillRect( const QWidget *widget, QPainter *painter, const QRect &rect, const QBrush &brush) { if ( brush.style() == Qt::TexturePattern ) { painter->save(); painter->setClipRect( rect ); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); painter->restore(); } else if ( brush.gradient() ) { painter->save(); painter->setClipRect( rect ); painter->fillRect(0, 0, widget->width(), widget->height(), brush); painter->restore(); } else { painter->fillRect(rect, brush); } }
QBrush FillTab::brush(QBrush b) const { QColor this_color = colorDirty() ? color() : b.color(); Qt::BrushStyle this_style = styleDirty() ? style() : b.style(); if (useGradientDirty()) { // Apply / unapply gradient if (useGradient()) { b = QBrush(gradient()); } else { b.setColor(this_color); b.setStyle(this_style); } } else { // Leave gradient but make other changes. QGradient this_gradient; if (const QGradient *grad = b.gradient()) { if (gradientDirty()) { this_gradient = gradient(); } else { this_gradient = *grad; } b = QBrush(this_gradient); } else { b.setColor(this_color); b.setStyle(this_style); } } return b; }
/*! \brief Draw an intervall of the curve \param painter Painter \param xMap maps x-values into pixel coordinates. \param yMap maps y-values into pixel coordinates. \param from index of the first point to be painted \param to index of the last point to be painted. If to < 0 the curve will be painted to its last point. \sa QwtCurve::drawCurve, QwtCurve::drawDots, QwtCurve::drawLines, QwtCurve::drawSpline, QwtCurve::drawSteps, QwtCurve::drawSticks */ void QwtCurve::draw(QPainter *painter, const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to) { if ( !painter || dataSize() <= 0 ) return; if (to < 0) to = dataSize() - 1; if ( verifyRange(from, to) > 0 ) { painter->save(); painter->setPen(d_pen); QBrush b = d_brush; if ( b.style() != Qt::NoBrush && !b.color().isValid() ) b.setColor(d_pen.color()); painter->setBrush(b); drawCurve(painter, d_style, xMap, yMap, from, to); painter->restore(); if (d_sym.style() != QwtSymbol::None) { painter->save(); drawSymbols(painter, d_sym, xMap, yMap, from, to); painter->restore(); } } }
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha) { SetBlend(true); DisableTextures(); glEnableClientState(GL_VERTEX_ARRAY); if (fillBrush.style() != Qt::NoBrush) { SetColor(fillBrush.color().red(), fillBrush.color().green(), fillBrush.color().blue(), fillBrush.color().alpha()); GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, area); glVertexPointer(2, GL_FLOAT, 0, vertices); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } if (linePen.style() != Qt::NoPen) { SetColor(linePen.color().red(), linePen.color().green(), linePen.color().blue(), linePen.color().alpha()); glLineWidth(linePen.width()); GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, area); glVertexPointer(2, GL_FLOAT, 0, vertices); glDrawArrays(GL_LINE_LOOP, 0, 4); } glDisableClientState(GL_VERTEX_ARRAY); }
void KoTableRowStyle::saveOdf(KoGenStyle &style) const { QList<int> keys = d->stylesPrivate.keys(); foreach(int key, keys) { if (key == QTextFormat::BackgroundBrush) { QBrush backBrush = background(); if (backBrush.style() != Qt::NoBrush) style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::TableRowType); else style.addProperty("fo:background-color", "transparent", KoGenStyle::TableRowType); } else if (key == MinimumRowHeight) { style.addPropertyPt("style:min-row-height", minimumRowHeight(), KoGenStyle::TableRowType); } else if (key == RowHeight) { style.addPropertyPt("style:row-height", rowHeight(), KoGenStyle::TableRowType); } else if (key == UseOptimalHeight) { style.addProperty("style:use-optimal-row-height", useOptimalHeight(), KoGenStyle::TableRowType); } else if (key == BreakBefore) { style.addProperty("fo:break-before", KoText::textBreakToString(breakBefore()), KoGenStyle::TableRowType); } else if (key == BreakAfter) { style.addProperty("fo:break-after", KoText::textBreakToString(breakAfter()), KoGenStyle::TableRowType); } else if (key == KeepTogether) { if (keepTogether()) style.addProperty("fo:keep-together", "always", KoGenStyle::TableRowType); else style.addProperty("fo:keep-together", "auto", KoGenStyle::TableRowType); } } }
void MythD3D9Painter::DrawRect(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha) { int style = fillBrush.style(); if (style == Qt::SolidPattern || style == Qt::NoBrush) { if (!m_render) return; if (style != Qt::NoBrush) m_render->DrawRect(area, fillBrush.color(), alpha); if (linePen.style() != Qt::NoPen) { int lineWidth = linePen.width(); QRect top(QPoint(area.x(), area.y()), QSize(area.width(), lineWidth)); QRect bot(QPoint(area.x(), area.y() + area.height() - lineWidth), QSize(area.width(), lineWidth)); QRect left(QPoint(area.x(), area.y()), QSize(lineWidth, area.height())); QRect right(QPoint(area.x() + area.width() - lineWidth, area.y()), QSize(lineWidth, area.height())); m_render->DrawRect(top, linePen.color(), alpha); m_render->DrawRect(bot, linePen.color(), alpha); m_render->DrawRect(left, linePen.color(), alpha); m_render->DrawRect(right, linePen.color(), alpha); } return; } MythPainter::DrawRect(area, fillBrush, linePen, alpha); }
QVariant Util::decorationForVariant(const QVariant &value) { switch (value.type()) { case QVariant::Brush: { const QBrush b = value.value<QBrush>(); if (b.style() != Qt::NoBrush) { QPixmap p(16, 16); p.fill(QColor(0, 0, 0, 0)); QPainter painter(&p); painter.setBrush(b); painter.drawRect(0, 0, p.width() - 1, p.height() - 1); return p; } } case QVariant::Color: { const QColor c = value.value<QColor>(); if (c.isValid()) { QPixmap p(16, 16); QPainter painter(&p); painter.setBrush(QBrush(c)); painter.drawRect(0, 0, p.width() - 1, p.height() - 1); return p; } } case QVariant::Cursor: { const QCursor c = value.value<QCursor>(); if (!c.pixmap().isNull()) { return c.pixmap().scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation); } } case QVariant::Icon: { return value; } case QVariant::Pen: { const QPen pen = value.value<QPen>(); if (pen.style() != Qt::NoPen) { QPixmap p(16, 16); p.fill(QColor(0, 0, 0, 0)); QPainter painter(&p); painter.setPen(pen); painter.translate(0, 8 - pen.width() / 2); painter.drawLine(0, 0, p.width(), 0); return p; } } case QVariant::Pixmap: { const QPixmap p = value.value<QPixmap>(); return QVariant::fromValue(p.scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation)); } default: break; } return QVariant(); }
QString StrokeTabSI::doCommand(QString x) { if(!x.startsWith("setIndexOfStrokeStyle")&&!x.startsWith("setIndexOfStrokeBrushStyle(")&&!x.startsWith("setIndexOfStrokeJoinStyle")&& !x.startsWith("setIndexOfStrokeCapStyle")&&!x.startsWith("setStrokeWidth")&&!x.startsWith("setStrokeBrushColor")) { return ""; } QPen p=item->pen(); QBrush b = p.brush(); Qt::PenStyle this_style = p.style(); qreal this_width = p.widthF(); QColor this_brushColor = b.color(); Qt::BrushStyle this_brushStyle = b.style(); Qt::PenJoinStyle this_joinStyle = p.joinStyle(); Qt::PenCapStyle this_capStyle = p.capStyle(); if(x.startsWith("setIndexOfStrokeStyle(")) { x.remove("setIndexOfStrokeStyle(").remove(')'); Qt::PenStyle arr[]={Qt::NoPen,Qt::SolidLine,Qt::DashLine,Qt::DotLine,Qt::DashDotLine,Qt::DashDotDotLine,Qt::CustomDashLine}; this_style=arr[x.toInt()]; } else if(x.startsWith("setIndexOfStrokeBrushStyle(")) { x.remove("setIndexOfStrokeBrushStyle(").remove(')'); Qt::BrushStyle arr[]={Qt::NoBrush,Qt::SolidPattern,Qt::Dense1Pattern,Qt::Dense2Pattern,Qt::Dense3Pattern,Qt::Dense4Pattern,Qt::Dense5Pattern, Qt::Dense6Pattern,Qt::Dense7Pattern,Qt::HorPattern,Qt::VerPattern,Qt::CrossPattern,Qt::BDiagPattern,Qt::FDiagPattern, Qt::DiagCrossPattern}; this_brushStyle=arr[x.toInt()]; } else if(x.startsWith("setIndexOfStrokeJoinStyle(")) { x.remove("setIndexOfStrokeJoinStyle(").remove(')'); Qt::PenJoinStyle arr[]={Qt::MiterJoin,Qt::BevelJoin,Qt::RoundJoin,Qt::SvgMiterJoin}; this_joinStyle=arr[x.toInt()]; } else if(x.startsWith("setIndexOfStrokeCapStyle(")) { x.remove("setIndexOfStrokeCapStyle(").remove(')'); Qt::PenCapStyle arr[]={Qt::FlatCap,Qt::SquareCap,Qt::RoundCap}; this_capStyle=arr[x.toInt()]; } else if(x.startsWith("setStrokeWidth(")) { this_width=x.remove("setStrokeWidth(").remove(')').toFloat(); } else if(x.startsWith("setStrokeBrushColor(")) { this_brushColor=QColor(x.remove("setStrokeBrushColor(").remove(')')); } p.setStyle(this_style); p.setWidthF(this_width); b.setColor(this_brushColor); b.setStyle(this_brushStyle); p.setJoinStyle(this_joinStyle); p.setCapStyle(this_capStyle); p.setBrush(b); #ifdef Q_OS_WIN32 if (p.isCosmetic()) { p.setWidth(1); } #endif item->storePen(p); return "Done"; }
/* Should we require that q is a toplevel window ??? Used by QWSManager */ void QWidgetPrivate::blitToScreen(const QRegion &globalrgn) { Q_Q(QWidget); QWidget *win = q->window(); QBrush bgBrush = win->palette().brush(win->backgroundRole()); bool opaque = bgBrush.style() == Qt::NoBrush || bgBrush.isOpaque(); QWidget::qwsDisplay()->repaintRegion(win->data->winid, win->windowFlags(), opaque, globalrgn); }
void QwtPieCurve::setBrushStyle(const Qt::BrushStyle &style) { QBrush br = QwtPlotCurve::brush(); if (br.style() == style) return; br.setStyle(style); setBrush(br); }
void QJsonPaintEngine::updateBrush(const QBrush &brush) { Q_D(QJsonPaintEngine); #ifdef QT_PICTURE_DEBUG qDebug() << " -> updateBrush(): style:" << brush.style() << brush.color().name(); #endif d->fillBrush = brush; setCanvasFillBrush(); }
void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy ) { if ( mLabelEdit->isEnabled() && mLabelEdit->text() != sy->label() ) mLabelEdit->setEnabled( false ); if ( lstSymbols->isEnabled() && lstSymbols->currentIndex().isValid() ) { QAbstractItemModel *m = lstSymbols->model(); if ( m->data( lstSymbols->currentIndex(), Qt::UserRole ).toString() != sy->pointSymbolName() ) lstSymbols->setEnabled( false ); } if ( mPointSizeSpinBox->isEnabled() && !doubleNear( mPointSizeSpinBox->value(), sy->pointSize() ) ) mPointSizeSpinBox->setEnabled( false ); if ( mPointSizeUnitsCheckBox->isEnabled() && mPointSizeUnitsCheckBox->isChecked() != sy->pointSizeUnits() ) mPointSizeUnitsCheckBox->setEnabled( false ); if ( mRotationClassificationComboBox->isEnabled() && mRotationClassificationComboBox->itemData( mRotationClassificationComboBox->currentIndex() ).toInt() != sy->rotationClassificationField() ) mRotationClassificationComboBox->setEnabled( false ); if ( mScaleClassificationComboBox->isEnabled() && mScaleClassificationComboBox->itemData( mScaleClassificationComboBox->currentIndex() ).toInt() != sy->scaleClassificationField() ) mScaleClassificationComboBox->setEnabled( false ); if ( mSymbolComboBox->isEnabled() && mSymbolComboBox->itemData( mSymbolComboBox->currentIndex() ).toInt() != sy->symbolField() ) mSymbolComboBox->setEnabled( false ); if ( outlinewidthspinbox->isEnabled() && !doubleNear( outlinewidthspinbox->value(), sy->pen().widthF() ) ) outlinewidthspinbox->setEnabled( false ); if ( btnFillColor->isEnabled() && btnFillColor->color() != sy->brush().color() ) btnFillColor->setEnabled( false ); if ( btnOutlineColor->isEnabled() && btnOutlineColor->color() != sy->pen().color() ) btnOutlineColor->setEnabled( false ); if ( cboOutlineStyle->isEnabled() ) { QPen myPen = sy->pen(); QString myLineStyle = QgsSymbologyUtils::penStyle2QString( myPen.style() ); if ( cboOutlineStyle->itemData( cboOutlineStyle->currentIndex(), Qt::UserRole ).toString() != myLineStyle ) cboOutlineStyle->setEnabled( false ); } if ( cboFillStyle->isEnabled() ) { QBrush myBrush = sy->brush(); QString myFillStyle = QgsSymbologyUtils::brushStyle2QString( myBrush.style() ); if ( cboFillStyle->itemData( cboFillStyle->currentIndex(), Qt::UserRole ).toString() != myFillStyle ) cboFillStyle->setEnabled( false ); } }
void KPrBrushProperty::setQBrush( const QBrush &brush ) { switch ( brush.style() ) { case NoBrush: // TODO break; case SolidPattern: m_brushUI->styleCombo->setCurrentItem( 0 ); break; case Dense1Pattern: m_brushUI->styleCombo->setCurrentItem( 1 ); break; case Dense2Pattern: m_brushUI->styleCombo->setCurrentItem( 2 ); break; case Dense3Pattern: m_brushUI->styleCombo->setCurrentItem( 3 ); break; case Dense4Pattern: m_brushUI->styleCombo->setCurrentItem( 4 ); break; case Dense5Pattern: m_brushUI->styleCombo->setCurrentItem( 5 ); break; case Dense6Pattern: m_brushUI->styleCombo->setCurrentItem( 6 ); break; case Dense7Pattern: m_brushUI->styleCombo->setCurrentItem( 7 ); break; case HorPattern: m_brushUI->styleCombo->setCurrentItem( 8 ); break; case VerPattern: m_brushUI->styleCombo->setCurrentItem( 9 ); break; case CrossPattern: m_brushUI->styleCombo->setCurrentItem( 10 ); break; case BDiagPattern: m_brushUI->styleCombo->setCurrentItem( 11 ); break; case FDiagPattern: m_brushUI->styleCombo->setCurrentItem( 12 ); break; case DiagCrossPattern: m_brushUI->styleCombo->setCurrentItem( 13 ); break; case CustomPattern: break; } m_brushUI->colorChooser->setColor( brush.color() ); m_preview_color->setBrush( brush ); }
void QAbstractDiagramGraphicsItem::setBrush( const QBrush & brush ) { m_brush = brush; QStringList mAttrs; mAttrs << QString("color:#%1").arg(brush.color().rgb(),3, 16); switch(brush.style()){ case Qt::NoBrush: mAttrs << "style:nobrush"; break; case Qt::SolidPattern: mAttrs << "style:solid"; break; case Qt::Dense1Pattern: mAttrs << "style:dense1"; break; case Qt::Dense2Pattern: mAttrs << "style:dense2"; break; case Qt::Dense3Pattern: mAttrs << "style:dense3"; break; case Qt::Dense4Pattern: mAttrs << "style:dense4"; break; case Qt::Dense5Pattern: mAttrs << "style:dense5"; break; case Qt::Dense6Pattern: mAttrs << "style:dense6"; break; case Qt::Dense7Pattern: mAttrs << "style:dense7"; break; case Qt::HorPattern: mAttrs << "style:hor"; break; case Qt::VerPattern: mAttrs << "style:ver"; break; case Qt::CrossPattern: mAttrs << "style:cross"; break; case Qt::BDiagPattern: mAttrs << "style:bdiag"; break; case Qt::FDiagPattern: mAttrs << "style:fdiag"; break; case Qt::DiagCrossPattern: mAttrs << "style:diagcross"; break; default: mAttrs << "style:solid"; } setProperty("brush", mAttrs.join(";")); }
static bool hasBackgroundColor( const QWidget *widget ) { #if QT_VERSION < 0x040000 return ( widget->backgroundMode() != Qt::FixedPixmap ); #else const QBrush brush = widget->palette().brush( widget->backgroundRole() ); return ( brush.style() <= Qt::DiagCrossPattern ); #endif }
void MythOpenGLPainter::DrawRect(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha) { if ((fillBrush.style() == Qt::SolidPattern || fillBrush.style() == Qt::NoBrush) && realRender) { realRender->DrawRect(area, fillBrush, linePen, alpha); return; } MythPainter::DrawRect(area, fillBrush, linePen, alpha); }
QTextCharFormat EditorPage::constructTextFormat() { QTextCharFormat format; QBrush fg = ui->fgPicker->brush(); if ( fg.style() != Qt::NoBrush) format.setForeground(fg); QBrush bg = ui->bgPicker->brush(); if (bg.style() != Qt::NoBrush) format.setBackground(bg); if (ui->italicOption->isChecked()) format.setFontItalic(true); if (ui->boldOption->isChecked()) format.setFontWeight(QFont::Bold); return format; }
static QBrush awesomeHeaderBrush() { static QBrush brush; if (brush.style() == Qt::NoBrush) { QColor alphaBlue(Qt::darkBlue); alphaBlue.setAlpha(155); brush.setStyle(Qt::SolidPattern); brush.setColor(alphaBlue); } return brush; }
int KPrBrushProperty::getBrushPropertyChange() const { int flags = 0; bool fillTypeChanged = getFillType() != m_brush.fillType; if ( getFillType() == FT_BRUSH ) { QBrush brush = getQBrush(); if ( fillTypeChanged || brush.color() != m_brush.brush.color() ) { flags |= KPrBrushCmd::BrushColor; } if ( fillTypeChanged || brush.style() != m_brush.brush.style() ) { flags |= KPrBrushCmd::BrushStyle; } if ( fillTypeChanged ) { flags |= KPrBrushCmd::BrushGradientSelect; } } else { if ( fillTypeChanged || getGColor1() != m_brush.gColor1 ) { flags |= KPrBrushCmd::GradientColor1; } if ( fillTypeChanged || getGColor2() != m_brush.gColor2 ) { flags |= KPrBrushCmd::GradientColor2; } if ( fillTypeChanged || getGType() != m_brush.gType ) { flags |= KPrBrushCmd::GradientType; } if ( fillTypeChanged || getGUnbalanced() != m_brush.unbalanced ) { flags |= KPrBrushCmd::GradientBalanced; } if ( fillTypeChanged || getGXFactor() != m_brush.xfactor ) { flags |= KPrBrushCmd::GradientXFactor; } if ( fillTypeChanged || getGYFactor() != m_brush.yfactor ) { flags |= KPrBrushCmd::GradientYFactor; } if ( fillTypeChanged ) { flags |= KPrBrushCmd::BrushGradientSelect; } } return flags; }