Skip to content

Commit 2c12085

Browse files
committed
clean up
1 parent 497b4a2 commit 2c12085

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

NodeGraphQt/widgets/actions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ def get_action(self, name):
3939
return action
4040

4141

42-
class NodeAction(QtWidgets.QAction):
42+
class NodeAction(GraphAction):
4343

4444
executed = QtCore.Signal(object, object)
4545

4646
def __init__(self, *args, **kwargs):
4747
super(NodeAction, self).__init__(*args, **kwargs)
48-
self.graph = None
4948
self.node_id = None
50-
self.triggered.connect(self._on_triggered)
5149

5250
def _on_triggered(self):
5351
node = self.graph.get_node_by_id(self.node_id)

NodeGraphQt/widgets/viewer.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@ def __init__(self, parent=None):
8383

8484
self._ctx_menu = BaseMenu('NodeGraph', self)
8585
self._ctx_node_menu = BaseMenu('Nodes', self)
86+
self._ctx_port_menu = BaseMenu('Ports', self)
8687
menu_bar.addMenu(self._ctx_menu)
8788
menu_bar.addMenu(self._ctx_node_menu)
89+
menu_bar.addMenu(self._ctx_port_menu)
8890

8991
self._ctx_node_menu.setDisabled(True)
92+
self._ctx_port_menu.setDisabled(True)
9093

9194
self.acyclic = True
9295
self.LMB_state = False
@@ -157,7 +160,7 @@ def resizeEvent(self, event):
157160

158161
def contextMenuEvent(self, event):
159162
self.RMB_state = False
160-
ctx_menu = self._ctx_menu
163+
ctx_menu = None
161164

162165
if self._ctx_node_menu.isEnabled():
163166
pos = self.mapToScene(self._previous_pos)
@@ -166,10 +169,13 @@ def contextMenuEvent(self, event):
166169
if nodes:
167170
node = nodes[0]
168171
ctx_menu = self._ctx_node_menu.get_menu(node.type_)
169-
for action in ctx_menu.actions():
170-
if not action.menu():
171-
action.node_id = node.id
172-
if ctx_menu and ctx_menu.isEnabled():
172+
if ctx_menu:
173+
for action in ctx_menu.actions():
174+
if not action.menu():
175+
action.node_id = node.id
176+
177+
ctx_menu = ctx_menu or self._ctx_menu
178+
if ctx_menu.isEnabled():
173179
ctx_menu.exec_(event.globalPos())
174180
else:
175181
return super(NodeViewer, self).contextMenuEvent(event)

0 commit comments

Comments
 (0)