From e32f585fdaa5c374fc5cd12e527876287c7ee6aa Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 23 Sep 2022 23:53:27 +0200 Subject: [PATCH] QmlDesigner: Fix drop incorrect place * Fix drop incorrect place * Improve overall drag smoothness Task-number: QDS-7733 Change-Id: I70e23df54c0e52b423c21b883924c5daee955d0a Reviewed-by: Reviewed-by: Thomas Hartmann --- .../qmldesigner/newstateseditor/Main.qml | 33 +++++++------------ .../newstateseditor/StateThumbnail.qml | 7 ++++ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index dd9e5772b49..f38baa7bd4a 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -599,11 +599,6 @@ Rectangle { property int grabIndex: -1 - function executeDrop(from, to) { - statesEditorModel.drop(from, to) - statesRepeater.grabIndex = -1 - } - model: statesEditorModel onItemAdded: root.responsiveResize(root.width, root.height) @@ -646,27 +641,27 @@ Rectangle { return } - statesEditorModel.move( - (drag.source as StateThumbnail).visualIndex, - stateThumbnail.visualIndex) + statesEditorModel.move(dragSource.visualIndex, + stateThumbnail.visualIndex) } onDropped: function (drop) { - let dragSource = (drop.source as StateThumbnail) + let dropSource = (drop.source as StateThumbnail) - if (dragSource === undefined) + if (dropSource === undefined) return - if (dragSource.extendString !== stateThumbnail.extendString + if (dropSource.extendString !== stateThumbnail.extendString || stateThumbnail.extendedState) { return } - if (statesRepeater.grabIndex === stateThumbnail.visualIndex) + if (statesRepeater.grabIndex === dropSource.visualIndex) return - statesRepeater.executeDrop(statesRepeater.grabIndex, - stateThumbnail.visualIndex) + statesEditorModel.drop(statesRepeater.grabIndex, + dropSource.visualIndex) + statesRepeater.grabIndex = -1 } // Extend Groups Visualization @@ -768,6 +763,8 @@ Rectangle { hasWhenCondition: delegateRoot.hasWhenCondition + dragParent: scrollView + // Fix ScrollView taking over the dragging event onGrabbing: { frame.interactive = false @@ -775,14 +772,6 @@ Rectangle { } onLetGo: frame.interactive = true - // Fix for ScrollView clipping while dragging of StateThumbnail - onDragActiveChanged: { - if (stateThumbnail.dragActive) - parent = scrollViewWrapper - else - parent = delegateRoot - } - stateName: delegateRoot.stateName thumbnailImageSource: delegateRoot.stateImageSource whenCondition: delegateRoot.whenConditionString diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml index 9cde5f27449..ee1ea8132a4 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml @@ -55,6 +55,8 @@ Item { property bool hasWhenCondition: false + property Item dragParent + property int visualIndex: 0 property int internalNodeId @@ -765,6 +767,11 @@ Item { name: "drag" when: dragHandler.active + ParentChange { + target: root + parent: root.dragParent + } + AnchorChanges { target: root anchors.horizontalCenter: undefined