From 992058348b2c2e9c4b470d2d16b10deb59a8ed16 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Tue, 20 Oct 2026 19:37:20 +0200 Subject: [PATCH] Report jump: put the mouse pointer on the end jumped to A double click on a linked folio report showed the other end's folio and highlighted it, but left the mouse pointer where it was, on every platform, while only Wayland forbids a program to move it. On Windows, X11 and macOS the pointer is now put on the end jumped to, once the folio shown has its size (next turn of the event loop), so that a second double click jumps back. On Wayland the highlight alone still shows where the jump landed. The pointing hand over a report's label text also stayed after a click: mousePressEvent() puts the text colour back, and the cursor was only unset with the colour in hoverLeaveEvent(). It is now always unset when the mouse leaves the text. --- .../dynamicelementtextitem.cpp | 5 ++-- sources/qetgraphicsitem/element.cpp | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index 7fc536a45..bb393c35a 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -778,9 +778,10 @@ void DynamicElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { setDefaultTextColor(m_user_color); m_user_color = QColor(); //m_user_color is now invalid - unsetCursor(); } - + //Out of the test above: a click (mousePressEvent()) already put + //the colour back, and the hand would stay after it + unsetCursor(); } void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 982b1ed22..125c069a0 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -47,6 +47,8 @@ #include #include +#include +#include #include #include #include @@ -296,8 +298,8 @@ void Element::showAsJumpTarget() cross reference: its folio is shown whole, as a page, without zooming in on it, and the target and its texts are shaded blue for a moment, so that the eye finds it on the page. - (The mouse pointer cannot be put on it: Wayland does not let a program - move the pointer.) + The mouse pointer is put on it too, except on Wayland, which does not + let a program move the pointer. */ void Element::jumpTo(Element *target) { @@ -315,6 +317,26 @@ void Element::jumpTo(Element *target) view->fitInView(diagram->sceneRect(), Qt::KeepAspectRatio); } target->showAsJumpTarget(); + + //Put the mouse pointer on the target, so that a double click + //there jumps back. Once the folio shown has its size (next turn + //of the event loop). Wayland does not let a program move the + //pointer: there the highlight alone shows where the jump landed. + if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) + return; + QTimer::singleShot(0, target, [target]() { + if (!target->diagram()) + return; + for (QGraphicsView *view : target->diagram()->views()) + { + if (!view->isVisible()) + continue; + const QPoint pos = view->mapFromScene(target->sceneBoundingRect().center()); + if (view->viewport()->rect().contains(pos)) + QCursor::setPos(view->viewport()->mapToGlobal(pos)); + return; + } + }); } /**