diff options
Diffstat (limited to 'src/quick/items/qquickmousearea.cpp')
-rw-r--r-- | src/quick/items/qquickmousearea.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 4bee4864d5..ddf34798d7 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -40,7 +40,9 @@ #include "qquickmousearea_p.h" #include "qquickmousearea_p_p.h" #include "qquickwindow.h" +#if QT_CONFIG(quick_draganddrop) #include "qquickdrag_p.h" +#endif #include <private/qqmldata_p.h> #include <private/qsgadaptationlayer_p.h> @@ -62,7 +64,7 @@ QQuickMouseAreaPrivate::QQuickMouseAreaPrivate() moved(false), stealMouse(false), doubleClick(false), preventStealing(false), propagateComposedEvents(false), overThreshold(false), pressed(nullptr), pressAndHoldInterval(-1) -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) , drag(nullptr) #endif #if QT_CONFIG(cursor) @@ -73,7 +75,7 @@ QQuickMouseAreaPrivate::QQuickMouseAreaPrivate() QQuickMouseAreaPrivate::~QQuickMouseAreaPrivate() { -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) delete drag; #endif #if QT_CONFIG(cursor) @@ -685,7 +687,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event) } else { d->longPress = false; d->saveEvent(event); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -712,7 +714,7 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) // ### can GV handle this for us? setHovered(contains(d->lastPos)); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) if (d->drag && d->drag->target()) { if (!d->moved) { d->targetStartPos = d->drag->target()->parentItem() @@ -759,8 +761,10 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) QPointF targetPos = d->drag->target()->position(); - if (d->drag->active()) + if (d->drag->active()) { d->drag->target()->setPosition(boundedDragPos); + d->lastPos = d->lastScenePos - mapToScene(position()); + } bool dragOverThresholdX = QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event, d->drag->threshold()); @@ -806,7 +810,7 @@ void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event) setPressed(event->button(), false, event->source()); if (!d->pressed) { // no other buttons are pressed -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -895,7 +899,7 @@ void QQuickMouseArea::wheelEvent(QWheelEvent *event) } QQuickWheelEvent &we = d->quickWheelEvent; - we.reset(event->posF().x(), event->posF().y(), event->angleDelta(), event->pixelDelta(), + we.reset(event->position().x(), event->position().y(), event->angleDelta(), event->pixelDelta(), event->buttons(), event->modifiers(), event->inverted()); we.setAccepted(d->isWheelConnected()); emit wheel(&we); @@ -916,7 +920,7 @@ void QQuickMouseArea::ungrabMouse() d->overThreshold = false; setKeepMouseGrab(false); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -999,7 +1003,7 @@ bool QQuickMouseArea::childMouseEventFilter(QQuickItem *i, QEvent *e) Q_D(QQuickMouseArea); if (!d->pressed && (!d->enabled || !isVisible() -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) || !d->drag || !d->drag->filterChildren() #endif ) @@ -1022,7 +1026,7 @@ void QQuickMouseArea::timerEvent(QTimerEvent *event) Q_D(QQuickMouseArea); if (event->timerId() == d->pressAndHoldTimer.timerId()) { d->pressAndHoldTimer.stop(); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) bool dragged = d->drag && d->drag->active(); #else bool dragged = false; @@ -1065,7 +1069,7 @@ void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value) Q_D(QQuickMouseArea); switch (change) { case ItemVisibleHasChanged: - if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) { + if (d->effectiveEnable && d->enabled && acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) { if (!d->hovered) { QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition; d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint()); @@ -1198,7 +1202,7 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS { Q_D(QQuickMouseArea); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) bool dragged = d->drag && d->drag->active(); #else bool dragged = false; @@ -1404,7 +1408,7 @@ void QQuickMouseArea::resetPressAndHoldInterval() */ -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(quick_draganddrop) QQuickDrag *QQuickMouseArea::drag() { Q_D(QQuickMouseArea); |