From 91cda49d7c1d012e67ffba3cbf0a433ede1bb85a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 17 Aug 2017 14:08:39 +0200 Subject: QmlDesigner: Fix shift modifer in layout case The move tool normally does not reparent, but by pressing shift the user can enforce reparenting. In the drag tool we prefer to reparent to layouts. The shoft modifer disables this heuristic. Task-number: QTCREATORBUG-18737 Change-Id: Ic8041aed537619b16b892a791c0d2bc2390af204 Reviewed-by: Tim Jenssen --- src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp | 5 +++-- src/plugins/qmldesigner/components/formeditor/movemanipulator.h | 7 ++++++- src/plugins/qmldesigner/components/formeditor/movetool.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp index ecca77a73d..d55f85090f 100644 --- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp @@ -332,7 +332,7 @@ void MoveManipulator::clear() m_beginVerticalCenterHash.clear(); } -void MoveManipulator::reparentTo(FormEditorItem *newParent) +void MoveManipulator::reparentTo(FormEditorItem *newParent, ReparentFlag flag) { deleteSnapLines(); @@ -348,7 +348,8 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent) && newParent->qmlItemNode().modelNode().hasParentProperty()) { ModelNode grandParent = newParent->qmlItemNode().modelNode().parentProperty().parentModelNode(); if (grandParent.metaInfo().isLayoutable() - && !NodeHints::fromModelNode(grandParent).isStackedContainer()) + && !NodeHints::fromModelNode(grandParent).isStackedContainer() + && flag == DoNotEnforceReparent) newParent = m_view.data()->scene()->itemForQmlItemNode(QmlItemNode(grandParent)); } diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h index 27b2e465f0..b64b31a97e 100644 --- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h +++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h @@ -48,6 +48,11 @@ public: UseBaseState }; + enum ReparentFlag { + DoNotEnforceReparent, + EnforceReparent + }; + MoveManipulator(LayerItem *layerItem, FormEditorView *view); ~MoveManipulator(); void setItems(const QList &itemList); @@ -57,7 +62,7 @@ public: void begin(const QPointF& beginPoint); void update(const QPointF& updatePoint, Snapper::Snapping useSnapping, State stateToBeManipulated = UseCurrentState); - void reparentTo(FormEditorItem *newParent); + void reparentTo(FormEditorItem *newParent, ReparentFlag flag = DoNotEnforceReparent); void end(); void end(Snapper::Snapping useSnapping); diff --git a/src/plugins/qmldesigner/components/formeditor/movetool.cpp b/src/plugins/qmldesigner/components/formeditor/movetool.cpp index d6eaee3b2e..b779216d61 100644 --- a/src/plugins/qmldesigner/components/formeditor/movetool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movetool.cpp @@ -113,7 +113,7 @@ void MoveTool::mouseMoveEvent(const QList &itemList, if (m_movingItems.count() > 1 || (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode()))) - m_moveManipulator.reparentTo(containerItem); + m_moveManipulator.reparentTo(containerItem, MoveManipulator::EnforceReparent); } } -- cgit v1.2.1