summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 10:56:55 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-29 12:09:17 (GMT)
commitd717d2686ecdbeafee1f5cabc6832c8339cfb2b4 (patch)
treea64103fc91a3dda5fdf6cb7414a5146665507ce9 /src/gui
parente7eb7bdf63791ed03257f2f23b1f515e4d89e054 (diff)
downloadQt-d717d2686ecdbeafee1f5cabc6832c8339cfb2b4.zip
Qt-d717d2686ecdbeafee1f5cabc6832c8339cfb2b4.tar.gz
Qt-d717d2686ecdbeafee1f5cabc6832c8339cfb2b4.tar.bz2
Respect QPainter::pen() in QPainter::drawStaticText()
QStaticText needs to support changing the pen on the painter to support rich text, but it should not override the pen unless it has been explicitly set in the rich text. We do this by marking the pen as dirty in updateState() when we record the text items. Task-number: QTBUG-8908 Reviewed-by: Gunnar
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/text/qstatictext.cpp15
2 files changed, 13 insertions, 4 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 1c528fe..ac5c8b7 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5901,7 +5901,7 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
QColor currentColor = oldPen.color();
for (int i=0; i<staticText_d->itemCount; ++i) {
QStaticTextItem *item = staticText_d->items + i;
- if (currentColor != item->color) {
+ if (item->color.isValid() && currentColor != item->color) {
setPen(item->color);
currentColor = item->color;
}
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index d685cd9..f433c78 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -388,10 +388,17 @@ namespace {
m_expectedItemCount(expectedItemCount),
m_expectedGlyphCount(expectedGlyphCount),
m_glyphPool(glyphPool),
- m_positionPool(positionPool)
+ m_positionPool(positionPool),
+ m_dirtyPen(false)
{
}
+ virtual void updateState(const QPaintEngineState &newState)
+ {
+ if (newState.state() & QPaintEngine::DirtyPen)
+ m_dirtyPen = true;
+ }
+
virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
{
const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
@@ -412,7 +419,8 @@ namespace {
currentItem->numGlyphs = ti.glyphs.numGlyphs;
currentItem->glyphs = m_glyphPool;
currentItem->glyphPositions = m_positionPool;
- currentItem->color = state->pen().color();
+ if (m_dirtyPen)
+ currentItem->color = state->pen().color();
QTransform matrix = state->transform();
matrix.translate(position.x(), position.y());
@@ -435,7 +443,6 @@ namespace {
virtual bool begin(QPaintDevice *) { return true; }
virtual bool end() { return true; }
- virtual void updateState(const QPaintEngineState &) {}
virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {}
virtual Type type() const
{
@@ -461,6 +468,8 @@ namespace {
glyph_t *m_glyphPool;
QFixedPoint *m_positionPool;
+
+ bool m_dirtyPen;
};
class DrawTextItemDevice: public QPaintDevice