diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2017-08-17 14:08:39 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2017-09-13 10:36:05 +0000 |
commit | 91cda49d7c1d012e67ffba3cbf0a433ede1bb85a (patch) | |
tree | 477ca33b1da7bee162cb35f9d9388ea410fe5841 | |
parent | 360609eb7abe93c477ab410eb8ab511fdb98f9f9 (diff) | |
download | qt-creator-91cda49d7c1d012e67ffba3cbf0a433ede1bb85a.tar.gz |
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 <tim.jenssen@qt.io>
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<FormEditorItem*> &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<QGraphicsItem*> &itemList, if (m_movingItems.count() > 1 || (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode()))) - m_moveManipulator.reparentTo(containerItem); + m_moveManipulator.reparentTo(containerItem, MoveManipulator::EnforceReparent); } } |