diff --git a/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui b/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui
index 28f62a039d..e50a671cca 100644
--- a/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui
+++ b/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui
@@ -6,8 +6,8 @@
0
0
- 474
- 300
+ 484
+ 362
@@ -77,14 +77,14 @@
- -
+
-
ToolTip
- -
+
-
<html><head/><body><p>ToolTip to be displayed when user hovers mouse over property.</p></body></html>
@@ -94,7 +94,7 @@
- -
+
-
@@ -132,12 +132,33 @@
+ -
+
+
+ false
+
+
+ Values
+
+
+
+ -
+
+
+ false
+
+
+ <html><head/><body><p>Comma separated list of enumeration values.</p></body></html>
+
+
+
propertyName
propertyGroup
propertyType
+ enumValues
propertyInfo
createAnother
diff --git a/src/Mod/Path/PathScripts/PathPropertyBag.py b/src/Mod/Path/PathScripts/PathPropertyBag.py
index 01455fa5be..a9cc8d4c00 100644
--- a/src/Mod/Path/PathScripts/PathPropertyBag.py
+++ b/src/Mod/Path/PathScripts/PathPropertyBag.py
@@ -36,7 +36,7 @@ SupportedPropertyType = {
'Angle' : 'App::PropertyAngle',
'Bool' : 'App::PropertyBool',
'Distance' : 'App::PropertyDistance',
- # 'Enumeration' : 'App::PropertyEnumeration',
+ 'Enumeration' : 'App::PropertyEnumeration',
'File' : 'App::PropertyFile',
'Float' : 'App::PropertyFloat',
'Integer' : 'App::PropertyInteger',
diff --git a/src/Mod/Path/PathScripts/PathPropertyBagGui.py b/src/Mod/Path/PathScripts/PathPropertyBagGui.py
index bebdfcfca6..948f41d14f 100644
--- a/src/Mod/Path/PathScripts/PathPropertyBagGui.py
+++ b/src/Mod/Path/PathScripts/PathPropertyBagGui.py
@@ -148,12 +148,26 @@ class PropertyCreate(object):
self.form.propertyGroup.currentTextChanged.connect(self.updateUI)
self.form.propertyGroup.currentIndexChanged.connect(self.updateUI)
self.form.propertyName.textChanged.connect(self.updateUI)
+ self.form.propertyType.currentIndexChanged.connect(self.updateUI)
+ self.form.enumValues.textChanged.connect(self.updateUI)
self.updateUI()
def updateUI(self):
+ typeSet = True
+ if self.propertyIsEnumeration():
+ self.form.enumLabel.setEnabled(True)
+ self.form.enumValues.setEnabled(True)
+ typeSet = self.form.enumValues.text().strip() != ''
+ else:
+ self.form.enumLabel.setEnabled(False)
+ self.form.enumValues.setEnabled(False)
+ if self.form.enumValues.text().strip():
+ self.form.enumValues.setText('')
+
ok = self.form.buttonBox.button(QtGui.QDialogButtonBox.Ok)
- if self.form.propertyName.text() and self.form.propertyGroup.currentText():
+
+ if typeSet and self.propertyName() and self.propertyGroup():
ok.setEnabled(True)
else:
ok.setEnabled(False)
@@ -168,10 +182,15 @@ class PropertyCreate(object):
return self.form.propertyInfo.toPlainText().strip()
def createAnother(self):
return self.form.createAnother.isChecked()
+ def propertyEnumerations(self):
+ return [s.strip() for s in self.form.enumValues.text().strip().split(',')]
+ def propertyIsEnumeration(self):
+ return self.propertyType() == 'App::PropertyEnumeration'
def exec_(self):
self.form.propertyName.setText('')
self.form.propertyInfo.setText('')
+ self.form.enumValues.setText('')
#self.form.propertyName.setFocus()
return self.form.exec_()
@@ -261,6 +280,8 @@ class TaskPanel(object):
grp = dialog.propertyGroup()
info = dialog.propertyInfo()
self.obj.Proxy.addCustomProperty(typ, name, grp, info)
+ if dialog.propertyIsEnumeration():
+ setattr(self.obj, name, dialog.propertyEnumerations())
index = 0
for i in range(self.model.rowCount()):
index = i
diff --git a/src/Mod/Path/PathScripts/PathPropertyEditor.py b/src/Mod/Path/PathScripts/PathPropertyEditor.py
index d45add0658..f376e351fd 100644
--- a/src/Mod/Path/PathScripts/PathPropertyEditor.py
+++ b/src/Mod/Path/PathScripts/PathPropertyEditor.py
@@ -78,12 +78,12 @@ class _PropertyEditorBool(_PropertyEditor):
def setEditorData(self, widget):
widget.clear()
- widget.addItems(['false', 'true'])
+ widget.addItems([str(False), str(True)])
index = 1 if self.propertyValue() else 0
widget.setCurrentIndex(index)
def setModelData(self, widget):
- self.setProperty(widget.currentText() == 'true')
+ self.setProperty(widget.currentText() == str(True))
class _PropertyEditorString(_PropertyEditor):
'''Editor for string values - uses a line edit.'''
@@ -190,11 +190,24 @@ class _PropertyEditorFile(_PropertyEditor):
def setModelData(self, widget):
self.setProperty(widget.text())
+class _PropertyEditorEnumeration(_PropertyEditor):
+
+ def widget(self, parent):
+ return QtGui.QComboBox(parent)
+
+ def setEditorData(self, widget):
+ widget.clear()
+ widget.addItems(self.obj.getEnumerationsOfProperty(self.prop))
+ widget.setCurrentText(self.propertyValue())
+
+ def setModelData(self, widget):
+ self.setProperty(widget.currentText())
+
_EditorFactory = {
'App::PropertyAngle' : _PropertyEditorAngle,
'App::PropertyBool' : _PropertyEditorBool,
'App::PropertyDistance' : _PropertyEditorLength,
- #'App::PropertyEnumeration' : _PropertyEditorEnum,
+ 'App::PropertyEnumeration' : _PropertyEditorEnumeration,
#'App::PropertyFile' : _PropertyEditorFile,
'App::PropertyFloat' : _PropertyEditorFloat,
'App::PropertyInteger' : _PropertyEditorInteger,