From 5f71da41b84fc16dd421202e3b1c871b80971fda 2015-11-02 11:01:45 From: Titta Heikkala Date: 2015-11-02 11:01:45 Subject: [PATCH] Fix color setting For some elements the brush and pen colors were set so that the default brush and pen style was used. This resulted wrong pattern for the colors. Change-Id: Ie67d954f1e6e91201a034921433e0bccf6745159 Task-number: QTRD-3736 Reviewed-by: Miikka Heikkinen --- diff --git a/src/charts/axis/qabstractaxis.cpp b/src/charts/axis/qabstractaxis.cpp index 9adc15d..b480558 100644 --- a/src/charts/axis/qabstractaxis.cpp +++ b/src/charts/axis/qabstractaxis.cpp @@ -514,7 +514,7 @@ QPen QAbstractAxis::linePen() const void QAbstractAxis::setLinePenColor(QColor color) { - QPen p = d_ptr->m_axisPen; + QPen p = linePen(); if (p.color() != color) { p.setColor(color); setLinePen(p); @@ -609,7 +609,7 @@ QPen QAbstractAxis::minorGridLinePen() const void QAbstractAxis::setGridLineColor(const QColor &color) { - QPen pen = d_ptr->m_gridLinePen; + QPen pen = gridLinePen(); if (color != pen.color()) { pen.setColor(color); d_ptr->m_gridLinePen = pen; @@ -624,7 +624,7 @@ QColor QAbstractAxis::gridLineColor() void QAbstractAxis::setMinorGridLineColor(const QColor &color) { - QPen pen = d_ptr->m_minorGridLinePen; + QPen pen = minorGridLinePen(); if (color != pen.color()) { pen.setColor(color); d_ptr->m_minorGridLinePen = pen; @@ -708,7 +708,7 @@ int QAbstractAxis::labelsAngle() const } void QAbstractAxis::setLabelsColor(QColor color) { - QBrush b = d_ptr->m_labelsBrush; + QBrush b = labelsBrush(); if (b.color() != color) { b.setColor(color); setLabelsBrush(b); @@ -851,7 +851,7 @@ QBrush QAbstractAxis::shadesBrush() const void QAbstractAxis::setShadesColor(QColor color) { - QBrush b = d_ptr->m_shadesBrush; + QBrush b = shadesBrush(); if (b.color() != color) { b.setColor(color); setShadesBrush(b); diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp index 3b78f02..f505463 100644 --- a/src/charts/legend/qlegend.cpp +++ b/src/charts/legend/qlegend.cpp @@ -237,12 +237,15 @@ void QLegend::setBrush(const QBrush &brush) */ QBrush QLegend::brush() const { - return d_ptr->m_brush; + if (d_ptr->m_brush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_brush; } void QLegend::setColor(QColor color) { - QBrush b = d_ptr->m_brush; + QBrush b = brush(); if (b.style() != Qt::SolidPattern || b.color() != color) { b.setStyle(Qt::SolidPattern); b.setColor(color); @@ -273,7 +276,10 @@ void QLegend::setPen(const QPen &pen) QPen QLegend::pen() const { - return d_ptr->m_pen; + if (d_ptr->m_pen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_pen; } void QLegend::setFont(const QFont &font) @@ -297,7 +303,7 @@ QFont QLegend::font() const void QLegend::setBorderColor(QColor color) { - QPen p = d_ptr->m_pen; + QPen p = pen(); if (p.color() != color) { p.setColor(color); setPen(p); @@ -331,12 +337,15 @@ void QLegend::setLabelBrush(const QBrush &brush) */ QBrush QLegend::labelBrush() const { - return d_ptr->m_labelBrush; + if (d_ptr->m_labelBrush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_labelBrush; } void QLegend::setLabelColor(QColor color) { - QBrush b = d_ptr->m_labelBrush; + QBrush b = labelBrush(); if (b.style() != Qt::SolidPattern || b.color() != color) { b.setStyle(Qt::SolidPattern); b.setColor(color); @@ -466,9 +475,9 @@ QLegendPrivate::QLegendPrivate(ChartPresenter *presenter, QChart *chart, QLegend m_chart(chart), m_items(new QGraphicsItemGroup(q)), m_alignment(Qt::AlignTop), - m_brush(QBrush()), - m_pen(QPen()), - m_labelBrush(QBrush()), + m_brush(QChartPrivate::defaultBrush()), + m_pen(QChartPrivate::defaultPen()), + m_labelBrush(QChartPrivate::defaultBrush()), m_diameter(5), m_attachedToChart(true), m_backgroundVisible(false),