From 38e02188ee132fd8c483fcb9773979875677c070 Mon Sep 17 00:00:00 2001 From: Cyril Oblikov Date: Thu, 27 Sep 2012 17:55:16 +0300 Subject: Possibility to change custom Drag&Drop cursors while dragging something. Implementation for Windows and X11. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additional checks to figure out if new Drag&Drop cursors where set. This means it is possible now to keep QDrag object in your program and call setDragCursor() method every time we need to change cursor depending on context. Change-Id: I4be69e44b2863371a7ffbb29efc17c18210d6cde Reviewed-by: Friedemann Kleint Reviewed-by: Gatis Paeglis Reviewed-by: Samuel Rødal --- src/platformsupport/dnd/qsimpledrag.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/platformsupport/dnd/qsimpledrag.cpp') diff --git a/src/platformsupport/dnd/qsimpledrag.cpp b/src/platformsupport/dnd/qsimpledrag.cpp index d8ef17ede3..18e6b97e3c 100644 --- a/src/platformsupport/dnd/qsimpledrag.cpp +++ b/src/platformsupport/dnd/qsimpledrag.cpp @@ -253,8 +253,19 @@ void QBasicDrag::updateCursor(Qt::DropAction action) } QCursor *cursor = qApp->overrideCursor(); - if (cursor && cursorShape != cursor->shape()) { - qApp->changeOverrideCursor(QCursor(cursorShape)); + QPixmap pixmap = m_drag->dragCursor(action); + if (!cursor) { + qApp->changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap)); + } else { + if (!pixmap.isNull()) { + if ((cursor->pixmap().cacheKey() != pixmap.cacheKey())) { + qApp->changeOverrideCursor(QCursor(pixmap)); + } + } else { + if (cursorShape != cursor->shape()) { + qApp->changeOverrideCursor(QCursor(cursorShape)); + } + } } updateAction(action); } -- cgit v1.2.3