Guard numeric elementInformation fields against "." and normalize decimal comma

- ElementInfoWidget::currentInfo() now skips a field whose validator
  hasn't accepted its text (e.g. a lone "." mid-typing), which
  previously stored and later parsed to 0.
- New QETInformation::NumericInfoValidator rewrites "," to "." before
  validating, so 80,5 on a German/French keyboard no longer silently
  becomes 805. Used at both existing call sites.
- Restored the header's #1/#2/#3 doc comment (was reflowed into a
  run-on paragraph by a previous edit).
This commit is contained in:
Levi Jetzer
2026-08-21 15:16:36 +02:00
parent 5dbb9f28de
commit 7c941e4697
6 changed files with 57 additions and 10 deletions
@@ -44,6 +44,7 @@
#include <QSplitter>
#include <QShortcut>
#include <QMenu>
#include <QRegularExpressionValidator>
/**
@brief The EditorDelegate class
@@ -69,8 +70,7 @@ class EditorDelegate : public QItemDelegate
if (key == QETInformation::ELMT_WIDTH || key == QETInformation::ELMT_HEIGHT || key == QETInformation::ELMT_DEPTH)
{
auto *line_edit = new QLineEdit(parent);
auto *validator = new QRegularExpressionValidator(
QETInformation::numericInfoPattern(), line_edit);
auto *validator = new QETInformation::NumericInfoValidator(line_edit);
line_edit->setValidator(validator);
line_edit->setPlaceholderText(tr("ex. 80.5"));
line_edit->setToolTip(tr("Nombre décimal avec un point comme séparateur (ex. 80.5)"));