forked from qt-creator/qt-creator
QmlDesigner.dragTool: behaivour/usabilty fix
The user should be able to drop an item everywhere, also outside the root item. The item is created in the scene when the animation is over. Also the animation is shorter now.
This commit is contained in:
@@ -146,7 +146,6 @@ void DragTool::beginWithPoint(const QPointF &beginPoint)
|
||||
|
||||
m_moveManipulator.setItem(m_movingItem.data());
|
||||
m_moveManipulator.begin(beginPoint);
|
||||
|
||||
}
|
||||
|
||||
void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlItemNode parentNode, QPointF scenePos)
|
||||
@@ -163,8 +162,6 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
|
||||
QList<QmlItemNode> nodeList;
|
||||
nodeList.append(m_dragNode);
|
||||
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
||||
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
|
||||
}
|
||||
|
||||
void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos)
|
||||
@@ -182,8 +179,6 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode
|
||||
QList<QmlItemNode> nodeList;
|
||||
nodeList.append(m_dragNode);
|
||||
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
||||
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
|
||||
}
|
||||
|
||||
FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorItem * currentItem)
|
||||
@@ -195,7 +190,7 @@ FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorIte
|
||||
return formEditorItem;
|
||||
}
|
||||
|
||||
if (scene()->rootFormEditorItem() && scene()->rootFormEditorItem()->boundingRect().adjusted(-100, -100, 100, 100).contains(point))
|
||||
if (scene()->rootFormEditorItem())
|
||||
return scene()->rootFormEditorItem();
|
||||
return 0;
|
||||
}
|
||||
@@ -215,6 +210,7 @@ void DragTool::instancesCompleted(const QList<FormEditorItem*> &itemList)
|
||||
foreach (FormEditorItem* item, itemList)
|
||||
if (item->qmlItemNode() == m_dragNode)
|
||||
clearMoveDelay();
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
|
||||
}
|
||||
|
||||
void DragTool::clearMoveDelay()
|
||||
@@ -314,6 +310,8 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (m_blockMove)
|
||||
return;
|
||||
if (QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::isAnimated())
|
||||
return;
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
event->accept();
|
||||
@@ -334,7 +332,7 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
||||
if (m_dragNode.modelNode().isValid())
|
||||
return;
|
||||
|
||||
FormEditorItem *parentItem = calculateContainer(event->scenePos());
|
||||
FormEditorItem *parentItem = calculateContainer(scenePos);
|
||||
if (!parentItem)
|
||||
return;
|
||||
QmlItemNode parentNode;
|
||||
|
||||
@@ -160,7 +160,7 @@ void CustomDragAndDropIcon::enter()
|
||||
{
|
||||
connect(&m_timeLine, SIGNAL( frameChanged (int)), this, SLOT(animateDrag(int)));
|
||||
m_timeLine.setFrameRange(0, 10);
|
||||
m_timeLine.setDuration(250);
|
||||
m_timeLine.setDuration(150);
|
||||
m_timeLine.setLoopCount(1);
|
||||
m_timeLine.setCurveShape(QTimeLine::EaseInCurve);
|
||||
m_timeLine.start();
|
||||
@@ -310,6 +310,13 @@ void CustomDragAndDrop::drop(QWidget *target, QPoint globalPos)
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomDragAndDrop::isAnimated()
|
||||
{
|
||||
if (instance()->m_widget)
|
||||
return instance()->m_widget->isAnimated();
|
||||
return false;
|
||||
}
|
||||
|
||||
} //namespace QmlDesignerItemLibraryDragAndDrop
|
||||
} //namespave QmlDesigner
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
void startDrag();
|
||||
void grabMouseSafely();
|
||||
|
||||
bool isAnimated() const
|
||||
{ return m_timeLine.state() == QTimeLine::Running; }
|
||||
|
||||
public slots:
|
||||
void animateDrag(int frame);
|
||||
|
||||
@@ -87,6 +90,7 @@ public:
|
||||
static void leave(QWidget *target, QPoint globalPos);
|
||||
static void move(QWidget *target, QPoint globalPos);
|
||||
static void drop(QWidget *target, QPoint globalPos);
|
||||
static bool isAnimated();
|
||||
static void hide()
|
||||
{ instance()->m_isVisible = false; }
|
||||
static void show()
|
||||
|
||||
Reference in New Issue
Block a user