forked from qt-creator/qt-creator
QmlDesigner: Fix Components lib wrong scrolling after drag-n-drop
Change-Id: Ibd3f3c155496443eac0accf468280a15cad51351 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -235,7 +235,7 @@ Item {
|
|||||||
id: verticalScrollView
|
id: verticalScrollView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
interactive: !itemContextMenu.opened && !moduleContextMenu.opened
|
interactive: !itemContextMenu.opened && !moduleContextMenu.opened && !rootView.isDragging
|
||||||
|
|
||||||
onContentHeightChanged: {
|
onContentHeightChanged: {
|
||||||
var maxPosition = Math.max(contentHeight - verticalScrollView.height, 0)
|
var maxPosition = Math.max(contentHeight - verticalScrollView.height, 0)
|
||||||
@@ -352,7 +352,7 @@ Item {
|
|||||||
width: 270
|
width: 270
|
||||||
height: parent.height
|
height: parent.height
|
||||||
clip: true
|
clip: true
|
||||||
interactive: !itemContextMenu.opened && !moduleContextMenu.opened
|
interactive: !itemContextMenu.opened && !moduleContextMenu.opened && !rootView.isDragging
|
||||||
|
|
||||||
onContentHeightChanged: {
|
onContentHeightChanged: {
|
||||||
var maxPosition = Math.max(contentHeight - horizontalScrollView.height, 0)
|
var maxPosition = Math.max(contentHeight - horizontalScrollView.height, 0)
|
||||||
@@ -457,6 +457,8 @@ Item {
|
|||||||
id: itemScrollView
|
id: itemScrollView
|
||||||
width: itemsView.width - 275
|
width: itemsView.width - 275
|
||||||
height: itemsView.height
|
height: itemsView.height
|
||||||
|
interactive: !itemContextMenu.opened && !moduleContextMenu.opened && !rootView.isDragging
|
||||||
|
|
||||||
onContentHeightChanged: {
|
onContentHeightChanged: {
|
||||||
var maxPosition = Math.max(contentHeight - itemScrollView.height, 0)
|
var maxPosition = Math.max(contentHeight - itemScrollView.height, 0)
|
||||||
if (contentY > maxPosition)
|
if (contentY > maxPosition)
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ bool ItemLibraryWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
m_itemToDrag = {};
|
m_itemToDrag = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (event->type() == QMouseEvent::MouseButtonRelease) {
|
||||||
|
m_itemToDrag = {};
|
||||||
|
|
||||||
|
setIsDragging(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
@@ -366,12 +370,21 @@ void ItemLibraryWidget::handlePriorityImportsChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemLibraryWidget::setIsDragging(bool val)
|
||||||
|
{
|
||||||
|
if (m_isDragging != val) {
|
||||||
|
m_isDragging = val;
|
||||||
|
emit isDraggingChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ItemLibraryWidget::startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos)
|
void ItemLibraryWidget::startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos)
|
||||||
{
|
{
|
||||||
// Actual drag is created after mouse has moved to avoid a QDrag bug that causes drag to stay
|
// Actual drag is created after mouse has moved to avoid a QDrag bug that causes drag to stay
|
||||||
// active (and blocks mouse release) if mouse is released at the same spot of the drag start.
|
// active (and blocks mouse release) if mouse is released at the same spot of the drag start.
|
||||||
m_itemToDrag = itemLibEntry;
|
m_itemToDrag = itemLibEntry;
|
||||||
m_dragStartPoint = mousePos.toPoint();
|
m_dragStartPoint = mousePos.toPoint();
|
||||||
|
setIsDragging(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ItemLibraryWidget::subCompEditMode() const
|
bool ItemLibraryWidget::subCompEditMode() const
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ class ItemLibraryWidget : public QFrame
|
|||||||
public:
|
public:
|
||||||
Q_PROPERTY(bool subCompEditMode READ subCompEditMode NOTIFY subCompEditModeChanged)
|
Q_PROPERTY(bool subCompEditMode READ subCompEditMode NOTIFY subCompEditModeChanged)
|
||||||
|
|
||||||
|
// Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position
|
||||||
|
Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged)
|
||||||
|
|
||||||
ItemLibraryWidget(AsynchronousImageCache &imageCache);
|
ItemLibraryWidget(AsynchronousImageCache &imageCache);
|
||||||
~ItemLibraryWidget();
|
~ItemLibraryWidget();
|
||||||
|
|
||||||
@@ -76,6 +79,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void itemActivated(const QString &itemName);
|
void itemActivated(const QString &itemName);
|
||||||
void subCompEditModeChanged();
|
void subCompEditModeChanged();
|
||||||
|
void isDraggingChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
@@ -86,6 +90,8 @@ private:
|
|||||||
|
|
||||||
void updateSearch();
|
void updateSearch();
|
||||||
void handlePriorityImportsChanged();
|
void handlePriorityImportsChanged();
|
||||||
|
void setIsDragging(bool val);
|
||||||
|
|
||||||
static QString getDependencyImport(const Import &import);
|
static QString getDependencyImport(const Import &import);
|
||||||
|
|
||||||
QTimer m_compressionTimer;
|
QTimer m_compressionTimer;
|
||||||
@@ -107,6 +113,7 @@ private:
|
|||||||
QString m_filterText;
|
QString m_filterText;
|
||||||
QPoint m_dragStartPoint;
|
QPoint m_dragStartPoint;
|
||||||
bool m_subCompEditMode = false;
|
bool m_subCompEditMode = false;
|
||||||
|
bool m_isDragging = false;
|
||||||
|
|
||||||
inline static int HORIZONTAL_LAYOUT_WIDTH_LIMIT = 600;
|
inline static int HORIZONTAL_LAYOUT_WIDTH_LIMIT = 600;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user