summaryrefslogtreecommitdiffstats
path: root/src/charts/legend
diff options
context:
space:
mode:
authorTitta Heikkala <titta.heikkala@theqtcompany.com>2015-11-02 09:47:59 +0200
committerTitta Heikkala <titta.heikkala@theqtcompany.com>2015-11-02 11:01:45 +0000
commit5f71da41b84fc16dd421202e3b1c871b80971fda (patch)
treee753c29d74e0427ef6d7d81017bf44af669c8fe6 /src/charts/legend
parent0e82bb0d49f5803129f15efbb5ccbc3f2365a93a (diff)
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 <miikka.heikkinen@theqtcompany.com>
Diffstat (limited to 'src/charts/legend')
-rw-r--r--src/charts/legend/qlegend.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp
index 3b78f027..f5054635 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),