diff options
Diffstat (limited to 'src')
5 files changed, 65 insertions, 64 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index edbd9782..64ae2094 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -799,22 +799,19 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newY <= maxY) { + newY = maxY; + rejectY = vData.pressPos == maxY && dy < 0; + } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newY >= minY) { + newY = minY; + rejectY = vData.pressPos == minY && dy > 0; } if (!rejectY && stealMouse && dy != 0) { vData.move.setValue(qRound(newY)); vMoved = true; } - if (qAbs(dy) > QApplication::startDragDistance()) + if (!rejectY && qAbs(dy) > QApplication::startDragDistance()) stealY = true; } } @@ -831,23 +828,20 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newX <= maxX) { + newX = maxX; + rejectX = hData.pressPos == maxX && dx < 0; + } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newX >= minX) { + newX = minX; + rejectX = hData.pressPos == minX && dx > 0; } if (!rejectX && stealMouse && dx != 0) { hData.move.setValue(qRound(newX)); hMoved = true; } - if (qAbs(dx) > QApplication::startDragDistance()) + if (!rejectX && qAbs(dx) > QApplication::startDragDistance()) stealX = true; } } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 99b3857d..c3bb5d9f 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2744,9 +2744,27 @@ QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const void QDeclarativeItemPrivate::focusChanged(bool flag) { Q_Q(QDeclarativeItem); - if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent) - emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange() - emit q->focusChanged(flag); + + if (hadActiveFocus != flag) { + hadActiveFocus = flag; + emit q->activeFocusChanged(flag); + } + + QDeclarativeItem *focusItem = q; + for (QDeclarativeItem *p = q->parentItem(); p; p = p->parentItem()) { + if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + if (!flag && QGraphicsItemPrivate::get(p)->focusScopeItem != focusItem) + break; + if (p->d_func()->hadActiveFocus != flag) { + p->d_func()->hadActiveFocus = flag; + emit p->activeFocusChanged(flag); + } + focusItem = p; + } + } + + // For all but the top most focus scope/item this will be called for us by QGraphicsItem. + focusItem->d_func()->focusScopeItemChange(flag); } QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::resources() diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 8ef91887..20262307 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -128,8 +128,8 @@ public: componentComplete(true), keepMouse(false), smooth(false), transformOriginDirty(true), doneEventPreHandler(false), inheritedLayoutMirror(false), effectiveLayoutMirror(false), isMirrorImplicit(true), - inheritMirrorFromParent(false), inheritMirrorFromItem(false), keyHandler(0), - mWidth(0), mHeight(0), mImplicitWidth(0), mImplicitHeight(0), attachedLayoutDirection(0), hadSubFocusItem(false) + inheritMirrorFromParent(false), inheritMirrorFromItem(false), hadFocus(false), hadActiveFocus(false), keyHandler(0), + mWidth(0), mHeight(0), mImplicitWidth(0), mImplicitHeight(0), attachedLayoutDirection(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; isDeclarativeItem = 1; @@ -289,6 +289,8 @@ public: bool isMirrorImplicit:1; bool inheritMirrorFromParent:1; bool inheritMirrorFromItem:1; + bool hadFocus:1; + bool hadActiveFocus:1; QDeclarativeItemKeyFilter *keyHandler; @@ -299,7 +301,6 @@ public: QDeclarativeLayoutMirroringAttached* attachedLayoutDirection; - bool hadSubFocusItem; QPointF computeTransformOrigin() const; @@ -312,22 +313,14 @@ public: } // Reimplemented from QGraphicsItemPrivate - virtual void subFocusItemChange() - { - bool hasSubFocusItem = subFocusItem != 0; - if (((flags & QGraphicsItem::ItemIsFocusScope) || !parent) && hasSubFocusItem != hadSubFocusItem) - emit q_func()->activeFocusChanged(hasSubFocusItem); - //see also QDeclarativeItemPrivate::focusChanged - hadSubFocusItem = hasSubFocusItem; - } - - // Reimplemented from QGraphicsItemPrivate virtual void focusScopeItemChange(bool isSubFocusItem) { - emit q_func()->focusChanged(isSubFocusItem); + if (hadFocus != isSubFocusItem) { + hadFocus = isSubFocusItem; + emit q_func()->focusChanged(isSubFocusItem); + } } - // Reimplemented from QGraphicsItemPrivate virtual void siblingOrderChange() { diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index a7c38ea8..4752ec32 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -530,39 +530,35 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) curLocalPos = event->scenePos(); } - const int dragThreshold = QApplication::startDragDistance(); - qreal dx = qAbs(curLocalPos.x() - startLocalPos.x()); - qreal dy = qAbs(curLocalPos.y() - startLocalPos.y()); - if (keepMouseGrab() && d->stealMouse) d->drag->setActive(true); bool dragX = drag()->axis() & QDeclarativeDrag::XAxis; bool dragY = drag()->axis() & QDeclarativeDrag::YAxis; - if (dragX && d->drag->active()) { - qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX; - if (x < drag()->xmin()) - x = drag()->xmin(); - else if (x > drag()->xmax()) - x = drag()->xmax(); - drag()->target()->setX(x); - } - if (dragY && d->drag->active()) { - qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY; - if (y < drag()->ymin()) - y = drag()->ymin(); - else if (y > drag()->ymax()) - y = drag()->ymax(); - drag()->target()->setY(y); + const qreal x = dragX + ? qBound(d->drag->xmin(), d->startX + curLocalPos.x() - startLocalPos.x(), d->drag->xmax()) + : d->startX; + const qreal y = dragY + ? qBound(d->drag->ymin(), d->startY + curLocalPos.y() - startLocalPos.y(), d->drag->ymax()) + : d->startY; + + if (d->drag->active()) { + if (dragX && dragY) + d->drag->target()->setPos(x, y); + else if (dragX) + d->drag->target()->setX(x); + else if (dragY) + d->drag->target()->setY(y); } if (!keepMouseGrab()) { - if ((!dragY && dy < dragThreshold && dragX && dx > dragThreshold) - || (!dragX && dx < dragThreshold && dragY && dy > dragThreshold) - || (dragX && dragY && (dx > dragThreshold || dy > dragThreshold))) { + const int dragThreshold = QApplication::startDragDistance(); + + if (qAbs(x - d->startX) > dragThreshold || qAbs(y - d->startY) > dragThreshold) { setKeepMouseGrab(true); d->stealMouse = true; + d->startScene = event->scenePos(); } } diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 1e68a7a1..240bc5d6 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -100,10 +100,10 @@ bool QSmoothedAnimation::recalc() s = (invert? qreal(-1.0): qreal(1.0)) * s; - if (userDuration > 0 && velocity > 0) { + if (userDuration >= 0 && velocity > 0) { tf = s / velocity; if (tf > (userDuration / qreal(1000.))) tf = (userDuration / qreal(1000.)); - } else if (userDuration > 0) { + } else if (userDuration >= 0) { tf = userDuration / qreal(1000.); } else if (velocity > 0) { tf = s / velocity; |