From 05d8253ee22bf7b2626f15be488d27665b16ad68 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 4 Jan 2022 14:45:36 -0600 Subject: [PATCH] Translation cleanup. Setupsheet related files. Simple copy, simulator --- src/Mod/Path/PathScripts/PathSetupSheet.py | 62 +++++++++---------- src/Mod/Path/PathScripts/PathSetupSheetGui.py | 12 +--- .../PathSetupSheetOpPrototypeGui.py | 4 -- src/Mod/Path/PathScripts/PathSimpleCopy.py | 15 ++--- src/Mod/Path/PathScripts/PathSimulatorGui.py | 9 ++- 5 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSetupSheet.py b/src/Mod/Path/PathScripts/PathSetupSheet.py index d2681bd742..e5d84ddf7d 100644 --- a/src/Mod/Path/PathScripts/PathSetupSheet.py +++ b/src/Mod/Path/PathScripts/PathSetupSheet.py @@ -25,21 +25,21 @@ import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog import PathScripts.PathSetupSheetOpPrototype as PathSetupSheetOpPrototype import PathScripts.PathUtil as PathUtil -import PySide +from PySide.QtCore import QT_TRANSLATE_NOOP __title__ = "Setup Sheet for a Job." __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "A container for all default values and job specific configuration values." -_RegisteredOps = {} - -PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) -# PathLog.trackModule(PathLog.thisModule()) +_RegisteredOps: dict = {} -def translate(context, text, disambig=None): - return PySide.QtCore.QCoreApplication.translate(context, text, disambig) +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) class Template: @@ -114,34 +114,36 @@ class SetupSheet: "App::PropertySpeed", "VertRapid", "ToolController", - translate("PathSetupSheet", "Default speed for horizontal rapid moves."), + QT_TRANSLATE_NOOP( + "App::Property", "Default speed for horizontal rapid moves." + ), ) obj.addProperty( "App::PropertySpeed", "HorizRapid", "ToolController", - translate("PathSetupSheet", "Default speed for vertical rapid moves."), + QT_TRANSLATE_NOOP( + "App::Property", "Default speed for vertical rapid moves." + ), ) - obj.addProperty( "App::PropertyStringList", "CoolantModes", "CoolantMode", - translate("PathSetupSheet", "Coolant Modes"), + QT_TRANSLATE_NOOP("App::Property", "Coolant Modes"), ) obj.addProperty( "App::PropertyEnumeration", "CoolantMode", "CoolantMode", - translate("PathSetupSheet", "Default coolant mode."), + QT_TRANSLATE_NOOP("App::Property", "Default coolant mode."), ) - obj.addProperty( "App::PropertyLength", "SafeHeightOffset", "OperationHeights", - translate( - "PathSetupSheet", + QT_TRANSLATE_NOOP( + "App::Property", "The usage of this field depends on SafeHeightExpression - by default its value is added to StartDepth and used for SafeHeight of an operation.", ), ) @@ -149,16 +151,16 @@ class SetupSheet: "App::PropertyString", "SafeHeightExpression", "OperationHeights", - translate( - "PathSetupSheet", "Expression set for the SafeHeight of new operations." + QT_TRANSLATE_NOOP( + "App::Property", "Expression set for the SafeHeight of new operations." ), ) obj.addProperty( "App::PropertyLength", "ClearanceHeightOffset", "OperationHeights", - translate( - "PathSetupSheet", + QT_TRANSLATE_NOOP( + "App::Property", "The usage of this field depends on ClearanceHeightExpression - by default is value is added to StartDepth and used for ClearanceHeight of an operation.", ), ) @@ -166,34 +168,33 @@ class SetupSheet: "App::PropertyString", "ClearanceHeightExpression", "OperationHeights", - translate( - "PathSetupSheet", + QT_TRANSLATE_NOOP( + "App::Property", "Expression set for the ClearanceHeight of new operations.", ), ) - obj.addProperty( "App::PropertyString", "StartDepthExpression", "OperationDepths", - translate( - "PathSetupSheet", "Expression used for StartDepth of new operations." + QT_TRANSLATE_NOOP( + "App::Property", "Expression used for StartDepth of new operations." ), ) obj.addProperty( "App::PropertyString", "FinalDepthExpression", "OperationDepths", - translate( - "PathSetupSheet", "Expression used for FinalDepth of new operations." + QT_TRANSLATE_NOOP( + "App::Property", "Expression used for FinalDepth of new operations." ), ) obj.addProperty( "App::PropertyString", "StepDownExpression", "OperationDepths", - translate( - "PathSetupSheet", "Expression used for StepDown of new operations." + QT_TRANSLATE_NOOP( + "App::Property", "Expression used for StepDown of new operations." ), ) @@ -403,7 +404,6 @@ class SetupSheet: setattr(obj, prop, getattr(self.obj, propName)) except Exception: PathLog.info("SetupSheet has no support for {}".format(opName)) - # traceback.print_exc() def onDocumentRestored(self, obj): @@ -412,7 +412,7 @@ class SetupSheet: "App::PropertyStringList", "CoolantModes", "CoolantMode", - translate("PathSetupSheet", "Coolant Modes"), + QT_TRANSLATE_NOOP("App::Property", "Coolant Modes"), ) obj.CoolantModes = self.DefaultCoolantModes @@ -421,7 +421,7 @@ class SetupSheet: "App::PropertyEnumeration", "CoolantMode", "CoolantMode", - translate("PathSetupSheet", "Default coolant mode."), + QT_TRANSLATE_NOOP("App::Property", "Default coolant mode."), ) obj.CoolantMode = self.DefaultCoolantModes diff --git a/src/Mod/Path/PathScripts/PathSetupSheetGui.py b/src/Mod/Path/PathScripts/PathSetupSheetGui.py index 540fd3612d..4747219bd2 100644 --- a/src/Mod/Path/PathScripts/PathSetupSheetGui.py +++ b/src/Mod/Path/PathScripts/PathSetupSheetGui.py @@ -38,14 +38,8 @@ __url__ = "https://www.freecadweb.org" __doc__ = "Task panel editor for a SetupSheet" -# Qt translation handling -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) - - LOGLEVEL = False - if LOGLEVEL: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) @@ -388,9 +382,7 @@ class TaskPanel: self.globalEditor = GlobalEditor(self.obj, self.globalForm) self.opsEditor = OpsDefaultEditor(self.obj, None) self.form = [op.form for op in self.opsEditor.ops] + [self.globalForm] - FreeCAD.ActiveDocument.openTransaction( - translate("Path_SetupSheet", "Edit SetupSheet") - ) + FreeCAD.ActiveDocument.openTransaction("Edit SetupSheet") def reject(self): self.globalEditor.reject() @@ -432,7 +424,7 @@ class TaskPanel: def Create(name="SetupSheet"): """Create(name='SetupSheet') ... creates a new setup sheet""" - FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Create Job")) + FreeCAD.ActiveDocument.openTransaction("Create Job") ssheet = PathSetupSheet.Create(name) PathIconViewProvider.Attach(ssheet, name) return ssheet diff --git a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py index 305f290507..aa5205961d 100644 --- a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py +++ b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py @@ -31,10 +31,6 @@ __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Task panel editor for a SetupSheet" -# Qt translation handling -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) - LOGLEVEL = False diff --git a/src/Mod/Path/PathScripts/PathSimpleCopy.py b/src/Mod/Path/PathScripts/PathSimpleCopy.py index 33daaa6904..135edc4fe8 100644 --- a/src/Mod/Path/PathScripts/PathSimpleCopy.py +++ b/src/Mod/Path/PathScripts/PathSimpleCopy.py @@ -23,22 +23,19 @@ import FreeCAD import FreeCADGui import PathScripts -from PySide import QtCore +from PySide.QtCore import QT_TRANSLATE_NOOP __doc__ = """Path SimpleCopy command""" - -# Qt translation handling -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) +translate = FreeCAD.Qt.translate class CommandPathSimpleCopy: def GetResources(self): return { "Pixmap": "Path_SimpleCopy", - "MenuText": QtCore.QT_TRANSLATE_NOOP("Path_SimpleCopy", "Simple Copy"), - "ToolTip": QtCore.QT_TRANSLATE_NOOP( + "MenuText": QT_TRANSLATE_NOOP("Path_SimpleCopy", "Simple Copy"), + "ToolTip": QT_TRANSLATE_NOOP( "Path_SimpleCopy", "Creates a non-parametric copy of another path" ), } @@ -68,9 +65,7 @@ class CommandPathSimpleCopy: ) return - FreeCAD.ActiveDocument.openTransaction( - translate("Path_SimpleCopy", "Simple Copy") - ) + FreeCAD.ActiveDocument.openTransaction("Simple Copy") FreeCADGui.doCommand( "srcpath = FreeCADGui.Selection.getSelectionEx()[0].Object.Path\n" ) diff --git a/src/Mod/Path/PathScripts/PathSimulatorGui.py b/src/Mod/Path/PathScripts/PathSimulatorGui.py index 118e2a9e87..28b478c627 100644 --- a/src/Mod/Path/PathScripts/PathSimulatorGui.py +++ b/src/Mod/Path/PathScripts/PathSimulatorGui.py @@ -31,6 +31,7 @@ import PathScripts.PathJob as PathJob import PathSimulator import math import os +from PySide.QtCore import QT_TRANSLATE_NOOP from FreeCAD import Vector, Base @@ -310,7 +311,9 @@ class PathSimulation: self.stock = newStock.removeSplitter() except Exception: if self.debug: - print("invalid cut at cmd #{}".format(self.icmd)) + FreeCAD.Console.PrintError( + "invalid cut at cmd #{}".format(self.icmd) + ) if not self.disableAnim: self.cutTool.Placement = FreeCAD.Placement(self.curpos, self.stdrot) self.icmd += 1 @@ -619,9 +622,9 @@ class CommandPathSimulate: def GetResources(self): return { "Pixmap": "Path_Simulator", - "MenuText": QtCore.QT_TRANSLATE_NOOP("Path_Simulator", "CAM Simulator"), + "MenuText": QT_TRANSLATE_NOOP("Path_Simulator", "CAM Simulator"), "Accel": "P, M", - "ToolTip": QtCore.QT_TRANSLATE_NOOP( + "ToolTip": QT_TRANSLATE_NOOP( "Path_Simulator", "Simulate Path G-Code on stock" ), }