[ui] Graph: Using Grouped UI Graph Modification to disable animation for qml elements

Used graph's disabledAnimation flag to halt the animations when a backdrop node is resized during an undo.
This commit is contained in:
waaake 2025-01-08 17:51:21 +05:30
parent 2f29d00b73
commit 5fb7636f41
2 changed files with 14 additions and 2 deletions

View file

@ -639,6 +639,18 @@ class UIGraph(QObject):
""" """
return commands.GroupedGraphModification(self._graph, self._undoStack, title, disableUpdates) return commands.GroupedGraphModification(self._graph, self._undoStack, title, disableUpdates)
def groupedUIGraphModification(self, title, disableUpdates=True):
""" Get a GroupedUIGraphModification for this Graph.
Args:
title (str): the title of the macro command
disableUpdates (bool): whether to disable graph and ui updates
Returns:
GroupedGraphModification: the instantiated context manager
"""
return commands.GroupedUIGraphModification(self, self._undoStack, title, disableUpdates)
@Slot(str) @Slot(str)
def beginModification(self, name): def beginModification(self, name):
""" Begin a Graph modification. Calls to beginModification and endModification may be nested, but """ Begin a Graph modification. Calls to beginModification and endModification may be nested, but
@ -703,7 +715,7 @@ class UIGraph(QObject):
position (QPoint): Node's position. position (QPoint): Node's position.
""" """
# Update the node size # Update the node size
with self.groupedGraphModification("Resize Node"): with self.groupedUIGraphModification("Resize Node"):
if node.hasInternalAttribute("nodeWidth"): if node.hasInternalAttribute("nodeWidth"):
self.setAttribute(node.internalAttribute("nodeWidth"), width) self.setAttribute(node.internalAttribute("nodeWidth"), width)
if node.hasInternalAttribute("nodeHeight"): if node.hasInternalAttribute("nodeHeight"):

View file

@ -1123,7 +1123,7 @@ Item {
} }
Behavior on x { Behavior on x {
enabled: !nodeRepeater.ongoingDrag && !resizing enabled: !nodeRepeater.ongoingDrag && !resizing && !uigraph.animationsDisabled;
NumberAnimation { duration: 100 } NumberAnimation { duration: 100 }
} }
Behavior on y { Behavior on y {