diff --git a/applets/kicker/package/contents/ui/ItemGridView.qml b/applets/kicker/package/contents/ui/ItemGridView.qml --- a/applets/kicker/package/contents/ui/ItemGridView.qml +++ b/applets/kicker/package/contents/ui/ItemGridView.qml @@ -428,19 +428,17 @@ onReleased: { mouse.accepted = true; - var item = updatePositionProperties(mouse.x, mouse.y); - - if (item === undefined) { - if (gridView.currentItem && gridView.currentItem == pressedItem) { - if ("trigger" in gridView.model) { - gridView.model.trigger(pressedItem.itemIndex, "", null); - root.toggle(); - } + updatePositionProperties(mouse.x, mouse.y); - itemGrid.itemActivated(pressedItem.itemIndex, "", null); - } else if (!pressedItem && mouse.button == Qt.LeftButton) { + if (gridView.currentItem && gridView.currentItem == pressedItem) { + if ("trigger" in gridView.model) { + gridView.model.trigger(pressedItem.itemIndex, "", null); root.toggle(); } + + itemGrid.itemActivated(pressedItem.itemIndex, "", null); + } else if (!dragHelper.dragging && !pressedItem && mouse.button == Qt.LeftButton) { + root.toggle(); } pressX = -1; diff --git a/applets/kicker/plugin/draghelper.h b/applets/kicker/plugin/draghelper.h --- a/applets/kicker/plugin/draghelper.h +++ b/applets/kicker/plugin/draghelper.h @@ -30,26 +30,31 @@ { Q_OBJECT Q_PROPERTY(int dragIconSize READ dragIconSize WRITE setDragIconSize NOTIFY dragIconSizeChanged) + Q_PROPERTY(bool dragging READ isDragging NOTIFY draggingChanged) public: explicit DragHelper(QObject *parent = nullptr); ~DragHelper() override; int dragIconSize() const; void setDragIconSize(int size); + bool isDragging() const { return m_dragging; } Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const; Q_INVOKABLE void startDrag(QQuickItem* item, const QUrl &url = QUrl(), const QIcon &icon = QIcon(), const QString &extraMimeType = QString(), const QString &extraMimeData = QString()); Q_SIGNALS: void dragIconSizeChanged() const; void dropped() const; + void draggingChanged() const; private: int m_dragIconSize; + bool m_dragging; Q_INVOKABLE void doDrag(QQuickItem* item, const QUrl &url = QUrl(), const QIcon &icon = QIcon(), - const QString &extraMimeType = QString(), const QString &extraMimeData = QString()) const; + const QString &extraMimeType = QString(), const QString &extraMimeData = QString()); + void setDragging(bool dragging); }; #endif diff --git a/applets/kicker/plugin/draghelper.cpp b/applets/kicker/plugin/draghelper.cpp --- a/applets/kicker/plugin/draghelper.cpp +++ b/applets/kicker/plugin/draghelper.cpp @@ -24,9 +24,11 @@ #include #include #include +#include DragHelper::DragHelper(QObject* parent) : QObject(parent) , m_dragIconSize(32) +, m_dragging(false) { } @@ -66,8 +68,10 @@ } void DragHelper::doDrag(QQuickItem *item, const QUrl &url, const QIcon &icon, - const QString &extraMimeType, const QString &extraMimeData) const + const QString &extraMimeType, const QString &extraMimeData) { + setDragging(true); + if (item && item->window() && item->window()->mouseGrabberItem()) { item->window()->mouseGrabberItem()->ungrabMouse(); } @@ -93,5 +97,17 @@ drag->exec(); emit dropped(); + + // Ensure dragging is still true when onRelease is called. + QTimer::singleShot(0, qApp, [this] { + setDragging(false); + }); } +void DragHelper::setDragging(bool dragging) +{ + if (m_dragging == dragging) + return; + m_dragging = dragging; + emit draggingChanged(); +} \ No newline at end of file