From 41e1e8172c4e86b02599ee4fec2b24cdb330c5ee Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Tue, 22 Sep 2026 15:02:31 +0200 Subject: [PATCH] Keep paste at original XML position instead of moving to cursor Commit dd0c194a3 (#913) moved the pasted group to the cursor position at construction time. The desired behaviour is that items appear at their original XML coordinates (where they were copied from) so the user starts from the origin. The grid-snapped movement baseline and the context-menu restoration from that commit are kept. --- sources/diagramevent/diagrameventaddpaste.cpp | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/sources/diagramevent/diagrameventaddpaste.cpp b/sources/diagramevent/diagrameventaddpaste.cpp index 5c867936c..a22d7d485 100644 --- a/sources/diagramevent/diagrameventaddpaste.cpp +++ b/sources/diagramevent/diagrameventaddpaste.cpp @@ -40,6 +40,7 @@ DiagramEventAddPaste::DiagramEventAddPaste(Diagram *diagram, const QPointF &start_pos) : DiagramEventInterface(diagram) { + Q_UNUSED(start_pos); // items stay at their original XML position //DiagramEventInterface::init() is called by Diagram::setEventInterface //only when it is replacing an earlier interface, so call it here as //DiagramEventAddMacro does. @@ -85,33 +86,23 @@ }; const QPointF grid_origin = snapGrid(top_left); - //Move the group to the cursor, rather than the cursor to the - //group. Both put the copy under the pointer, but warping the - //pointer also drags it back to the original's position, so the - //copy appears exactly on top of what was copied until the mouse - //is moved -- which is the thing pasting under the cursor was - //meant to avoid (issue #913). Taking the pointer away from - //where the user put it is also its own surprise. - m_group_origin = snapGrid(start_pos); - const QPointF offset = m_group_origin - grid_origin; - - //Store each item's position after the move. moveTo() applies a + //Store each item's original position. moveTo() applies a //grid-snapped delta from the baseline to these, so items //preserve their layout and move in whole grid steps. for (auto *item : movable) { - item->setPos(item->pos() + offset); m_relative_pos.insert(item, item->pos()); } + m_group_origin = grid_origin; - //The conductors were laid out against the old terminal + //The conductors were laid out against the original terminal //positions, so re-route them before anything is drawn. const QList conductors = m_content.conductors(DiagramContent::AnyConductor); for (auto *conductor : conductors) { conductor->updatePath(); } - //The baseline is known now, so moveTo() does not have to - //capture one from the first mouse movement. + //The baseline is the group's grid-snapped origin, so moveTo() + //does not have to capture one from the first mouse movement. m_initial_cursor = m_group_origin; m_baseline_captured = true;