Draft: Allow to set a custom feet separator for dimensions (#10481)

This commit is contained in:
Yorik van Havre
2023-09-11 14:05:26 +02:00
committed by GitHub
parent ebffe55030
commit 36353ffb7c
2 changed files with 63 additions and 9 deletions

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>605</height>
<width>555</width>
<height>797</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
@@ -45,9 +54,9 @@
</property>
<property name="toolTip">
<string>This is the default font name for all Draft texts and dimensions.
It can be a font name such as "Arial", a default style such as "sans", "serif"
or "mono", or a family such as "Arial,Helvetica,sans" or a name with a style
such as "Arial:Bold"</string>
It can be a font name such as &quot;Arial&quot;, a default style such as &quot;sans&quot;, &quot;serif&quot;
or &quot;mono&quot;, or a family such as &quot;Arial,Helvetica,sans&quot; or a name with a style
such as &quot;Arial:Bold&quot;</string>
</property>
<property name="text">
<string/>
@@ -504,6 +513,43 @@ such as "Arial:Bold"</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Feet separator</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefLineEdit" name="lineEdit_2">
<property name="toolTip">
<string>Optional string to appear between the feet and inches values in dimensions</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>FeetSeparator</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@@ -572,9 +572,17 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase):
# Special representation if we use 'Building US' scheme
u_params = App.ParamGet("User parameter:BaseApp/Preferences/Units")
if u_params.GetInt("UserSchema", 0) == 5:
s = App.Units.Quantity(length, App.Units.Length).UserString
self.string = s.replace("' ", "'- ") # feet
self.string = s.replace("+", " ")
self.string = App.Units.Quantity(length, App.Units.Length).UserString
if self.string.count('"') > 1:
# multiple inch tokens
self.string = self.string.replace('"',"",self.string.count('"')-1)
d_params = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
sep = d_params.GetString("FeetSeparator"," ")
# use a custom separator
self.string = self.string.replace("' ", "'" + sep)
self.string = self.string.replace("+", " ")
self.string = self.string.replace(" ", " ")
self.string = self.string.replace(" ", " ")
elif hasattr(vobj, "Decimals"):
self.string = units.display_external(length,
vobj.Decimals,