From 7c3300dbf2f848a97f1a9c8317a17de0ead05b29 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sat, 7 Nov 2020 12:00:58 -0600 Subject: [PATCH] Fix duplicate docs being created fix edit changes not being retained fix edit removing new toolbit from diretory --- src/Mod/Path/Gui/Resources/panels/ToolBitEditor.ui | 6 +++--- src/Mod/Path/PathScripts/PathToolBit.py | 10 ++++------ src/Mod/Path/PathScripts/PathToolBitEdit.py | 6 +++--- src/Mod/Path/PathScripts/PathToolBitGui.py | 1 + src/Mod/Path/PathScripts/PathToolBitLibraryGui.py | 3 +++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/ToolBitEditor.ui b/src/Mod/Path/Gui/Resources/panels/ToolBitEditor.ui index bceff42fcd..1342da5649 100644 --- a/src/Mod/Path/Gui/Resources/panels/ToolBitEditor.ui +++ b/src/Mod/Path/Gui/Resources/panels/ToolBitEditor.ui @@ -1,7 +1,7 @@ - Form - + ToolBitAttributes + 0 @@ -11,7 +11,7 @@ - Form + Tool Bit Attributes diff --git a/src/Mod/Path/PathScripts/PathToolBit.py b/src/Mod/Path/PathScripts/PathToolBit.py index e2f2c45e6d..9c76b141f6 100644 --- a/src/Mod/Path/PathScripts/PathToolBit.py +++ b/src/Mod/Path/PathScripts/PathToolBit.py @@ -42,8 +42,8 @@ __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Class to deal with and represent a tool bit." -PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) -PathLog.trackModule() +# PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) +# PathLog.trackModule() def translate(context, text, disambig=None): @@ -254,7 +254,6 @@ class ToolBit(object): return (doc, docOpened) def _removeBitBody(self, obj): - print('in _removebitbody') if obj.BitBody: obj.BitBody.removeObjectsFromDocument() obj.Document.removeObject(obj.BitBody.Name) @@ -327,7 +326,7 @@ class ToolBit(object): return None def saveToFile(self, obj, path, setFile=True): - print('were saving now') + PathLog.track(path) try: with open(path, 'w') as fp: json.dump(self.templateAttrs(obj), fp, indent=' ') @@ -363,7 +362,6 @@ class ToolBit(object): def Declaration(path): - print(path) with open(path, 'r') as fp: return json.load(fp) @@ -396,6 +394,7 @@ class AttributePrototype(PathSetupSheetOpPrototype.OpPrototype): class ToolBitFactory(object): def CreateFromAttrs(self, attrs, name='ToolBit'): + PathLog.debug(attrs) obj = Factory.Create(name, attrs['shape']) obj.Label = attrs['name'] params = attrs['parameter'] @@ -407,7 +406,6 @@ class ToolBitFactory(object): proto = AttributePrototype() uservals = {} for pname in params: - # print(f"pname: {pname}") try: prop = proto.getProperty(pname) # val = prop.valueFromString(params[pname]) diff --git a/src/Mod/Path/PathScripts/PathToolBitEdit.py b/src/Mod/Path/PathScripts/PathToolBitEdit.py index 8ab67e77b0..1f3f4c4c4d 100644 --- a/src/Mod/Path/PathScripts/PathToolBitEdit.py +++ b/src/Mod/Path/PathScripts/PathToolBitEdit.py @@ -95,7 +95,7 @@ class ToolBitEditor(object): self.model.setHorizontalHeaderLabels(['Set', 'Property', 'Value']) for i, name in enumerate(self.props): - print("propname: %s " % name) + PathLog.debug("propname: %s " % name) prop = self.proto.getProperty(name) isset = hasattr(tool, name) @@ -133,7 +133,7 @@ class ToolBitEditor(object): if hasattr(tool, "UserAttributes"): for key, value in tool.UserAttributes.items(): - print(key, value) + PathLog.debug(key, value) c1 = QtGui.QStandardItem() c1.setCheckable(False) c1.setEditable(False) @@ -169,7 +169,7 @@ class ToolBitEditor(object): # get the attributes for i, name in enumerate(self.props): - print('in accept: {}'.format(name)) + PathLog.debug('in accept: {}'.format(name)) prop = self.proto.getProperty(name) if self.model.item(i, 0) is not None: enabled = self.model.item(i, 0).checkState() == QtCore.Qt.Checked diff --git a/src/Mod/Path/PathScripts/PathToolBitGui.py b/src/Mod/Path/PathScripts/PathToolBitGui.py index cac76acce2..adeab5ba89 100644 --- a/src/Mod/Path/PathScripts/PathToolBitGui.py +++ b/src/Mod/Path/PathScripts/PathToolBitGui.py @@ -150,6 +150,7 @@ class TaskPanel: FreeCAD.ActiveDocument.recompute() def updateUI(self): + PathLog.track() self.editor.updateUI() def updateModel(self): diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py index 3606228d96..3f527e298b 100644 --- a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py +++ b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py @@ -343,6 +343,7 @@ class ToolBitSelector(object): return else: doc.setVisible(True) + return mw = FreeCADGui.getMainWindow() mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.form, @@ -454,7 +455,9 @@ class ToolBitLibrary(object): self.lockoff() def accept(self): + self.editor.accept() self.temptool.Proxy.saveToFile(self.temptool, self.temptool.File) + self.librarySave() self.loadData() self.cleanupDocument()