diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-11 13:19:30 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-11 13:19:30 +0200 |
commit | 3408d28e3c058c620f4dfb167a1e25c3618fc90f (patch) | |
tree | f70f55faf78e89e2260f7464868c0feefbbf647a /src/quicktemplates2 | |
parent | 40f59da21a74b5999db90e1eb7073f292ac3e54e (diff) | |
parent | 880475bbe620a533db7b7b744e0b4c98fbf34d1b (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/quicktemplates2/qquickcontrol.cpp
Change-Id: I73a9946da4214dcb8c877e716af5a8bb64335f69
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 18 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollbar.cpp | 53 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollbar_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollbar_p_p.h | 1 |
4 files changed, 71 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 4adf80e0..95686360 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -467,12 +467,24 @@ bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item) #endif /* - Cancels incubation to avoid "Object destroyed during incubation" (QTBUG-50992) + Cancels incubation recursively to avoid "Object destroyed during incubation" (QTBUG-50992) */ +static void cancelIncubation(QObject *object, QQmlContext *context) +{ + const auto children = object->children(); + for (QObject *child : children) + cancelIncubation(child, context); + QQmlIncubatorPrivate::cancel(object, context); +} + void QQuickControlPrivate::destroyDelegate(QObject *delegate, QObject *parent) { - if (delegate && parent) - QQmlIncubatorPrivate::cancel(delegate, qmlContext(parent)); + if (!delegate) + return; + + QQmlContext *context = parent ? qmlContext(parent) : nullptr; + if (context) + cancelIncubation(delegate, context); delete delegate; } diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 6050149e..240f6601 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -165,6 +165,7 @@ QQuickScrollBarPrivate::QQuickScrollBarPrivate() moving(false), interactive(true), explicitInteractive(false), + touchId(-1), orientation(Qt::Vertical), snapMode(QQuickScrollBar::NoSnap), policy(QQuickScrollBar::AsNeeded) @@ -268,6 +269,7 @@ void QQuickScrollBarPrivate::handleRelease(const QPointF &point) pos = snapPosition(pos); q->setPosition(pos); offset = 0.0; + touchId = -1; q->setPressed(false); } @@ -275,6 +277,7 @@ void QQuickScrollBarPrivate::handleUngrab() { Q_Q(QQuickScrollBar); offset = 0.0; + touchId = -1; q->setPressed(false); } @@ -625,6 +628,7 @@ void QQuickScrollBar::mousePressEvent(QMouseEvent *event) Q_D(QQuickScrollBar); QQuickControl::mousePressEvent(event); d->handlePress(event->localPos()); + d->handleMove(event->localPos()); } void QQuickScrollBar::mouseMoveEvent(QMouseEvent *event) @@ -648,6 +652,55 @@ void QQuickScrollBar::mouseUngrabEvent() d->handleUngrab(); } +void QQuickScrollBar::touchEvent(QTouchEvent *event) +{ + Q_D(QQuickScrollBar); + switch (event->type()) { + case QEvent::TouchBegin: + if (d->touchId == -1) { + const QTouchEvent::TouchPoint point = event->touchPoints().first(); + d->touchId = point.id(); + d->handlePress(point.pos()); + } else { + event->ignore(); + } + break; + + case QEvent::TouchUpdate: + for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { + if (point.id() != d->touchId) + continue; + + d->handleMove(point.pos()); + } + break; + + case QEvent::TouchEnd: + for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { + if (point.id() != d->touchId) + continue; + + d->handleRelease(point.pos()); + } + break; + + case QEvent::TouchCancel: + d->handleUngrab(); + break; + + default: + QQuickControl::touchEvent(event); + break; + } +} + +void QQuickScrollBar::touchUngrabEvent() +{ + Q_D(QQuickScrollBar); + QQuickControl::touchUngrabEvent(); + d->handleUngrab(); +} + #if QT_CONFIG(quicktemplates2_hover) void QQuickScrollBar::hoverChange() { diff --git a/src/quicktemplates2/qquickscrollbar_p.h b/src/quicktemplates2/qquickscrollbar_p.h index 523e27f0..d7457876 100644 --- a/src/quicktemplates2/qquickscrollbar_p.h +++ b/src/quicktemplates2/qquickscrollbar_p.h @@ -139,6 +139,8 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseUngrabEvent() override; + void touchEvent(QTouchEvent *event) override; + void touchUngrabEvent() override; #if QT_CONFIG(quicktemplates2_hover) void hoverChange() override; diff --git a/src/quicktemplates2/qquickscrollbar_p_p.h b/src/quicktemplates2/qquickscrollbar_p_p.h index cbbef2c8..409b952b 100644 --- a/src/quicktemplates2/qquickscrollbar_p_p.h +++ b/src/quicktemplates2/qquickscrollbar_p_p.h @@ -88,6 +88,7 @@ public: bool moving; bool interactive; bool explicitInteractive; + int touchId; Qt::Orientation orientation; QQuickScrollBar::SnapMode snapMode; QQuickScrollBar::Policy policy; |