diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index f0eb50e2a6..4f22c75a36 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -91,9 +91,20 @@ void ExpressionSpinBox::showInvalidExpression(const QString& tip) p.setColor(QPalette::Active, QPalette::Text, Qt::red); lineedit->setPalette(p); iconLabel->setToolTip(tip); + iconLabel->setPixmap(getIcon(":/icons/button_invalid.svg", QSize(iconHeight, iconHeight))); } void ExpressionSpinBox::showValidExpression(ExpressionSpinBox::Number number) +{ + try { + showExpression(number); + } + catch (const Base::Exception& e) { + showInvalidExpression(QString::fromUtf8(e.what())); + } +} + +void ExpressionSpinBox::showExpression(Number number) { std::unique_ptr result(getExpression()->eval()); auto* value = freecad_cast(result.get()); diff --git a/src/Gui/SpinBox.h b/src/Gui/SpinBox.h index 14d12c50ca..a0124926b6 100644 --- a/src/Gui/SpinBox.h +++ b/src/Gui/SpinBox.h @@ -73,6 +73,9 @@ protected: void drawControl(QStyleOptionSpinBox&); +private: + void showExpression(Number number); + protected: QLineEdit* lineedit; QAbstractSpinBox* spinbox;