Skip to content

Commit

Permalink
Added command with menu item to create a property container.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jan 27, 2021
1 parent e9093e1 commit cc12ce4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Mod/Path/InitGui.py
Expand Up @@ -154,6 +154,10 @@ def Initialize(self):
if extracmdlist:
self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], extracmdlist)

self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], ["Separator"])
self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path"), QtCore.QT_TRANSLATE_NOOP("Path", "Tools")],
["Path_PropertyContainer"])

self.dressupcmds = dressupcmdlist

curveAccuracy = PathPreferences.defaultLibAreaCurveAccuracy()
Expand Down
28 changes: 25 additions & 3 deletions src/Mod/Path/PathScripts/PathPropertyContainerGui.py
Expand Up @@ -256,12 +256,14 @@ def propertyAdd(self):
grpe = dialog.propertyGroup()
info = dialog.propertyInfo()
self.obj.Proxy.addCustomProperty(typ, name, grpe, info)
index = 0
for i in range(self.model.rowCount()):
index = i
if self.model.item(i, self.ColumnName).data(QtCore.Qt.EditRole) > dialog.propertyName():
self.model.insertRows(i, 1)
self._setupProperty(i, name)
self.form.table.selectionModel().setCurrentIndex(self.model.index(i, 0), QtCore.QItemSelectionModel.Rows)
break
self.model.insertRows(index, 1)
self._setupProperty(index, name)
self.form.table.selectionModel().setCurrentIndex(self.model.index(index, 0), QtCore.QItemSelectionModel.Rows)
#self.model.blockSignals(False)

def propertyRemove(self):
Expand All @@ -288,3 +290,23 @@ def Create(name = 'PropertyContainer'):

PathIconViewProvider.RegisterViewProvider('PropertyContainer', ViewProvider)

class PropertyContainerCreateCommand(object):
'''Command to create a property container object'''

def __init__(self):
pass

def GetResources(self):
return {'MenuText': translate('PathPropertyContainer', 'Property Container'),
'ToolTip': translate('PathPropertyContainer', 'Creates an object which can be used to store reference properties.')}

def IsActive(self):
return not FreeCAD.ActiveDocument is None

def Activated(self):
Create()

if FreeCAD.GuiUp:
FreeCADGui.addCommand('Path_PropertyContainer', PropertyContainerCreateCommand())

FreeCAD.Console.PrintLog("Loading PathPropertyContainerGui ... done\n")

0 comments on commit cc12ce4

Please sign in to comment.