diff --git a/src/chatlog/content/text.cpp b/src/chatlog/content/text.cpp index 58002220e..cadf6b274 100644 --- a/src/chatlog/content/text.cpp +++ b/src/chatlog/content/text.cpp @@ -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; diff --git a/src/chatlog/content/text.h b/src/chatlog/content/text.h index 1f15107ac..4fe23ad92 100644 --- a/src/chatlog/content/text.h +++ b/src/chatlog/content/text.h @@ -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;