Fix duplicate docs being created
fix edit changes not being retained fix edit removing new toolbit from diretory
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<class>ToolBitAttributes</class>
|
||||
<widget class="QWidget" name="ToolBitAttributes">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>Tool Bit Attributes</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -150,6 +150,7 @@ class TaskPanel:
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def updateUI(self):
|
||||
PathLog.track()
|
||||
self.editor.updateUI()
|
||||
|
||||
def updateModel(self):
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user