Skip to content

Commit

Permalink
Gui: [skip ci] fix bugs in spin box classes:
Browse files Browse the repository at this point in the history
+ use correct format string when assigning value to an expression
+ do not round value when setting value of a DoubleSpinBox
  • Loading branch information
wwmayer committed Sep 9, 2020
1 parent b0d5afc commit b38517b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Gui/SpinBox.cpp
Expand Up @@ -409,6 +409,7 @@ void UIntSpinBox::keyPressEvent(QKeyEvent *event)
QAbstractSpinBox::keyPressEvent(event);
}

// ----------------------------------------------------------------------------

IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) {

Expand Down Expand Up @@ -437,7 +438,7 @@ IntSpinBox::~IntSpinBox() {
bool IntSpinBox::apply(const std::string& propName) {

if (!ExpressionBinding::apply(propName)) {
Gui::Command::doCommand(Gui::Command::Doc, "%s = %u", propName.c_str(), value());
Gui::Command::doCommand(Gui::Command::Doc, "%s = %d", propName.c_str(), value());
return true;
}
else
Expand Down Expand Up @@ -586,6 +587,7 @@ void IntSpinBox::keyPressEvent(QKeyEvent *event)
QAbstractSpinBox::keyPressEvent(event);
}

// ----------------------------------------------------------------------------

DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) {

Expand Down Expand Up @@ -614,11 +616,11 @@ DoubleSpinBox::~DoubleSpinBox() {
bool DoubleSpinBox::apply(const std::string& propName) {

if (!ExpressionBinding::apply(propName)) {
Gui::Command::doCommand(Gui::Command::Doc, "%s = %u", propName.c_str(), value());
Gui::Command::doCommand(Gui::Command::Doc, "%s = %f", propName.c_str(), value());
return true;
}
else
return false;

return false;
}

void DoubleSpinBox::bind(const ObjectIdentifier& _path) {
Expand Down Expand Up @@ -654,7 +656,7 @@ void DoubleSpinBox::onChange() {
NumberExpression * value = freecad_dynamic_cast<NumberExpression>(result.get());

if (value) {
setValue(boost::math::round(value->getValue()));
setValue(value->getValue());
setReadOnly(true);
iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)));

Expand Down

0 comments on commit b38517b

Please sign in to comment.