aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp52
-rw-r--r--src/quicktemplates2/qquickscrollbar_p.h2
-rw-r--r--src/quicktemplates2/qquickscrollbar_p_p.h1
3 files changed, 55 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index cb5c0001..844bba3a 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);
}
@@ -616,6 +619,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 1b18c4ad..7bf8a9d3 100644
--- a/src/quicktemplates2/qquickscrollbar_p.h
+++ b/src/quicktemplates2/qquickscrollbar_p.h
@@ -134,6 +134,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;