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
+10 -2
View File
@@ -47,8 +47,7 @@ ElementInfoPartWidget::ElementInfoPartWidget(
if (key_ == QETInformation::ELMT_WIDTH || key_ == QETInformation::ELMT_HEIGHT || key_ == QETInformation::ELMT_DEPTH)
{
auto *validator = new QRegularExpressionValidator(
QETInformation::numericInfoPattern(), ui->line_edit);
auto *validator = new QETInformation::NumericInfoValidator(ui->line_edit);
ui->line_edit->setValidator(validator);
ui->line_edit->setPlaceholderText(tr("ex. 80.5"));
ui->line_edit->setToolTip(tr("Nombre décimal avec un point comme séparateur (ex. 80.5)"));
@@ -78,6 +77,15 @@ QString ElementInfoPartWidget::text() const
return (ui->line_edit->text());
}
/**
@brief ElementInfoPartWidget::hasAcceptableInput
@return whether the line edit's current text satisfies its validator
*/
bool ElementInfoPartWidget::hasAcceptableInput() const
{
return ui->line_edit->hasAcceptableInput();
}
/**
@brief ElementInfoPartWidget::setText
Set text to line edit