From ac0251e1067ec363033b44772cba77adaff724b7 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 6 Oct 2022 11:15:22 +0200 Subject: [PATCH] QmlDesigner: Block DragHandler when menu open Task-number: QDS-7851 Change-Id: Ia48e326c1f33d7b405eb2f93936e3aa99f0a9e60 Reviewed-by: Reviewed-by: Thomas Hartmann --- .../qtcreator/qmldesigner/newstateseditor/Main.qml | 14 +++++++++++++- .../qmldesigner/newstateseditor/StateThumbnail.qml | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index 540f70b4857..4431252eccd 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -253,6 +253,10 @@ Rectangle { property bool tinyMode: Constants.thumbnailSize <= Constants.thumbnailBreak property int currentStateInternalId: 0 + // Using an int instead of a bool, because when opening a menu on one state and without closing + // opening a menu on another state will first trigger the open of the new popup and afterwards + // the close of the old popup. Using an int keeps track of number of opened popups. + property int menuOpen: 0 // This timer is used to delay the current state animation as it didn't work due to the // repeaters item not being positioned in time resulting in 0 x and y position if the grids @@ -797,10 +801,18 @@ Rectangle { hasWhenCondition: delegateRoot.hasWhenCondition - scrollViewActive: horizontalBar.active || verticalBar.active + blockDragHandler: horizontalBar.active || verticalBar.active + || root.menuOpen dragParent: scrollView + onMenuOpenChanged: { + if (stateThumbnail.menuOpen) + root.menuOpen++ + else + root.menuOpen-- + } + // Fix ScrollView taking over the dragging event onGrabbing: { frame.interactive = false diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml index ce95aa21983..e154bb4d39b 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml @@ -55,7 +55,8 @@ Item { property bool hasWhenCondition: false - property bool scrollViewActive: false + property bool menuOpen: stateMenu.opened + property bool blockDragHandler: false property Item dragParent @@ -91,7 +92,7 @@ Item { DragHandler { id: dragHandler - enabled: !root.baseState && !root.extendedState && !root.scrollViewActive + enabled: !root.baseState && !root.extendedState && !root.blockDragHandler onGrabChanged: function (transition, point) { if (transition === PointerDevice.GrabPassive || transition === PointerDevice.GrabExclusive)