diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-09-11 05:48:45 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-09-11 05:48:45 (GMT) |
commit | 283ad006223cd4c178465397d25edc70362612ae (patch) | |
tree | 5afdb4a7876f2e5e99cf7a66933c27429762266a | |
parent | df478cf9577c766a0a8d0bcb7b4da6c9c0be0171 (diff) | |
download | Qt-283ad006223cd4c178465397d25edc70362612ae.zip Qt-283ad006223cd4c178465397d25edc70362612ae.tar.gz Qt-283ad006223cd4c178465397d25edc70362612ae.tar.bz2 |
Ensure text size changes when text is made empty, or elides to empty.
Previously, old size would persist if text changed from non-"" to "".
Elide text in example (tests and demonstrates)
-rw-r--r-- | examples/declarative/listview/dynamic.qml | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.cpp | 21 |
2 files changed, 12 insertions, 13 deletions
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index dde24f6..52c3c0b 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -59,8 +59,8 @@ Item { id: FruitDelegate Item { width: parent.width; height: 55 - Text { id: Label; font.pixelSize: 24; text: name } - Text { font.pixelSize: 24; text: '$'+Number(cost).toFixed(2); anchors.right: ItemButtons.left } + Text { id: Label; font.pixelSize: 24; text: name; elide: "ElideRight"; anchors.right: Cost.left; anchors.left:parent.left } + Text { id: Cost; font.pixelSize: 24; text: '$'+Number(cost).toFixed(2); anchors.right: ItemButtons.left } Row { anchors.top: Label.bottom spacing: 5 diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index c60aaf2..5b10289 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -466,9 +466,6 @@ void QFxTextPrivate::updateSize() { Q_Q(QFxText); if (q->isComponentComplete()) { - if (text.isEmpty()) { - return; - } QFontMetrics fm(font); int dy = q->height(); @@ -633,15 +630,17 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle) //paint text QPixmap img(size); - img.fill(Qt::transparent); - QPainter p(&img); - if (drawStyle) { - p.setPen(styleColor); + if (!size.isEmpty()) { + img.fill(Qt::transparent); + QPainter p(&img); + if (drawStyle) { + p.setPen(styleColor); + } + else + p.setPen(color); + p.setFont(font); + layout.draw(&p, QPointF(0, 0)); } - else - p.setPen(color); - p.setFont(font); - layout.draw(&p, QPointF(0, 0)); return img; } |