From 1a2e77cf6ee860e4647f5c5191c9cd48ef0e936b Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Wed, 29 Nov 2017 16:26:41 +0100 Subject: [PATCH] Spinboxes: Fix for issue #3278. --- src/Gui/SpinBox.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 8bb1ab2ad9..a0c0acecab 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -38,6 +38,7 @@ #include #include #include "QuantitySpinBox_p.h" +#include using namespace Gui; using namespace App; @@ -371,7 +372,13 @@ void UIntSpinBox::openFormulaDialog() { Q_ASSERT(isBound()); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), Unit(), this); + PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); + Unit unit; + + if (qprop != 0) + unit = qprop->getUnit(); + + Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, this); connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); box->show(); @@ -546,7 +553,13 @@ void IntSpinBox::openFormulaDialog() { Q_ASSERT(isBound()); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), Unit(), this); + PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); + Unit unit; + + if (qprop != 0) + unit = qprop->getUnit(); + + Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(),unit, this); connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); box->show(); @@ -721,7 +734,13 @@ void DoubleSpinBox::openFormulaDialog() { Q_ASSERT(isBound()); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), Unit(), this); + PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); + Unit unit; + + if (qprop != 0) + unit = qprop->getUnit(); + + Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, this); connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); box->show();