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; + } + }); } /**