From a3e3487f74ede1fef365c5e1031625cf4a6c3ab6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 27 Mar 2021 18:31:49 +0100 Subject: [PATCH] Gui: [skip ci] handle number of decimals in PropertyUnitItem, PropertyVectorDistanceItem and PropertyPlacementItem --- src/Gui/propertyeditor/PropertyItem.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 330a7224ca..6eeac387ce 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1051,7 +1051,8 @@ void PropertyUnitItem::setValue(const QVariant& value) return; const Base::Quantity& val = value.value(); - QString unit = QString::fromLatin1("'%1 %2'").arg(val.getValue()).arg(val.getUnit().getString()); + QString unit = QString::fromLatin1("'%1 %2'").arg(val.getValue(),0,'f',decimals()) + .arg(val.getUnit().getString()); setPropertyValue(unit); } } @@ -1643,9 +1644,9 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant) Base::Quantity y = Base::Quantity(value.y, Base::Unit::Length); Base::Quantity z = Base::Quantity(value.z, Base::Unit::Length); QString data = QString::fromLatin1("(%1, %2, %3)") - .arg(x.getValue()) - .arg(y.getValue()) - .arg(z.getValue()); + .arg(x.getValue(),0,'f',decimals()) + .arg(y.getValue(),0,'f',decimals()) + .arg(z.getValue(),0,'f',decimals()); setPropertyValue(data); } @@ -2370,13 +2371,13 @@ void PropertyPlacementItem::setValue(const QVariant& value) QString data = QString::fromLatin1("App.Placement(" "App.Vector(%1,%2,%3)," "App.Rotation(App.Vector(%4,%5,%6),%7))") - .arg(pos.x) - .arg(pos.y) - .arg(pos.z) - .arg(rot_axis.x) - .arg(rot_axis.y) - .arg(rot_axis.z) - .arg(rot_angle,0); + .arg(pos.x, 0, 'f', decimals()) + .arg(pos.y, 0, 'f', decimals()) + .arg(pos.z, 0, 'f', decimals()) + .arg(rot_axis.x, 0, 'f', decimals()) + .arg(rot_axis.y, 0, 'f', decimals()) + .arg(rot_axis.z, 0, 'f', decimals()) + .arg(rot_angle, 0, 'f', decimals()); setPropertyValue(data); }