Keep a line's pivot at its centre when one of its ends is dragged

A shape's pivot follows its centre when it is resized, unless it was
placed by hand: setLine() and setRect() do that, and so did dragging a
rectangle's or an ellipse's handles, which goes through setRect().
Dragging an end of a line moved the end directly and left the pivot
where it was, so the next rotation turned the line around a point
beside it. Undo and redo already re-centred it, through setLine().

The line's handle drag now applies the same rule.

New tst_linepivotresize, on a real folio with scene mouse events: the
pivot is at the new centre after an end is dragged (fails without the
change: it stays at the old centre), and after undo and redo; a pivot
placed by hand stays; a rectangle's pivot follows as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Beat Hangartner
2026-10-09 14:35:26 +02:00
parent eab557d9af
commit c52cd3b2fc
3 changed files with 171 additions and 0 deletions
+4
View File
@@ -2465,6 +2465,10 @@ void QetShapeItem::dragResize(int index, const QPointF &localPos, Qt::KeyboardMo
{
prepareGeometryChange();
(index == 0 ? m_P1 : m_P2) = localPos;
// The same rule as setLine() and setRect(): a pivot nobody placed
// by hand follows the centre.
if (!m_pivotIsCustom)
resetPivotToBoundingRectCenter();
repositionHandles();
emit geometryChanged();
return;