summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-01-07 00:36:01 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2011-01-07 00:38:53 (GMT)
commit8b45ca46095020c495b44d764bb439018a87d22a (patch)
tree1e3434a862e4a44ef5ee7bb74ba0ca370b2d8c8f /src/declarative/graphicsitems/qdeclarativetextedit.cpp
parentc1a87921c8a85d5ecee9aba3b3578ae8d042c28a (diff)
downloadQt-8b45ca46095020c495b44d764bb439018a87d22a.zip
Qt-8b45ca46095020c495b44d764bb439018a87d22a.tar.gz
Qt-8b45ca46095020c495b44d764bb439018a87d22a.tar.bz2
Add linkActivated signal to TextEdit
Since TextEdit can also contain rich text with anchors, it should also have a linkActivated signal like Text does. Task-number: QTBUG-15283 Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index c1314ff..c71fd98 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -103,6 +103,14 @@ TextEdit {
\sa Text, TextInput, {declarative/text/textselection}{Text Selection example}
*/
+/*!
+ \qmlsignal TextEdit::onLinkActivated(string link)
+ \since Quick 1.1
+
+ This handler is called when the user clicks on a link embedded in the text.
+ The link must be in rich text or HTML format and the
+ \a link string provides access to the particular link.
+*/
QDeclarativeTextEdit::QDeclarativeTextEdit(QDeclarativeItem *parent)
: QDeclarativePaintedItem(*(new QDeclarativeTextEditPrivate), parent)
{
@@ -894,11 +902,11 @@ void QDeclarativeTextEdit::setReadOnly(bool r)
return;
- Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
+ Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse;
if (r) {
- flags = Qt::TextSelectableByMouse;
+ flags = flags | Qt::TextSelectableByMouse;
} else {
- flags = Qt::TextEditorInteraction;
+ flags = flags | Qt::TextEditorInteraction;
}
d->control->setTextInteractionFlags(flags);
if (!r)
@@ -1260,6 +1268,7 @@ void QDeclarativeTextEditPrivate::init()
control = new QTextControl(q);
control->setIgnoreUnusedNavigationEvents(true);
+ control->setTextInteractionFlags(control->textInteractionFlags() | Qt::LinksAccessibleByMouse);
// QTextControl follows the default text color
// defined by the platform, declarative text
@@ -1278,6 +1287,7 @@ void QDeclarativeTextEditPrivate::init()
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorRectangleChanged()));
+ QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
document = control->document();
document->setDefaultFont(font);