Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/draghelper.cpp
Context not available. | |||||
24 | #include <QMimeData> | 24 | #include <QMimeData> | ||
---|---|---|---|---|---|
25 | #include <QQuickItem> | 25 | #include <QQuickItem> | ||
26 | #include <QQuickWindow> | 26 | #include <QQuickWindow> | ||
27 | #include <QTimer> | ||||
27 | 28 | | |||
28 | DragHelper::DragHelper(QObject* parent) : QObject(parent) | 29 | DragHelper::DragHelper(QObject* parent) : QObject(parent) | ||
29 | , m_dragIconSize(32) | 30 | , m_dragIconSize(32) | ||
31 | , m_dragging(false) | ||||
30 | { | 32 | { | ||
31 | } | 33 | } | ||
32 | 34 | | |||
Context not available. | |||||
66 | } | 68 | } | ||
67 | 69 | | |||
68 | void DragHelper::doDrag(QQuickItem *item, const QUrl &url, const QIcon &icon, | 70 | void DragHelper::doDrag(QQuickItem *item, const QUrl &url, const QIcon &icon, | ||
69 | const QString &extraMimeType, const QString &extraMimeData) const | 71 | const QString &extraMimeType, const QString &extraMimeData) | ||
70 | { | 72 | { | ||
73 | setDragging(true); | ||||
74 | | ||||
71 | if (item && item->window() && item->window()->mouseGrabberItem()) { | 75 | if (item && item->window() && item->window()->mouseGrabberItem()) { | ||
72 | item->window()->mouseGrabberItem()->ungrabMouse(); | 76 | item->window()->mouseGrabberItem()->ungrabMouse(); | ||
73 | } | 77 | } | ||
Context not available. | |||||
93 | drag->exec(); | 97 | drag->exec(); | ||
94 | 98 | | |||
95 | emit dropped(); | 99 | emit dropped(); | ||
100 | | ||||
101 | // Ensure dragging is still true when onRelease is called. | ||||
102 | QTimer::singleShot(0, qApp, [this] { | ||||
103 | setDragging(false); | ||||
104 | }); | ||||
96 | } | 105 | } | ||
97 | 106 | | |||
107 | void DragHelper::setDragging(bool dragging) | ||||
108 | { | ||||
109 | if (m_dragging == dragging) | ||||
110 | return; | ||||
111 | m_dragging = dragging; | ||||
112 | emit draggingChanged(); | ||||
113 | } | ||||
114 | No newline at end of file | ||||
Context not available. |