Report jump: put the mouse pointer on the end jumped to
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m41s

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.
This commit is contained in:
Laurent Trinques
2026-10-20 19:37:20 +02:00
parent aebe82d6c2
commit 992058348b
2 changed files with 27 additions and 4 deletions
@@ -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)
+24 -2
View File
@@ -47,6 +47,8 @@
#include <QAbstractTextDocumentLayout>
#include <QApplication>
#include <QCursor>
#include <QGuiApplication>
#include <QCollator>
#include <QScreen>
#include <QTimer>
@@ -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;
}
});
}
/**