aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickwheelhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/handlers/qquickwheelhandler.cpp')
-rw-r--r--src/quick/handlers/qquickwheelhandler.cpp79
1 files changed, 35 insertions, 44 deletions
diff --git a/src/quick/handlers/qquickwheelhandler.cpp b/src/quick/handlers/qquickwheelhandler.cpp
index 7045f10d8e..34110ff6cc 100644
--- a/src/quick/handlers/qquickwheelhandler.cpp
+++ b/src/quick/handlers/qquickwheelhandler.cpp
@@ -1,44 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickwheelhandler_p.h"
#include "qquickwheelhandler_p_p.h"
+#include <QtQuick/private/qquickitem_p.h>
#include <QLoggingCategory>
#include <QtMath>
@@ -81,7 +46,7 @@ Q_LOGGING_CATEGORY(lcWheelHandler, "qt.quick.handler.wheel")
WheelHandler handles only a rotating mouse wheel by default; this
can be changed by setting acceptedDevices.
- \sa MouseArea, Flickable
+ \sa MouseArea, Flickable, {Qt Quick Examples - Pointer Handlers}
*/
QQuickWheelHandler::QQuickWheelHandler(QQuickItem *parent)
@@ -91,7 +56,7 @@ QQuickWheelHandler::QQuickWheelHandler(QQuickItem *parent)
}
/*!
- \qmlproperty enum QtQuick::WheelHandler::orientation
+ \qmlproperty enumeration QtQuick::WheelHandler::orientation
Which wheel to react to. The default is \c Qt.Vertical.
@@ -119,7 +84,7 @@ void QQuickWheelHandler::setOrientation(Qt::Orientation orientation)
\qmlproperty bool QtQuick::WheelHandler::invertible
Whether or not to reverse the direction of property change if
- QQuickPointerScrollEvent::inverted is true. The default is \c true.
+ \l QWheelEvent::inverted is \c true. The default is \c true.
If the operating system has a "natural scrolling" setting that causes
scrolling to be in the same direction as the finger movement, then if this
@@ -354,6 +319,29 @@ void QQuickWheelHandler::setTargetTransformAroundCursor(bool ttac)
emit targetTransformAroundCursorChanged();
}
+/*!
+ \qmlproperty bool QtQuick::WheelHandler::blocking
+ \since 6.3
+
+ Whether this handler prevents other items or handlers behind it from
+ handling the same wheel event. This property is \c true by default.
+*/
+bool QQuickWheelHandler::isBlocking() const
+{
+ Q_D(const QQuickWheelHandler);
+ return d->blocking;
+}
+
+void QQuickWheelHandler::setBlocking(bool blocking)
+{
+ Q_D(QQuickWheelHandler);
+ if (d->blocking == blocking)
+ return;
+
+ d->blocking = blocking;
+ emit blockingChanged();
+}
+
bool QQuickWheelHandler::wantsPointerEvent(QPointerEvent *event)
{
if (!event)
@@ -393,7 +381,8 @@ void QQuickWheelHandler::handleEventPoint(QPointerEvent *ev, QEventPoint &point)
return;
const QWheelEvent *event = static_cast<const QWheelEvent *>(ev);
setActive(true); // ScrollEnd will not happen unless it was already active (see setActive(false) below)
- point.setAccepted();
+ if (d->blocking)
+ point.setAccepted();
qreal inversion = !d->invertible && event->isInverted() ? -1 : 1;
qreal angleDelta = inversion * qreal(orientation() == Qt::Horizontal ? event->angleDelta().x() :
event->angleDelta().y()) / 8;
@@ -502,7 +491,7 @@ void QQuickWheelHandler::timerEvent(QTimerEvent *event)
}
/*!
- \qmlsignal QtQuick::WheelHandler::wheel(PointerScrollEvent event)
+ \qmlsignal QtQuick::WheelHandler::wheel(WheelEvent event)
This signal is emitted every time this handler receives an \a event
of type \l QWheelEvent: that is, every time the wheel is moved or the
@@ -535,7 +524,7 @@ QMetaProperty &QQuickWheelHandlerPrivate::targetMetaProperty() const
By default, this property is set to
\l{QInputDevice::DeviceType}{PointerDevice.Mouse}, so as to react only to
- events events from an actual mouse wheel.
+ events from an actual mouse wheel.
WheelHandler can be made to respond to both mouse wheel and touchpad
scrolling by setting acceptedDevices to
@@ -548,3 +537,5 @@ QMetaProperty &QQuickWheelHandlerPrivate::targetMetaProperty() const
*/
QT_END_NAMESPACE
+
+#include "moc_qquickwheelhandler_p.cpp"