Commit ce6e3b88 authored by Maxime Perrotin's avatar Maxime Perrotin

Add second layer of filtering for user widgets

parent ff4ea20b
......@@ -40,7 +40,13 @@ class TM(QtGui.QDockWidget, QObject):
@staticmethod
def applicable():
'''' Return true is the widget is active '''
''' Return true is the widget is active '''
return True
@staticmethod
def editorIsApplicable(editor):
''' Return true if this particular editor is compatible with this
widget'''
return True
@Slot()
......@@ -70,3 +76,9 @@ class TC(QtGui.QDockWidget, QObject):
def applicable():
'''' Return true is the widget is active '''
return True
@staticmethod
def editorIsApplicable(editor):
''' Return true if this particular editor is compatible with this
widget'''
return True
......@@ -455,11 +455,18 @@ def gui():
elif button.objectName() == 'meterButton':
button.clicked.connect(editor.meter)
elif button.objectName() == 'customCombo':
if not customTM:
# check if the custom widget is applicable to THIS editor
# (not only in general)
applicableMenuEntries = list()
for each in customTM:
if each.editorIsApplicable(editor):
applicableMenuEntries.append(each)
if not applicableMenuEntries:
button.hide()
continue
myMenu = QMenu()
for each in customTM:
for each in applicableMenuEntries:
action = QAction(each.name, myMenu)
myMenu.addAction(action)
action.triggered.connect(partial(editor.custom,
......@@ -491,11 +498,18 @@ def gui():
'editor': editor,
'send_btn': button})
elif button.objectName() == 'customCombo':
if not customTC:
# check if the custom widget is applicable to THIS editor
# (not only in general)
applicableMenuEntries = list()
for each in customTC:
if each.editorIsApplicable(editor):
applicableMenuEntries.append(each)
if not applicableMenuEntries:
button.hide()
continue
myMenu = QMenu()
for each in customTC:
for each in applicableMenuEntries:
action = QAction(each.name, myMenu)
myMenu.addAction(action)
action.triggered.connect(partial(editor.custom,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment