1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Text anchors: use PointingHandCursor

This commit is contained in:
krepa098 2015-02-11 17:03:38 +01:00
parent 788d57c815
commit 0b56916b9f
2 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,7 @@ Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwTe
{
setText(txt);
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptHoverEvents(true);
}
Text::~Text()
@ -210,6 +211,16 @@ void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QDesktopServices::openUrl(anchor);
}
void Text::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
QString anchor = doc->documentLayout()->anchorAt(event->pos());
if(!anchor.isEmpty())
setCursor(QCursor(Qt::PointingHandCursor));
else
setCursor(QCursor());
}
QString Text::getText() const
{
return rawText;

View File

@ -51,6 +51,7 @@ public:
virtual qreal getAscent() const override;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
virtual QString getText() const override;