Merge pull request #1225 from 2xB/fix-mergeerror-1175

ParameterTree: Fix custom context menu
This commit is contained in:
Ogi Moore 2020-06-06 11:38:48 -07:00 committed by GitHub
commit 1c67d3ea2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,16 +104,18 @@ class ParameterItem(QtGui.QTreeWidgetItem):
pass
def contextMenuEvent(self, ev):
if not self.param.opts.get('removable', False) and not self.param.opts.get('renamable', False)\
and "context" not in self.param.opts:
opts = self.param.opts
if not opts.get('removable', False) and not opts.get('renamable', False)\
and "context" not in opts:
return
## Generate context menu for renaming/removing parameter
self.contextMenu = QtGui.QMenu() # Put in global name space to prevent garbage collection
self.contextMenu.addSeparator()
if self.param.opts.get('renamable', False):
if opts.get('renamable', False):
self.contextMenu.addAction('Rename').triggered.connect(self.editName)
if self.param.opts.get('removable', False):
if opts.get('removable', False):
self.contextMenu.addAction("Remove").triggered.connect(self.requestRemove)
# context menu