Skip to content

Commit

Permalink
Merge pull request #123 from jchanvfx/port_disconnect_signal_#122
Browse files Browse the repository at this point in the history
port disconnected signal
  • Loading branch information
jchanvfx authored Aug 19, 2019
2 parents 205f679 + cf4d69e commit 6cacbdd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion NodeGraphQt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self):
from .base.node import NodeObject, BaseNode, BackdropNode
from .base.port import Port
from .pkg_info import __version__ as VERSION
from .pkg_info import __license__ as LICENSE

# functions
from .base.actions import setup_context_menu
Expand All @@ -94,7 +95,7 @@ def __init__(self):

__version__ = VERSION
__all__ = [
'BackdropNode', 'BaseNode', 'Menu', 'MenuCommand', 'NodeGraph',
'BackdropNode', 'BaseNode', 'LICENSE', 'Menu', 'MenuCommand', 'NodeGraph',
'NodeObject', 'NodeTreeWidget', 'Port', 'PropertiesBinWidget', 'VERSION',
'constants', 'setup_context_menu'
]
2 changes: 2 additions & 0 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class NodeGraph(QtCore.QObject):
node_double_clicked = QtCore.Signal(NodeObject)
#: signal for when a node has been connected emits (source port, target port).
port_connected = QtCore.Signal(Port, Port)
#: signal for when a node has been disconnected emits (source port, target port).
port_disconnected = QtCore.Signal(Port, Port)
#: signal for when a node property has changed emits (node, property name, property value).
property_changed = QtCore.Signal(NodeObject, str, object)
#: signal for when drop data has been added to the graph.
Expand Down
9 changes: 7 additions & 2 deletions NodeGraphQt/base/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def connected_ports(self):

def connect_to(self, port=None):
"""
Create connection to the specified port.
Create connection to the specified port and emits the "port_connected"
signal from the parent node graph.
Args:
port (NodeGraphQt.Port): port object.
Expand Down Expand Up @@ -170,7 +171,8 @@ def connect_to(self, port=None):

def disconnect_from(self, port=None):
"""
Disconnect from the specified port.
Disconnect from the specified port and emits the "port_disconnected"
signal from the parent node graph.
Args:
port (NodeGraphQt.Port): port object.
Expand All @@ -179,3 +181,6 @@ def disconnect_from(self, port=None):
return
graph = self.node().graph
graph.undo_stack().push(PortDisconnectedCmd(self, port))

# emit "port_disconnected" signal from the parent graph.
graph.port_disconnected.emit(self, port)
3 changes: 3 additions & 0 deletions NodeGraphQt/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from .pkg_info import __version__

#: Version of the NodeGraphQt framework.
VERSION = __version__

# === PIPE ===

Expand Down

0 comments on commit 6cacbdd

Please sign in to comment.