summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativemousearea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativemousearea.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index d9edd11..0a043a7 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -500,17 +500,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
const int dragThreshold = QApplication::startDragDistance();
qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
- if ((d->dragX && !(dx < dragThreshold)) || (d->dragY && !(dy < dragThreshold))) {
+
+ if (keepMouseGrab() && d->stealMouse)
d->drag->setActive(true);
- d->stealMouse = true;
- }
- if (!keepMouseGrab()) {
- if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
- || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
- || (d->dragX && d->dragY)) {
- setKeepMouseGrab(true);
- }
- }
if (d->dragX && d->drag->active()) {
qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
@@ -528,6 +520,16 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
y = drag()->ymax();
drag()->target()->setY(y);
}
+
+ if (!keepMouseGrab()) {
+ if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
+ || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
+ || (d->dragX && d->dragY && (dx > dragThreshold || dy > dragThreshold))) {
+ setKeepMouseGrab(true);
+ d->stealMouse = true;
+ }
+ }
+
d->moved = true;
}
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
@@ -618,6 +620,7 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
// if our mouse grab has been removed (probably by Flickable), fix our
// state
d->pressed = false;
+ d->stealMouse = false;
setKeepMouseGrab(false);
emit canceled();
emit pressedChanged();
@@ -672,8 +675,18 @@ bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
return stealThisEvent;
}
if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
- d->stealMouse = false;
- ungrabMouse();
+ if (d->pressed) {
+ d->pressed = false;
+ d->stealMouse = false;
+ if (s && s->mouseGrabberItem() == this)
+ ungrabMouse();
+ emit canceled();
+ emit pressedChanged();
+ if (d->hovered) {
+ d->hovered = false;
+ emit hoveredChanged();
+ }
+ }
}
return false;
}