Gui: enable range check in QuantitySpinBox when opening expression editor
This commit is contained in:
@@ -355,9 +355,18 @@ void Placement::setupUnits()
|
||||
ui->yCnt->setValue(Base::Quantity(0, Base::Unit::Length));
|
||||
ui->zCnt->setValue(Base::Quantity(0, Base::Unit::Length));
|
||||
ui->angle->setUnit(Base::Unit::Angle);
|
||||
ui->yawAngle->setMaximum(180.0F);
|
||||
ui->yawAngle->setMinimum(-180.0F);
|
||||
ui->yawAngle->setUnit(Base::Unit::Angle);
|
||||
ui->yawAngle->checkRangeInExpression(true);
|
||||
ui->pitchAngle->setMaximum(90.0F);
|
||||
ui->pitchAngle->setMinimum(-90.0F);
|
||||
ui->pitchAngle->setUnit(Base::Unit::Angle);
|
||||
ui->pitchAngle->checkRangeInExpression(true);
|
||||
ui->rollAngle->setMaximum(180.0F);
|
||||
ui->rollAngle->setMinimum(-180.0F);
|
||||
ui->rollAngle->setUnit(Base::Unit::Angle);
|
||||
ui->rollAngle->checkRangeInExpression(true);
|
||||
}
|
||||
|
||||
void Placement::setupSignalMapper()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -114,6 +114,8 @@ public:
|
||||
void selectNumber();
|
||||
|
||||
void setRange(double min, double max);
|
||||
void checkRangeInExpression(bool);
|
||||
bool isCheckedRangeInExpresion() const;
|
||||
|
||||
Base::Quantity valueFromText(const QString &text) const;
|
||||
QString textFromValue(const Base::Quantity& val) const;
|
||||
|
||||
Reference in New Issue
Block a user