Restore cursor before sending QDropEvent

When users created a modal window in a dropEvent(QDropEvent* event),
the cursor was not restored to its original shape until after the modal
window had been dismissed.

Change-Id: Id4723e3cb66b36a3ca18ff097a3993563816d9e1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Gatis Paeglis 2013-05-10 23:16:20 +02:00 committed by The Qt Project
parent 29b9b92f40
commit a77e4ea207
3 changed files with 4 additions and 7 deletions

View File

@ -140,7 +140,6 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
QKeyEvent *ke = static_cast<QKeyEvent *>(e); QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) { if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) {
cancel(); cancel();
resetDndState(true);
disableEventFilter(); disableEventFilter();
exitDndEventLoop(); exitDndEventLoop();
@ -154,13 +153,10 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
disableEventFilter(); disableEventFilter();
if (canDrop()) { if (canDrop()) {
drop(static_cast<QMouseEvent *>(e)); drop(static_cast<QMouseEvent *>(e));
resetDndState(false);
} else { } else {
cancel(); cancel();
resetDndState(true);
} }
exitDndEventLoop(); exitDndEventLoop();
return true; // Eat all mouse events return true; // Eat all mouse events
@ -195,7 +191,7 @@ Qt::DropAction QBasicDrag::drag(QDrag *o)
return m_executed_drop_action; return m_executed_drop_action;
} }
void QBasicDrag::resetDndState(bool /* deleteSource */) void QBasicDrag::restoreCursor()
{ {
if (m_restoreCursor) { if (m_restoreCursor) {
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
@ -227,6 +223,7 @@ void QBasicDrag::endDrag()
void QBasicDrag::cancel() void QBasicDrag::cancel()
{ {
disableEventFilter(); disableEventFilter();
restoreCursor();
m_drag_icon_window->setVisible(false); m_drag_icon_window->setVisible(false);
} }
@ -239,6 +236,7 @@ void QBasicDrag::move(const QMouseEvent *)
void QBasicDrag::drop(const QMouseEvent *) void QBasicDrag::drop(const QMouseEvent *)
{ {
disableEventFilter(); disableEventFilter();
restoreCursor();
m_drag_icon_window->setVisible(false); m_drag_icon_window->setVisible(false);
} }

View File

@ -88,7 +88,7 @@ protected:
private: private:
void enableEventFilter(); void enableEventFilter();
void disableEventFilter(); void disableEventFilter();
void resetDndState(bool deleteSource); void restoreCursor();
void exitDndEventLoop(); void exitDndEventLoop();
bool m_restoreCursor; bool m_restoreCursor;

View File

@ -523,7 +523,6 @@ void QXcbDrag::drop(const QMouseEvent *event)
current_proxy_target = 0; current_proxy_target = 0;
source_time = 0; source_time = 0;
// current_embedding_widget = 0; // current_embedding_widget = 0;
// #fixme resetDndState(false);
} }
Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t a) const Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t a) const