Draft: Adapted input boxes to use Units->Decimals pref setting

This commit is contained in:
Yorik van Havre 2013-09-29 13:21:29 -03:00
parent 4487df35de
commit 069481aa3d
3 changed files with 16 additions and 13 deletions

View File

@ -400,6 +400,7 @@ class _CommandStructure:
def taskbox(self):
"sets up a taskbox widget"
d = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2)
w = QtGui.QWidget()
w.setWindowTitle(str(translate("Arch","Structure options")))
lay0 = QtGui.QVBoxLayout(w)
@ -422,7 +423,7 @@ class _CommandStructure:
label1 = QtGui.QLabel(str(translate("Arch","Length")))
lay1.addWidget(label1)
self.vLength = QtGui.QDoubleSpinBox()
self.vLength.setDecimals(2)
self.vLength.setDecimals(d)
self.vLength.setMaximum(99999.99)
self.vLength.setValue(self.Length)
lay1.addWidget(self.vLength)
@ -433,7 +434,7 @@ class _CommandStructure:
label2 = QtGui.QLabel(str(translate("Arch","Width")))
lay2.addWidget(label2)
self.vWidth = QtGui.QDoubleSpinBox()
self.vWidth.setDecimals(2)
self.vWidth.setDecimals(d)
self.vWidth.setMaximum(99999.99)
self.vWidth.setValue(self.Width)
lay2.addWidget(self.vWidth)
@ -444,7 +445,7 @@ class _CommandStructure:
label3 = QtGui.QLabel(str(translate("Arch","Height")))
lay3.addWidget(label3)
self.vHeight = QtGui.QDoubleSpinBox()
self.vHeight.setDecimals(2)
self.vHeight.setDecimals(d)
self.vHeight.setMaximum(99999.99)
self.vHeight.setValue(self.Height)
lay3.addWidget(self.vHeight)

View File

@ -251,6 +251,7 @@ class _CommandWall:
def taskbox(self):
"sets up a taskbox widget"
d = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2)
w = QtGui.QWidget()
w.setWindowTitle(str(translate("Arch","Wall options")))
lay0 = QtGui.QVBoxLayout(w)
@ -260,7 +261,7 @@ class _CommandWall:
label5 = QtGui.QLabel(str(translate("Arch","Length")))
lay5.addWidget(label5)
self.Length = QtGui.QDoubleSpinBox()
self.Length.setDecimals(2)
self.Length.setDecimals(d)
self.Length.setValue(0.00)
lay5.addWidget(self.Length)
@ -269,7 +270,7 @@ class _CommandWall:
label1 = QtGui.QLabel(str(translate("Arch","Width")))
lay1.addWidget(label1)
value1 = QtGui.QDoubleSpinBox()
value1.setDecimals(2)
value1.setDecimals(d)
value1.setValue(self.Width)
lay1.addWidget(value1)
@ -278,7 +279,7 @@ class _CommandWall:
label2 = QtGui.QLabel(str(translate("Arch","Height")))
lay2.addWidget(label2)
value2 = QtGui.QDoubleSpinBox()
value2.setDecimals(2)
value2.setDecimals(d)
value2.setValue(self.Height)
lay2.addWidget(value2)

View File

@ -253,7 +253,7 @@ class DraftToolBar:
def _spinbox (self,name, layout, val=None, vmax=None, hide=True, double=False, size=None):
if double:
sbox = QtGui.QDoubleSpinBox(self.baseWidget)
sbox.setDecimals(2)
sbox.setDecimals(FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2))
else:
sbox = QtGui.QSpinBox(self.baseWidget)
sbox.setObjectName(name)
@ -1214,21 +1214,22 @@ class DraftToolBar:
dp = plane.getLocalCoords(point)
# set widgets
ds = "%." + str(FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2)) + "f"
if self.mask in ['y','z']:
self.xValue.setText("0.00")
self.xValue.setText(ds % 0)
else:
if dp:
self.xValue.setText("%.2f" % dp.x)
self.xValue.setText(ds % dp.x)
if self.mask in ['x','z']:
self.yValue.setText("0.00")
self.yValue.setText(ds % 0)
else:
if dp:
self.yValue.setText("%.2f" % dp.y)
self.yValue.setText(ds % dp.y)
if self.mask in ['x','y']:
self.zValue.setText("0.00")
self.zValue.setText(ds % 0)
else:
if dp:
self.zValue.setText("%.2f" % dp.z)
self.zValue.setText(ds % dp.z)
# set masks
if (mask == "x") or (self.mask == "x"):