make links clicking and text selection actually work
svn path=/branches/KDE/4.4/kdelibs/; revision=1095291
This commit is contained in:
parent
af46d07b61
commit
0174e8599b
@ -116,6 +116,7 @@ Label::Label(QGraphicsWidget *parent)
|
|||||||
QLabel *native = new QLabel;
|
QLabel *native = new QLabel;
|
||||||
//disabled for now: triggers Qt bug 7254
|
//disabled for now: triggers Qt bug 7254
|
||||||
//native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
//native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
||||||
|
native->setTextInteractionFlags(Qt::TextBrowserInteraction)
|
||||||
d->textSelectable = false;
|
d->textSelectable = false;
|
||||||
connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString)));
|
connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString)));
|
||||||
connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString)));
|
connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString)));
|
||||||
@ -190,7 +191,7 @@ bool Label::hasScaledContents() const
|
|||||||
|
|
||||||
void Label::setTextSelectable(bool enable)
|
void Label::setTextSelectable(bool enable)
|
||||||
{
|
{
|
||||||
d->textSelectable = enable;
|
d->textSelectable = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::textSelectable() const
|
bool Label::textSelectable() const
|
||||||
@ -255,10 +256,14 @@ void Label::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
|
|
||||||
void Label::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void Label::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!d->textSelectable) {
|
QGraphicsProxyWidget::mousePressEvent(event);
|
||||||
event->ignore();
|
event->accept();
|
||||||
} else {
|
}
|
||||||
QGraphicsProxyWidget::mousePressEvent(event);
|
|
||||||
|
void Label::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (d->textSelectable) {
|
||||||
|
QGraphicsProxyWidget::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ public Q_SLOTS:
|
|||||||
protected:
|
protected:
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void paint(QPainter *painter,
|
void paint(QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
Loading…
Reference in New Issue
Block a user