From 0174e8599bf4f11e6b4fa4db32f65a405e356ae9 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 23 Feb 2010 23:04:25 +0000 Subject: [PATCH] make links clicking and text selection actually work svn path=/branches/KDE/4.4/kdelibs/; revision=1095291 --- widgets/label.cpp | 17 +++++++++++------ widgets/label.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/widgets/label.cpp b/widgets/label.cpp index 10d93fc40..b73f4f325 100644 --- a/widgets/label.cpp +++ b/widgets/label.cpp @@ -116,6 +116,7 @@ Label::Label(QGraphicsWidget *parent) QLabel *native = new QLabel; //disabled for now: triggers Qt bug 7254 //native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget); + native->setTextInteractionFlags(Qt::TextBrowserInteraction) d->textSelectable = false; connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString))); connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString))); @@ -190,9 +191,9 @@ bool Label::hasScaledContents() const void Label::setTextSelectable(bool enable) { - d->textSelectable = enable; + d->textSelectable = enable; } - + bool Label::textSelectable() const { return d->textSelectable; @@ -255,10 +256,14 @@ void Label::resizeEvent(QGraphicsSceneResizeEvent *event) void Label::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (!d->textSelectable) { - event->ignore(); - } else { - QGraphicsProxyWidget::mousePressEvent(event); + QGraphicsProxyWidget::mousePressEvent(event); + event->accept(); +} + +void Label::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (d->textSelectable) { + QGraphicsProxyWidget::mouseMoveEvent(event); } } diff --git a/widgets/label.h b/widgets/label.h index d672ae0b0..dbf28509a 100644 --- a/widgets/label.h +++ b/widgets/label.h @@ -148,6 +148,7 @@ public Q_SLOTS: protected: void resizeEvent(QGraphicsSceneResizeEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);