Toolbit Translation Cleanup
This commit is contained in:
@@ -25,10 +25,10 @@ import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PySide
|
||||
import json
|
||||
import os
|
||||
import zipfile
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
@@ -44,12 +44,12 @@ PropertyGroupShape = "Shape"
|
||||
|
||||
_DebugFindTool = False
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule()
|
||||
|
||||
|
||||
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())
|
||||
|
||||
|
||||
def _findToolFile(name, containerFile, typ):
|
||||
@@ -142,31 +142,35 @@ class ToolBit(object):
|
||||
"App::PropertyFile",
|
||||
"BitShape",
|
||||
"Base",
|
||||
translate("PathToolBit", "Shape for bit shape"),
|
||||
QT_TRANSLATE_NOOP("App::Property", "Shape for bit shape"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"BitBody",
|
||||
"Base",
|
||||
translate("PathToolBit", "The parametrized body representing the tool bit"),
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "The parametrized body representing the tool bit"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyFile",
|
||||
"File",
|
||||
"Base",
|
||||
translate("PathToolBit", "The file of the tool"),
|
||||
QT_TRANSLATE_NOOP("App::Property", "The file of the tool"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyString",
|
||||
"ShapeName",
|
||||
"Base",
|
||||
translate("PathToolBit", "The name of the shape file"),
|
||||
QT_TRANSLATE_NOOP("App::Property", "The name of the shape file"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyStringList",
|
||||
"BitPropertyNames",
|
||||
"Base",
|
||||
translate("PathToolBit", "List of all properties inherited from the bit"),
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "List of all properties inherited from the bit"
|
||||
),
|
||||
)
|
||||
|
||||
if path:
|
||||
@@ -202,8 +206,8 @@ class ToolBit(object):
|
||||
"App::PropertyStringList",
|
||||
"BitPropertyNames",
|
||||
"Base",
|
||||
translate(
|
||||
"PathToolBit", "List of all properties inherited from the bit"
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "List of all properties inherited from the bit"
|
||||
),
|
||||
)
|
||||
propNames = []
|
||||
@@ -365,14 +369,8 @@ class ToolBit(object):
|
||||
self._setupProperty(obj, prop, attributes)
|
||||
propNames.append(prop)
|
||||
if not propNames:
|
||||
PathLog.error(
|
||||
translate(
|
||||
"PathToolBit",
|
||||
"Did not find a PropertyBag in {} - not a ToolBit shape?".format(
|
||||
docName
|
||||
),
|
||||
)
|
||||
)
|
||||
PathLog.error("Did not find a PropertyBag in {} - not a ToolBit shape?".format(
|
||||
docName))
|
||||
|
||||
# has to happen last because it could trigger op.execute evaluations
|
||||
obj.BitPropertyNames = propNames
|
||||
|
||||
@@ -20,12 +20,19 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts
|
||||
import PathScripts.PathLog as PathLog
|
||||
import os
|
||||
|
||||
from PySide import QtCore
|
||||
if False:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
|
||||
class CommandToolBitCreate:
|
||||
@@ -39,9 +46,9 @@ class CommandToolBitCreate:
|
||||
def GetResources(self):
|
||||
return {
|
||||
"Pixmap": "Path_ToolBit",
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP("PathToolBit", "Create Tool"),
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBit", "Creates a new ToolBit object"
|
||||
"MenuText": QT_TRANSLATE_NOOP("Path_ToolBitCreate", "Create Tool"),
|
||||
"ToolTip": QT_TRANSLATE_NOOP(
|
||||
"Path_ToolBitCreate", "Creates a new ToolBit object"
|
||||
),
|
||||
}
|
||||
|
||||
@@ -63,14 +70,14 @@ class CommandToolBitSave:
|
||||
|
||||
def GetResources(self):
|
||||
if self.saveAs:
|
||||
menuTxt = QtCore.QT_TRANSLATE_NOOP("PathToolBit", "Save Tool as...")
|
||||
menuTxt = QT_TRANSLATE_NOOP("Path_ToolBitSaveAs", "Save Tool as...")
|
||||
else:
|
||||
menuTxt = QtCore.QT_TRANSLATE_NOOP("PathToolBit", "Save Tool")
|
||||
menuTxt = QT_TRANSLATE_NOOP("Path_ToolBitSave", "Save Tool")
|
||||
return {
|
||||
"Pixmap": "Path_ToolBit",
|
||||
"MenuText": menuTxt,
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBit", "Save an existing ToolBit object to a file"
|
||||
"ToolTip": QT_TRANSLATE_NOOP(
|
||||
"Path_ToolBitSave", "Save an existing ToolBit object to a file"
|
||||
),
|
||||
}
|
||||
|
||||
@@ -130,9 +137,9 @@ class CommandToolBitLoad:
|
||||
def GetResources(self):
|
||||
return {
|
||||
"Pixmap": "Path_ToolBit",
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP("PathToolBit", "Load Tool"),
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBit", "Load an existing ToolBit object from a file"
|
||||
"MenuText": QT_TRANSLATE_NOOP("Path_ToolBitLoad", "Load Tool"),
|
||||
"ToolTip": QT_TRANSLATE_NOOP(
|
||||
"Path_ToolBitLoad", "Load an existing ToolBit object from a file"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -20,26 +20,22 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
from PySide import QtCore, QtGui
|
||||
import FreeCADGui
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathPropertyEditor as PathPropertyEditor
|
||||
import PathScripts.PathToolBit as PathToolBit
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import os
|
||||
import re
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule(PathLog.thisModule())
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
return 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 _Delegate(QtGui.QStyledItemDelegate):
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathIconViewProvider as PathIconViewProvider
|
||||
@@ -29,21 +31,19 @@ import PathScripts.PathToolBit as PathToolBit
|
||||
import PathScripts.PathToolBitEdit as PathToolBitEdit
|
||||
import os
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
__title__ = "Tool Bit UI"
|
||||
__author__ = "sliptonic (Brad Collette)"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
__doc__ = "Task panel editor for a ToolBit"
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
return 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())
|
||||
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule(PathLog.thisModule())
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
class ViewProvider(object):
|
||||
@@ -135,16 +135,14 @@ class TaskPanel:
|
||||
self.editor = PathToolBitEdit.ToolBitEditor(self.obj)
|
||||
self.form = self.editor.form
|
||||
self.deleteOnReject = deleteOnReject
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("PathToolBit", "Edit ToolBit"))
|
||||
FreeCAD.ActiveDocument.openTransaction("Edit ToolBit")
|
||||
|
||||
def reject(self):
|
||||
FreeCAD.ActiveDocument.abortTransaction()
|
||||
self.editor.reject()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
if self.deleteOnReject:
|
||||
FreeCAD.ActiveDocument.openTransaction(
|
||||
translate("PathToolBit", "Uncreate ToolBit")
|
||||
)
|
||||
FreeCAD.ActiveDocument.openTransaction("Uncreate ToolBit")
|
||||
self.editor.reject()
|
||||
FreeCAD.ActiveDocument.removeObject(self.obj.Name)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
@@ -176,9 +174,7 @@ class ToolBitGuiFactory(PathToolBit.ToolBitFactory):
|
||||
It is assumed the tool will be edited immediately so the internal bit body is still attached."""
|
||||
|
||||
PathLog.track(name, shapeFile, path)
|
||||
FreeCAD.ActiveDocument.openTransaction(
|
||||
translate("PathToolBit", "Create ToolBit")
|
||||
)
|
||||
FreeCAD.ActiveDocument.openTransaction("Create ToolBit")
|
||||
tool = PathToolBit.ToolBitFactory.Create(self, name, shapeFile, path)
|
||||
PathIconViewProvider.Attach(tool.ViewObject, name)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
@@ -20,10 +20,18 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PySide.QtCore as QtCore
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathLog as PathLog
|
||||
|
||||
if False:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
class CommandToolBitSelectorOpen:
|
||||
@@ -37,10 +45,8 @@ class CommandToolBitSelectorOpen:
|
||||
def GetResources(self):
|
||||
return {
|
||||
"Pixmap": "Path_ToolTable",
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP("PathToolBitLibrary", "ToolBit Dock"),
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBitLibrary", "Toggle the Toolbit Dock"
|
||||
),
|
||||
"MenuText": QT_TRANSLATE_NOOP("Path_ToolBitDock", "ToolBit Dock"),
|
||||
"ToolTip": QT_TRANSLATE_NOOP("Path_ToolBitDock", "Toggle the Toolbit Dock"),
|
||||
"Accel": "P, T",
|
||||
"CmdType": "ForEdit",
|
||||
}
|
||||
@@ -66,11 +72,11 @@ class CommandToolBitLibraryOpen:
|
||||
def GetResources(self):
|
||||
return {
|
||||
"Pixmap": "Path_ToolTable",
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBitLibrary", "ToolBit Library editor"
|
||||
"MenuText": QT_TRANSLATE_NOOP(
|
||||
"Path_ToolBitLibraryOpen", "ToolBit Library editor"
|
||||
),
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(
|
||||
"PathToolBitLibrary", "Open an editor to manage ToolBit libraries"
|
||||
"ToolTip": QT_TRANSLATE_NOOP(
|
||||
"Path_ToolBitLibraryOpen", "Open an editor to manage ToolBit libraries"
|
||||
),
|
||||
"CmdType": "ForEdit",
|
||||
}
|
||||
|
||||
@@ -42,15 +42,18 @@ import uuid as UUID
|
||||
from functools import partial
|
||||
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule(PathLog.thisModule())
|
||||
if False:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
|
||||
_UuidRole = PySide.QtCore.Qt.UserRole + 1
|
||||
_PathRole = PySide.QtCore.Qt.UserRole + 2
|
||||
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return PySide.QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
def checkWorkingDir():
|
||||
@@ -76,7 +79,9 @@ def checkWorkingDir():
|
||||
if ret == qm.No:
|
||||
return False
|
||||
|
||||
msg = translate("Path", "Choose a writable location for your toolbits", None)
|
||||
msg = translate(
|
||||
"Path_ToolBit", "Choose a writable location for your toolbits", None
|
||||
)
|
||||
while not dirOK():
|
||||
workingdir = PySide.QtGui.QFileDialog.getExistingDirectory(
|
||||
None, msg, PathPreferences.filePath()
|
||||
@@ -656,13 +661,11 @@ class ToolBitLibrary(object):
|
||||
print("all done")
|
||||
|
||||
def libraryNew(self):
|
||||
TooltableTypeJSON = translate(
|
||||
"PathToolLibraryManager", "Tooltable JSON (*.fctl)"
|
||||
)
|
||||
TooltableTypeJSON = translate("Path_ToolBit", "Tooltable JSON (*.fctl)")
|
||||
|
||||
filename = PySide.QtGui.QFileDialog.getSaveFileName(
|
||||
self.form,
|
||||
translate("TooltableEditor", "Save toolbit library", None),
|
||||
translate("Path_ToolBit", "Save toolbit library", None),
|
||||
PathPreferences.lastPathToolLibrary(),
|
||||
"{}".format(TooltableTypeJSON),
|
||||
)
|
||||
@@ -786,16 +789,12 @@ class ToolBitLibrary(object):
|
||||
|
||||
def librarySaveAs(self, path):
|
||||
|
||||
TooltableTypeJSON = translate(
|
||||
"PathToolLibraryManager", "Tooltable JSON (*.fctl)"
|
||||
)
|
||||
TooltableTypeLinuxCNC = translate(
|
||||
"PathToolLibraryManager", "LinuxCNC tooltable (*.tbl)"
|
||||
)
|
||||
TooltableTypeJSON = translate("Path_ToolBit", "Tooltable JSON (*.fctl)")
|
||||
TooltableTypeLinuxCNC = translate("Path_ToolBit", "LinuxCNC tooltable (*.tbl)")
|
||||
|
||||
filename = PySide.QtGui.QFileDialog.getSaveFileName(
|
||||
self.form,
|
||||
translate("TooltableEditor", "Save toolbit library", None),
|
||||
translate("Path_ToolBit", "Save toolbit library", None),
|
||||
PathPreferences.lastPathToolLibrary(),
|
||||
"{};;{}".format(TooltableTypeJSON, TooltableTypeLinuxCNC),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user