mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 14:14:15 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user