From 9d7fac1f539a22ff1f0cff9224a2c571a7b4ad50 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sun, 4 Oct 2026 11:31:04 +1300 Subject: [PATCH] Element editor: keep a static text's alignment while typing (#1252) startEdition() records the bounding rect, but the aligned point was only restored in endEdition(), so a right/centre/bottom-aligned text grew from its old left/top edge while being typed into and jumped into place when the edition ended. Re-anchor after every content change during inline edition. endEdition() now always clears previous_text, which marks an edition in progress. It used to stay set after an edition that left the text unchanged. Co-Authored-By: Claude Opus 5.5 --- sources/editor/graphicspart/parttext.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sources/editor/graphicspart/parttext.cpp b/sources/editor/graphicspart/parttext.cpp index 56f7faa93..9430f429f 100644 --- a/sources/editor/graphicspart/parttext.cpp +++ b/sources/editor/graphicspart/parttext.cpp @@ -57,7 +57,17 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) : connect(document(), &QTextDocument::contentsChanged, this, - [this]() { adjustItemPosition(); }); + [this]() { + adjustItemPosition(); + // During inline edition, keep the aligned point in place after + // every keystroke instead of only when the edition ends (#1252). + // setPlainText() and setFont() re-anchor on their own. + if (!previous_text.isNull()) { + applyLineAlignment(); + finishAlignment(); + prepareAlignment(); + } + }); } /// Destructeur @@ -552,8 +562,8 @@ void PartText::endEdition() QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "text", previous_text, new_text); undo -> setText(tr("Modifier un champ texte")); undoStack().push(undo); - previous_text = QString(); } + previous_text = QString(); } // deselectionne le texte