Draft: Make featureName attribute translation-independent

The translation for the task panel title is done in the Ui method call
This commit is contained in:
marioalexis
2021-03-29 01:23:13 -03:00
parent 744846dd4f
commit d428b30635
37 changed files with 68 additions and 77 deletions

View File

@@ -155,12 +155,12 @@ class DraftWorkbench(FreeCADGui.Workbench):
else:
self.appendContextMenu("Draft", self.drawing_commands)
else:
if FreeCAD.activeDraftCommand.featureName in (translate("draft", "Line"),
translate("draft", "Wire"),
translate("draft", "Polyline"),
translate("draft", "BSpline"),
translate("draft", "BezCurve"),
translate("draft", "CubicBezCurve")):
if FreeCAD.activeDraftCommand.featureName in ("Line",
"Wire",
"Polyline",
"BSpline",
"BezCurve",
"CubicBezCurve"):
self.appendContextMenu("", self.line_commands)
else:
if FreeCADGui.Selection.getSelection():

View File

@@ -69,7 +69,7 @@ class Arc(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
super(Arc, self).Activated(name=translate("draft","Arc"))
super(Arc, self).Activated(name=self.featureName)
if self.ui:
self.step = 0
self.center = None
@@ -479,7 +479,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest):
"""GuiCommand for the Draft_Arc_3Points tool."""
def __init__(self):
super(Arc_3Points, self).__init__(name=translate("draft","Arc by 3 points"))
super(Arc_3Points, self).__init__(name="Arc by 3 points")
def GetResources(self):
"""Set icon, menu and tooltip."""
@@ -510,7 +510,8 @@ class Arc_3Points(gui_base.GuiCommandSimplest):
App.DraftWorkingPlane.setup()
Gui.Snapper.getPoint(callback=self.getPoint,
movecallback=self.drawArc)
movecallback=self.drawArc,
title=translate("draft","Arc by 3 points"))
def getPoint(self, point, info):
"""Get the point by clicking on the 3D view.

View File

@@ -68,7 +68,7 @@ class Array(gui_base_original.Modifier):
'MenuText': QT_TRANSLATE_NOOP("Draft_Array", "Array"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_Array", "Creates an array from a selected object.\nBy default, it is a 2x2 orthogonal array.\nOnce the array is created its type can be changed\nto polar or circular, and its properties can be modified.")}
def Activated(self, name=translate("draft","Array")):
def Activated(self, name="Array"):
"""Execute when the command is called."""
super(Array, self).Activated(name=name)
if not Gui.Selection.getSelection():
@@ -121,7 +121,7 @@ class LinkArray(Array):
def Activated(self):
"""Execute when the command is called."""
super(LinkArray, self).Activated(name=translate("draft","Link array"))
super(LinkArray, self).Activated(name="Link array")
Gui.addCommand('Draft_LinkArray', LinkArray())

View File

@@ -69,7 +69,7 @@ class BezCurve(gui_lines.Line):
Activate the specific bezier curve tracker.
"""
super(BezCurve, self).Activated(name=translate("draft", "Bezier curve"),
super(BezCurve, self).Activated(name="BezCurve",
icon="Draft_BezCurve")
if self.doc:
self.bezcurvetrack = trackers.bezcurveTracker()
@@ -247,7 +247,7 @@ class CubicBezCurve(gui_lines.Line):
Activate the specific BezCurve tracker.
"""
super(CubicBezCurve, self).Activated(name=translate("draft", "Cubic Bezier curve"),
super(CubicBezCurve, self).Activated(name="CubicBezCurve",
icon="Draft_CubicBezCurve")
if self.doc:
self.bezcurvetrack = trackers.bezcurveTracker()

View File

@@ -72,7 +72,7 @@ class Clone(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Clone, self).Activated(name=translate("draft","Clone"))
super(Clone, self).Activated(name="Clone")
if not Gui.Selection.getSelection():
if self.ui:
self.ui.selectUi()

View File

@@ -86,19 +86,18 @@ class Dimension(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "Dimension")
if self.cont:
self.finish()
elif self.selected_app_measure():
super(Dimension, self).Activated(name)
super(Dimension, self).Activated(name="Dimension")
self.dimtrack = trackers.dimTracker()
self.arctrack = trackers.arcTracker()
self.create_with_app_measure()
self.finish()
else:
super(Dimension, self).Activated(name)
super(Dimension, self).Activated(name="Dimension")
if self.ui:
self.ui.pointUi(title=name, icon="Draft_Dimension")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Dimension")
self.ui.continueCmd.show()
self.ui.selectButton.show()
self.altdown = False

View File

@@ -60,7 +60,7 @@ class Downgrade(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Downgrade, self).Activated(name=translate("draft","Downgrade"))
super(Downgrade, self).Activated(name="Downgrade")
if self.ui:
if not Gui.Selection.getSelection():
self.ui.selectUi()

View File

@@ -59,7 +59,7 @@ class Draft2Sketch(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Draft2Sketch, self).Activated(name=translate("draft","Convert Draft/Sketch"))
super(Draft2Sketch, self).Activated(name="Convert Draft/Sketch")
if not Gui.Selection.getSelection():
if self.ui:
self.ui.selectUi()

View File

@@ -73,7 +73,7 @@ class Drawing(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Drawing, self).Activated(name=translate("draft","Drawing"))
super(Drawing, self).Activated(name="Drawing")
_wrn(translate("draft","The Drawing Workbench is obsolete since 0.17, consider using the TechDraw Workbench instead."))
if not Gui.Selection.getSelection():
self.ghost = None

View File

@@ -61,11 +61,10 @@ class Ellipse(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "Ellipse")
super(Ellipse, self).Activated(name)
super(Ellipse, self).Activated(name="Ellipse")
if self.ui:
self.refpoint = None
self.ui.pointUi(title=name, icon="Draft_Ellipse")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Ellipse")
self.ui.extUi()
self.call = self.view.addEventCallback("SoEvent", self.action)
self.rect = trackers.rectangleTracker()

View File

@@ -63,7 +63,7 @@ class Facebinder(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
super(Facebinder, self).Activated(name=translate("draft","Facebinder"))
super(Facebinder, self).Activated(name="Facebinder")
if not Gui.Selection.getSelection():
if self.ui:

View File

@@ -64,7 +64,7 @@ class Fillet(gui_base_original.Creator):
'MenuText': QT_TRANSLATE_NOOP("Draft", "Fillet"),
'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates a fillet between two selected wires or edges.")}
def Activated(self, name=translate("Draft", "Fillet")):
def Activated(self, name="Fillet"):
"""Execute when the command is called."""
super(Fillet, self).Activated(name=name)
@@ -76,7 +76,7 @@ class Fillet(gui_base_original.Creator):
tooltip = translate("draft", "Radius of fillet")
# Call the task panel defined in DraftGui to enter a radius.
self.ui.taskUi(title=name, icon="Draft_Fillet")
self.ui.taskUi(title=translate("Draft", self.featureName), icon="Draft_Fillet")
self.ui.radiusUi()
self.ui.sourceCmd = self
self.ui.labelRadius.setText(label)

View File

@@ -68,7 +68,7 @@ class Join(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Join, self).Activated(name=translate("draft","Join"))
super(Join, self).Activated(name="Join")
if not self.ui:
return
if not Gui.Selection.getSelection():

View File

@@ -66,14 +66,13 @@ class Label(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
self.name = translate("draft", "Label")
super(Label, self).Activated(self.name, noplanesetup=True)
super(Label, self).Activated(name="Label", noplanesetup=True)
self.ghost = None
self.labeltype = utils.getParam("labeltype", "Custom")
self.sel = Gui.Selection.getSelectionEx()
if self.sel:
self.sel = self.sel[0]
self.ui.labelUi(self.name, callback=self.setmode)
self.ui.labelUi(title=translate("draft",self.featureName), callback=self.setmode)
self.ui.xValue.setFocus()
self.ui.xValue.selectAll()
self.ghost = trackers.lineTracker()

View File

@@ -64,7 +64,7 @@ class Line(gui_base_original.Creator):
'MenuText': QT_TRANSLATE_NOOP("Draft_Line", "Line"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_Line", "Creates a 2-point line. CTRL to snap, SHIFT to constrain.")}
def Activated(self, name=translate("draft", "Line"), icon="Draft_Line"):
def Activated(self, name="Line", icon="Draft_Line"):
"""Execute when the command is called."""
super(Line, self).Activated(name)
@@ -73,9 +73,9 @@ class Line(gui_base_original.Creator):
self.obj = None # stores the temp shape
self.oldWP = None # stores the WP if we modify it
if self.isWire:
self.ui.wireUi(title=name, icon=icon)
self.ui.wireUi(title=translate("draft", self.featureName), icon=icon)
else:
self.ui.lineUi(title=name, icon=icon)
self.ui.lineUi(title=translate("draft", self.featureName), icon=icon)
if sys.version_info.major < 3:
if isinstance(self.featureName, unicode):
self.featureName = self.featureName.encode("utf8")
@@ -359,7 +359,7 @@ class Wire(Line):
# If there was no selection or the selection was just one object
# then we proceed with the normal line creation functions,
# only this time we will be able to input more than two points
super(Wire, self).Activated(name=translate("draft", "Polyline"),
super(Wire, self).Activated(name="Polyline",
icon="Draft_Wire")

View File

@@ -65,8 +65,7 @@ class Mirror(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
self.name = translate("draft", "Mirror")
super(Mirror, self).Activated(name=self.name)
super(Mirror, self).Activated(name="Mirror")
self.ghost = None
if self.ui:
if not Gui.Selection.getSelection():
@@ -84,7 +83,7 @@ class Mirror(gui_base_original.Modifier):
self.view.removeEventCallback("SoEvent", self.call)
self.sel = Gui.Selection.getSelection()
self.ui.pointUi(title=self.name, icon="Draft_Mirror")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Mirror")
self.ui.modUi()
self.ui.xValue.setFocus()
self.ui.xValue.selectAll()

View File

@@ -65,8 +65,7 @@ class Move(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
self.name = translate("draft", "Move")
super(Move, self).Activated(self.name,
super(Move, self).Activated(name="Move",
is_subtool=isinstance(App.activeDraftCommand,
SubelementHighlight))
if not self.ui:
@@ -94,7 +93,7 @@ class Move(gui_base_original.Modifier):
spaces=True,
noarchchild=True)
self.selected_subelements = Gui.Selection.getSelectionEx()
self.ui.lineUi(self.name, icon="Draft_Move")
self.ui.lineUi(title=translate("draft", self.featureName), icon="Draft_Move")
self.ui.modUi()
if self.copymode:
self.ui.isCopy.setChecked(True)

View File

@@ -66,7 +66,7 @@ class Offset(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
self.running = False
super(Offset, self).Activated(name=translate("draft","Offset"))
super(Offset, self).Activated(name="Offset")
self.ghost = None
self.linetrack = None
self.arctrack = None

View File

@@ -73,7 +73,7 @@ class PathArray(gui_base_original.Modifier):
'MenuText': QT_TRANSLATE_NOOP("Draft_PathArray", "Path array"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_PathArray", "Creates copies of the selected object along a selected path.\nFirst select the object, and then select the path.\nThe path can be a polyline, B-spline, Bezier curve, or even edges from other objects.")}
def Activated(self, name=translate("draft","Path array")):
def Activated(self, name="Path array"):
"""Execute when the command is called."""
super(PathArray, self).Activated(name=name)
self.name = name
@@ -165,7 +165,7 @@ class PathLinkArray(PathArray):
def Activated(self):
"""Execute when the command is called."""
super(PathLinkArray, self).Activated(name=translate("draft","Path link array"))
super(PathLinkArray, self).Activated(name="Path link array")
Gui.addCommand('Draft_PathLinkArray', PathLinkArray())

View File

@@ -66,7 +66,7 @@ class PathTwistedArray(gui_base_original.Modifier):
'MenuText': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", "Path twisted array"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", "Creates copies of the selected object along a selected path, and twists the copies.\nFirst select the object, and then select the path.\nThe path can be a polyline, B-spline, Bezier curve, or even edges from other objects.")}
def Activated(self, name=translate("draft","Path twisted array")):
def Activated(self, name="Path twisted array"):
"""Execute when the command is called."""
super(PathTwistedArray, self).Activated(name=name)
self.name = name
@@ -124,7 +124,7 @@ class PathTwistedLinkArray(PathTwistedArray):
def Activated(self):
"""Execute when the command is called."""
super(PathTwistedLinkArray,
self).Activated(name=translate("draft","Path twisted link array"))
self).Activated(name="Path twisted link array")
Gui.addCommand('Draft_PathTwistedLinkArray', PathTwistedLinkArray())

View File

@@ -78,8 +78,7 @@ class PointArray(gui_base_original.Modifier):
def Activated(self, name="Point array"):
"""Execute when the command is called."""
self.name = name
super(PointArray, self).Activated(name=translate("draft","Point array"))
super(PointArray, self).Activated(name=name)
# This was deactivated because it doesn't work correctly;
# the selection needs to be made on two objects, but currently
# it only selects one.

View File

@@ -64,7 +64,7 @@ class Point(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
super(Point, self).Activated(name=translate("draft","Point"))
super(Point, self).Activated(name="Point")
self.view = gui_utils.get3DView()
self.stack = []
rot = self.view.getCameraNode().getField("orientation").getValue()
@@ -74,7 +74,7 @@ class Point(gui_base_original.Creator):
upv)
self.point = None
if self.ui:
self.ui.pointUi(icon="Draft_Point")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Point")
self.ui.continueCmd.show()
# adding 2 callback functions
self.callbackClick = self.view.addEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.click)

View File

@@ -59,15 +59,14 @@ class Polygon(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "Polygon")
super(Polygon, self).Activated(name)
super(Polygon, self).Activated(name="Polygon")
if self.ui:
self.step = 0
self.center = None
self.rad = None
self.tangents = []
self.tanpoints = []
self.ui.pointUi(title=name, icon="Draft_Polygon")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Polygon")
self.ui.extUi()
self.ui.numFaces.show()
self.ui.numFacesLabel.show()

View File

@@ -56,11 +56,10 @@ class Rectangle(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "Rectangle")
super(Rectangle, self).Activated(name)
super(Rectangle, self).Activated(name="Rectangle")
if self.ui:
self.refpoint = None
self.ui.pointUi(title=name, icon="Draft_Rectangle")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Rectangle")
self.ui.extUi()
if utils.getParam("UsePartPrimitives", False):
self.fillstate = self.ui.hasFill.isChecked()

View File

@@ -64,7 +64,7 @@ class Rotate(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Rotate, self).Activated(name=translate("draft","Rotate"))
super(Rotate, self).Activated(name="Rotate")
if not self.ui:
return
self.ghosts = []

View File

@@ -73,8 +73,7 @@ class Scale(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
self.name = translate("draft", "Scale")
super(Scale, self).Activated(name=self.name)
super(Scale, self).Activated(name="Scale")
if not self.ui:
return
self.ghosts = []
@@ -99,7 +98,7 @@ class Scale(gui_base_original.Modifier):
groups.get_group_contents(self.selected_objects)
self.selected_subelements = Gui.Selection.getSelectionEx()
self.refs = []
self.ui.pointUi(title=self.name, icon="Draft_Scale")
self.ui.pointUi(title=translate("draft",self.featureName), icon="Draft_Scale")
self.ui.modUi()
self.ui.xValue.setFocus()
self.ui.xValue.selectAll()

View File

@@ -61,7 +61,7 @@ class Shape2DView(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Shape2DView, self).Activated(name=translate("draft","Project 2D view"))
super(Shape2DView, self).Activated(name="Project 2D view")
if not Gui.Selection.getSelection():
if self.ui:
self.ui.selectUi()

View File

@@ -71,8 +71,7 @@ class ShapeString(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "ShapeString")
super(ShapeString, self).Activated(name)
super(ShapeString, self).Activated(name="ShapeString")
self.creator = gui_base_original.Creator
if self.ui:
self.ui.sourceCmd = self
@@ -91,7 +90,8 @@ class ShapeString(gui_base_original.Creator):
self.dialog = None
self.text = ''
self.ui.sourceCmd = self
self.ui.pointUi(title=name, icon="Draft_ShapeString")
self.ui.pointUi(title=translate("draft",self.featureName),
icon="Draft_ShapeString")
self.active = True
self.call = self.view.addEventCallback("SoEvent", self.action)
self.ssBase = None

View File

@@ -65,7 +65,7 @@ class BSpline(gui_lines.Line):
Activate the specific BSpline tracker.
"""
super(BSpline, self).Activated(name=translate("draft", "B-spline"), icon="Draft_BSpline")
super(BSpline, self).Activated(name="Bspline", icon="Draft_BSpline")
if self.doc:
self.bsplinetrack = trackers.bsplineTracker()

View File

@@ -58,7 +58,7 @@ class Split(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Split, self).Activated(name=translate("draft","Split"))
super(Split, self).Activated(name="Split")
if not self.ui:
return
_msg(translate("draft", "Click anywhere on a line to split it."))

View File

@@ -66,7 +66,7 @@ class Stretch(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Stretch, self).Activated(name=translate("draft","Stretch"))
super(Stretch, self).Activated(name="Stretch")
if self.ui:
if not Gui.Selection.getSelection():
self.ui.selectUi()
@@ -111,7 +111,7 @@ class Stretch(gui_base_original.Modifier):
if self.ui and self.sel:
self.step = 1
self.refpoint = None
self.ui.pointUi(title="Stretch", icon="Draft_Stretch")
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Stretch")
self.ui.extUi()
self.call = self.view.addEventCallback("SoEvent", self.action)
self.rectracker = trackers.rectangleTracker(dotted=True,

View File

@@ -52,7 +52,7 @@ class ApplyStyle(gui_base_original.Modifier):
Activate the specific BSpline tracker.
"""
super(ApplyStyle, self).Activated(name=translate("draft","Apply style"))
super(ApplyStyle, self).Activated(name="Apply style")
if self.ui:
self.sel = Gui.Selection.getSelection()
if len(self.sel) > 0:

View File

@@ -66,7 +66,7 @@ class SubelementHighlight(gui_base_original.Modifier):
if self.is_running:
return self.finish()
self.is_running = True
super(SubelementHighlight, self).Activated(name=translate("draft","Subelement highlight"))
super(SubelementHighlight, self).Activated(name="Subelement highlight")
self.get_selection()
def proceed(self):

View File

@@ -62,13 +62,12 @@ class Text(gui_base_original.Creator):
def Activated(self):
"""Execute when the command is called."""
name = translate("draft", "Text")
super(Text, self).Activated(name)
super(Text, self).Activated(name="Text")
if self.ui:
self.dialog = None
self.text = ''
self.ui.sourceCmd = self
self.ui.pointUi(name)
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Text")
self.call = self.view.addEventCallback("SoEvent", self.action)
self.active = True
self.ui.xValue.setFocus()

View File

@@ -78,7 +78,7 @@ class Trimex(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Trimex, self).Activated(name=translate("draft","Trimex"))
super(Trimex, self).Activated(name="Trimex")
self.edges = []
self.placement = None
self.ghost = []
@@ -105,7 +105,7 @@ class Trimex(gui_base_original.Modifier):
self.finish()
return
self.obj = sel[0]
self.ui.trimUi()
self.ui.trimUi(title=translate("draft",self.featureName))
self.linetrack = trackers.lineTracker()
import DraftGeomUtils

View File

@@ -60,7 +60,7 @@ class Upgrade(gui_base_original.Modifier):
def Activated(self):
"""Execute when the command is called."""
super(Upgrade, self).Activated(name=translate("draft","Upgrade"))
super(Upgrade, self).Activated(name="Upgrade")
if self.ui:
if not Gui.Selection.getSelection():
self.ui.selectUi()

View File

@@ -77,7 +77,7 @@ class WireToBSpline(gui_base_original.Modifier):
selection = Gui.Selection.getSelection()
if selection:
if utils.getType(selection[0]) in ['Wire', 'BSpline']:
super(WireToBSpline, self).Activated(name=translate("draft","Convert polyline/B-spline"))
super(WireToBSpline, self).Activated(name="Convert polyline/B-spline")
if self.doc:
self.obj = Gui.Selection.getSelection()
if self.obj: