diff options
author | Igor Mironchik <igor.mironchik@gmail.com> | 2017-12-31 19:41:14 +0300 |
---|---|---|
committer | Igor Mironchik <igor.mironchik@gmail.com> | 2018-01-20 09:23:30 +0000 |
commit | 0d23b7f074fde36a164ed2535957114a52a28ad8 (patch) | |
tree | e996cf1f2adcacca40d14fb6de4cd4caa1f1e2be /src/gui/painting/qpainter.cpp | |
parent | 276ec1ab00fccf98c5c5a9a9b04c54a944b4178e (diff) |
Use QColor(0, 0, 0, 0) to mark body text in QStaticText
QStaticTextPrivate::paintText() now uses QColor(0, 0, 0, 0) to mark
body text. QPainter's pen color was used before this commit
(that was always black) that leads to different colors of body text if,
for example, links are in body (first block painted with correct color
set by QPainter::setPen() but after link body text was always black).
Now QPainter::drawStaticText() will draw body text with set pen in
any case.
[ChangeLog][QtGui][Important Behavior Changes] Fixed a bug where
QStaticText would not use the QPainter's pen color for text when other
text colors were also in use. Internally this reserves
QColor(0, 0, 0, 0) for use with QStaticText.
Task-number: QTBUG-45957
Change-Id: If3e180e3083cdac1b4236e738acd15572f19ab69
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 317fe4cbf7..ec1b4c1310 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5744,7 +5744,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText if (d->extended == 0 || !d->state->matrix.isAffine() || !fe->supportsTransformation(d->state->matrix)) { - staticText_d->paintText(topLeftPosition, this); + staticText_d->paintText(topLeftPosition, this, pen().color()); return; } @@ -5816,11 +5816,16 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText QPen oldPen = d->state->pen; QColor currentColor = oldPen.color(); + static const QColor bodyIndicator(0, 0, 0, 0); for (int i=0; i<staticText_d->itemCount; ++i) { QStaticTextItem *item = staticText_d->items + i; - if (item->color.isValid() && currentColor != item->color) { - setPen(item->color); - currentColor = item->color; + if (item->color.isValid() && currentColor != item->color + && item->color != bodyIndicator) { + setPen(item->color); + currentColor = item->color; + } else if (item->color == bodyIndicator) { + setPen(oldPen); + currentColor = oldPen.color(); } d->extended->drawStaticTextItem(item); |