[ui] Graph: Updating the way how color gets set on the selected nodes

Coloring the nodes now uses setAttribute command instead of relying on refrences to Nodes within the graph.
This commit is contained in:
waaake 2024-11-28 09:28:36 +05:30
parent 418bd638ad
commit 233bbb76c8
4 changed files with 11 additions and 65 deletions

View file

@ -953,15 +953,18 @@ class UIGraph(QObject):
self.selectNodes(self._graph.dfsOnDiscover(startNodes=[node], reverse=True, dependenciesOnly=True)[0])
@Slot(str)
def updateNodeColor(self, color):
def setSelectedNodesColor(self, color: str):
""" Sets the Provided color on the selected Nodes.
Args:
color (str): Hex code of the color to be set on the nodes.
"""
# Update the color attribute of the nodes which are currently selected
with self.groupedGraphModification("Update Color for Select Nodes"):
self.push(commands.UpdateNodeColorCommand(self._graph, list(self._selectedNodes), color))
with self.groupedGraphModification("Set Nodes Color"):
# For each of the selected nodes -> Check if the node has a color -> Apply the color if it has
for node in self._selectedNodes:
if node.hasInternalAttribute("color"):
self.setAttribute(node.internalAttribute("color"), color)
@Slot(QObject, QObject)
def boxSelect(self, selection, draggable):