mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-09 13:34:14 +02:00
Undo restores whether a shape's pivot was placed by hand
A shape remembers whether its pivot was placed by hand: a hand-placed pivot is saved and no longer follows the shape's centre when the shape is resized. Dragging the pivot handle marked it as hand-placed, but the undo step restored only the pivot and the position. After Ctrl+Z the pivot was back at the centre and still marked as hand-placed, so it stayed behind on the next resize and was saved as a <transform>. pivotIsCustom becomes a property and goes into the pivot drag's undo step, the same fix as #1367 for pictures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2809,6 +2809,7 @@ void QetShapeItem::handlerMousePressEvent(int handlerIndex)
|
||||
m_old_endAngle = m_endAngle;
|
||||
m_old_transform = m_transform;
|
||||
m_old_pos = pos();
|
||||
m_old_pivotIsCustom = m_pivotIsCustom;
|
||||
m_old_nodes = m_nodes;
|
||||
if(m_xRadius == 0 && m_yRadius == 0) {
|
||||
m_modifie_radius_equaly = true;
|
||||
@@ -2913,7 +2914,12 @@ void QetShapeItem::handlerMouseReleaseEvent(int handlerIndex)
|
||||
undo = new QUndoCommand(tr("Move the rotation center"));
|
||||
new QPropertyUndoCommand(this, "pos", m_old_pos, pos(), undo);
|
||||
new QPropertyUndoCommand(this, "pivot", m_old_transform.pivot, m_transform.pivot, undo);
|
||||
// dragPivotHandle() marked the pivot as hand-placed; undoing
|
||||
// the move has to take that back as well.
|
||||
new QPropertyUndoCommand(this, "pivotIsCustom", m_old_pivotIsCustom, m_pivotIsCustom, undo);
|
||||
}
|
||||
else
|
||||
m_pivotIsCustom = m_old_pivotIsCustom; // dragged back to where it was: nothing to undo
|
||||
break;
|
||||
|
||||
case HandleRole::CornerRadius:
|
||||
|
||||
@@ -62,6 +62,10 @@ class QetShapeItem : public QetGraphicsItem
|
||||
Q_PROPERTY(qreal scaleFactorX READ scaleFactorX WRITE setScaleFactorX NOTIFY transformChanged)
|
||||
Q_PROPERTY(qreal scaleFactorY READ scaleFactorY WRITE setScaleFactorY NOTIFY transformChanged)
|
||||
Q_PROPERTY(QPointF pivot READ pivot WRITE setPivot NOTIFY transformChanged)
|
||||
// Whether the pivot was placed by hand: a hand-placed pivot is saved
|
||||
// and no longer follows the shape's centre. Changes in the same undo
|
||||
// step as the pivot itself, so that Ctrl+Z restores both.
|
||||
Q_PROPERTY(bool pivotIsCustom READ pivotIsCustom WRITE setPivotIsCustom)
|
||||
|
||||
Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle NOTIFY arcChanged)
|
||||
Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle NOTIFY arcChanged)
|
||||
@@ -194,6 +198,8 @@ class QetShapeItem : public QetGraphicsItem
|
||||
qreal scaleFactorY() const {return m_transform.scaleY;}
|
||||
void setScaleFactorY(qreal factor);
|
||||
QPointF pivot() const {return m_transform.pivot;}
|
||||
bool pivotIsCustom() const {return m_pivotIsCustom;}
|
||||
void setPivotIsCustom(bool custom) {m_pivotIsCustom = custom;}
|
||||
void setPivot(const QPointF &pivot); // moves the pivot handle: compensates pos() so the shape does not jump
|
||||
void resetPivotToBoundingRectCenter();
|
||||
void enableNodeEditMode(); // Path only: switches to NodeEdit mode, so every node's control handles become visible
|
||||
@@ -339,6 +345,7 @@ class QetShapeItem : public QetGraphicsItem
|
||||
QVector<HandleRole> m_handleRoles; // parallel to m_handler_vector, one role per handle
|
||||
QVector<int> m_handleSlot; // parallel to m_handler_vector, meaning depends on role (see HandleRole)
|
||||
QPointF m_old_pos;
|
||||
bool m_old_pivotIsCustom = false;
|
||||
|
||||
qreal m_startAngle = 0;
|
||||
qreal m_endAngle = 360;
|
||||
|
||||
Reference in New Issue
Block a user