From 2e9b47d6bd999c622011dcd1f7e30d5f77da4d25 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 3 Feb 2010 20:08:57 +0000 Subject: [PATCH] if the user dragged less than KGlobalSettings::dndEventDelay() and releases, don't drag, but pass the click, start to drag after that threshold svn path=/trunk/KDE/kdelibs/; revision=1084809 --- widgets/scrollwidget.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/widgets/scrollwidget.cpp b/widgets/scrollwidget.cpp index 2675e40f2..5e8323b97 100644 --- a/widgets/scrollwidget.cpp +++ b/widgets/scrollwidget.cpp @@ -597,15 +597,31 @@ bool ScrollWidget::eventFilter(QObject *watched, QEvent *event) if (event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseMove || event->type() == QEvent::GraphicsSceneMouseRelease) { - if (scene()) { + + QGraphicsSceneMouseEvent *me = static_cast(event); + + if (event->type() == QEvent::GraphicsSceneMousePress) { + d->dragHandleClicked = me->scenePos(); + } + + d->dragging = (d->dragging | (d->dragHandleClicked.toPoint() - me->scenePos().toPoint()).manhattanLength() > (KGlobalSettings::dndEventDelay())); + + if (scene() && event->type() != QEvent::GraphicsSceneMouseMove) { scene()->sendEvent(this, event); } - QGraphicsSceneMouseEvent *me = static_cast(event); - if (event->type() == QEvent::GraphicsSceneMousePress) { - d->dragHandleClicked = me->scenePos(); - } else if (event->type() == QEvent::GraphicsSceneMouseRelease && - (d->dragHandleClicked.toPoint() - me->scenePos().toPoint()).manhattanLength() > KGlobalSettings::dndEventDelay()) { + if (!d->dragging) { + return false; + } + + if (scene() && event->type() == QEvent::GraphicsSceneMouseMove) { + scene()->sendEvent(this, event); + } + + + if (event->type() == QEvent::GraphicsSceneMouseRelease) { + + d->dragging = false; return true; } }