From 1d37ce9b84ce42d7d988b46f9c3df247a4a3e9f7 Mon Sep 17 00:00:00 2001 From: Beat Hangartner Date: Mon, 5 Oct 2026 17:57:03 +0200 Subject: [PATCH 1/2] Show "Auto" in the width box of element editor text fields The width box of a dynamic text field in the element editor showed -1 for the automatic width and stopped at 500 px. It now shows "Auto" and "px", and goes up to 10000 px, so a wider field is not cut to 500 just by being shown. Leaving the box without changing it no longer pushes a change either: the box holds whole pixels, while a width fitted to the text (or set elsewhere) can have decimals, and the comparison made the field's width round itself on every focus loss. Co-Authored-By: Claude Opus 5.5 --- sources/editor/ui/dynamictextfieldeditor.cpp | 4 +++- sources/editor/ui/dynamictextfieldeditor.ui | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index 47d87a91c..1640907ce 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -363,7 +363,9 @@ void DynamicTextFieldEditor::on_m_width_sb_editingFinished() qreal width = (qreal)ui -> m_width_sb -> value(); for (int i = 0; i < m_parts.length(); i++) { - if(width != m_parts[i] -> textWidth()) { + //The box shows whole pixels: a width dragged with the mouse or + //fitted to the text is not rounded just by leaving the box. + if(ui -> m_width_sb -> value() != qRound(m_parts[i] -> textWidth())) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i] -> textWidth(), width); undo -> setText(tr("Modifier la largeur d'un texte")); undoStack().push(undo); diff --git a/sources/editor/ui/dynamictextfieldeditor.ui b/sources/editor/ui/dynamictextfieldeditor.ui index 516b41853..59c8defde 100644 --- a/sources/editor/ui/dynamictextfieldeditor.ui +++ b/sources/editor/ui/dynamictextfieldeditor.ui @@ -101,11 +101,17 @@ + + Auto + + + px + -1 - 500 + 10000 From a0cfa580bbdb6fa9321c8c720e038b4691b5a1fd Mon Sep 17 00:00:00 2001 From: Beat Hangartner Date: Tue, 6 Oct 2026 09:41:01 +0200 Subject: [PATCH 2/2] Round the width when filling the element editor width box updateForm() filled the box with setValue(textWidth()), and setValue(int) truncates: a field 61.7 px wide showed 61 while editingFinished compared with qRound() = 62, so leaving the box still set the width to 61 and pushed an undo step. Round in both places. Co-Authored-By: Claude Opus 5.5 --- sources/editor/ui/dynamictextfieldeditor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index 1640907ce..972de4176 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -157,7 +157,9 @@ void DynamicTextFieldEditor::updateForm() m_color_kpb -> setColor(m_text_field.data() -> color()); } #endif - ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth()); + //Rounded as on_m_width_sb_editingFinished() compares it; + //setValue(int) would truncate 61.7 to 61 + ui -> m_width_sb -> setValue(qRound(m_text_field.data() -> textWidth())); ui -> m_font_pb -> setText(m_text_field -> font().family()); switch (m_text_field.data() -> textFrom()) { @@ -363,8 +365,8 @@ void DynamicTextFieldEditor::on_m_width_sb_editingFinished() qreal width = (qreal)ui -> m_width_sb -> value(); for (int i = 0; i < m_parts.length(); i++) { - //The box shows whole pixels: a width dragged with the mouse or - //fitted to the text is not rounded just by leaving the box. + //The box shows whole pixels: a width fitted to the text is not + //rounded just by leaving the box. if(ui -> m_width_sb -> value() != qRound(m_parts[i] -> textWidth())) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i] -> textWidth(), width); undo -> setText(tr("Modifier la largeur d'un texte"));