Gui: enable range check in QuantitySpinBox when opening expression editor

This commit is contained in:
wmayer
2022-12-19 14:46:31 +01:00
parent d7957531f2
commit e171a1f6e1
3 changed files with 29 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ public:
QuantitySpinBoxPrivate(QuantitySpinBox *q) :
validInput(true),
pendingEmit(false),
checkRangeInExpression(false),
unitValue(0),
maximum(DOUBLE_MAX),
minimum(-DOUBLE_MAX),
@@ -230,6 +231,7 @@ public:
QLocale locale;
bool validInput;
bool pendingEmit;
bool checkRangeInExpression;
QString validStr;
Base::Quantity quantity;
Base::Quantity cached;
@@ -516,7 +518,9 @@ void QuantitySpinBox::openFormulaDialog()
Q_D(const QuantitySpinBox);
auto box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), d->unit, this);
box->setRange(d->minimum, d->maximum);
if (d->checkRangeInExpression) {
box->setRange(d->minimum, d->maximum);
}
QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [=]() {
if (box->result() == QDialog::Accepted)
setExpression(box->getExpression());
@@ -638,6 +642,19 @@ void QuantitySpinBox::setRange(double minimum, double maximum)
d->maximum = maximum;
}
void QuantitySpinBox::checkRangeInExpression(bool on)
{
Q_D(QuantitySpinBox);
d->checkRangeInExpression = on;
}
bool QuantitySpinBox::isCheckedRangeInExpresion() const
{
Q_D(const QuantitySpinBox);
return d->checkRangeInExpression;
}
int QuantitySpinBox::decimals() const
{
Q_D(const QuantitySpinBox);