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 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-04 11:31:04 +13:00
parent 69aed0cf84
commit 9d7fac1f53
+12 -2
View File
@@ -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