From 009480275e0bfc471a7c315ac5f74e941c1e85ff Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 22 Sep 2011 17:28:04 +0200 Subject: Use the drag cursor shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correctly use the Qt::Drag* cursor shapes for drags. Still doesn't work as QGuiApp::setOverrideCursor needs an implementation. Change-Id: I60b6a647be03f3700408ee8afcfa631a18e2bcaf Reviewed-on: http://codereview.qt-project.org/5559 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/gui/kernel/qdnd.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index 9a90c213cf..b3aa206234 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -354,20 +354,21 @@ void QDragManager::updateCursor() shapedPixmapWindow->render(); // ### Hack shapedPixmapWindow->move(QCursor::pos() - shapedPixmapWindow->hotSpot); } -#ifndef QT_NO_CURSOR + + Qt::CursorShape cursorShape = Qt::ForbiddenCursor; if (willDrop) { - if (currentActionForOverrideCursor != global_accepted_action) { - QGuiApplication::changeOverrideCursor(QCursor(dragCursor(global_accepted_action), 0, 0)); - currentActionForOverrideCursor = global_accepted_action; - } - } else { - QCursor *overrideCursor = QGuiApplication::overrideCursor(); - if (!overrideCursor || overrideCursor->shape() != Qt::ForbiddenCursor) { - QGuiApplication::changeOverrideCursor(QCursor(Qt::ForbiddenCursor)); - currentActionForOverrideCursor = Qt::IgnoreAction; + if (global_accepted_action == Qt::CopyAction) { + cursorShape = Qt::DragCopyCursor; + } else if (global_accepted_action == Qt::LinkAction) { + cursorShape = Qt::DragLinkCursor; + } else { + cursorShape = Qt::DragMoveCursor; } } -#endif + if (cursorShape != qApp->overrideCursor()->shape()) { + qDebug() << "setting cursor shape to" << cursorShape; + qApp->changeOverrideCursor(QCursor(cursorShape)); + } } @@ -465,7 +466,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) global_accepted_action = Qt::CopyAction; #ifndef QT_NO_CURSOR - qApp->setOverrideCursor(Qt::ArrowCursor); + qApp->setOverrideCursor(Qt::DragCopyCursor); restoreCursor = true; updateCursor(); #endif -- cgit v1.2.3