diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-06-19 11:30:59 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-25 08:57:36 +0200 |
commit | 3ae9c8c36097abffd73e29cea1b897ca7d704916 (patch) | |
tree | 0657805f357206636bd37b9b95e6d4557ce6473c /src/quick/items/qquicktextutil.cpp | |
parent | 31ba131f9b166ef857f8559a23429d99609e6669 (diff) |
Fix clicking on links in aligned or elided Text.
Adjust the mouse position to compensate for any alignment offsets
and test the elided text layout for anchors if none is found in
the normal layout.
Change-Id: Idfda3f7e372d0f2d6c1b7bb5f22d7015d52e8239
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextutil.cpp')
-rw-r--r-- | src/quick/items/qquicktextutil.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextutil.cpp b/src/quick/items/qquicktextutil.cpp index c2c11b3daa..176301d450 100644 --- a/src/quick/items/qquicktextutil.cpp +++ b/src/quick/items/qquicktextutil.cpp @@ -78,4 +78,37 @@ QQuickItem *QQuickTextUtil::createCursor( return item; } +qreal QQuickTextUtil::alignedX(const QRectF &rect, qreal width, int alignment) +{ + qreal x = 0; + switch (alignment) { + case Qt::AlignLeft: + case Qt::AlignJustify: + break; + case Qt::AlignRight: + x = width - rect.width(); + break; + case Qt::AlignHCenter: + x = (width - rect.width()) / 2; + break; + } + return x; +} + +qreal QQuickTextUtil::alignedY(const QRectF &rect, const qreal height, int alignment) +{ + qreal y = 0; + switch (alignment) { + case Qt::AlignTop: + break; + case Qt::AlignBottom: + y = height - rect.height(); + break; + case Qt::AlignVCenter: + y = (height - rect.height()) / 2; + break; + } + return y; +} + QT_END_NAMESPACE |