6#include <QtQuick/private/qquickitem_p.h>
7#include <QLoggingCategory>
70 return d->orientation;
133 return d->activeTimeout;
143 qWarning(
"activeTimeout must be positive");
171 return d->rotation *
d->rotationScale;
196 return d->rotationScale;
205 qWarning(
"rotationScale cannot be set to zero");
245 return d->propertyName;
251 if (
d->propertyName == propertyName)
254 d->propertyName = propertyName;
255 d->metaPropertyDirty =
true;
280 return d->targetScaleMultiplier;
309 return d->targetTransformAroundCursor;
315 if (
d->targetTransformAroundCursor == ttac)
318 d->targetTransformAroundCursor = ttac;
342 emit blockingChanged();
351 QWheelEvent *we =
static_cast<QWheelEvent *
>(
event);
358 if (!(we->angleDelta().x()) && !(we->pixelDelta().x()))
362 if (!(we->angleDelta().y()) && !(we->pixelDelta().y()))
367 auto &
point =
event->point(0);
382 const QWheelEvent *
event =
static_cast<const QWheelEvent *
>(ev);
386 qreal inversion = !
d->invertible &&
event->isInverted() ? -1 : 1;
388 event->angleDelta().y()) / 8;
389 d->rotation += angleDelta;
392 d->wheelEvent.reset(
event);
394 if (!
d->propertyName.isEmpty() &&
target()) {
398 qreal multiplier =
qPow(
d->targetScaleMultiplier, angleDelta *
d->rotationScale / 15);
400 const QPointF positionWas =
t->position();
401 const qreal scaleWas =
t->scale();
402 const qreal activePropertyValue = scaleWas * multiplier;
403 qCDebug(lcWheelHandler) <<
objectName() <<
"angle delta" <<
event->angleDelta() <<
"pixel delta" <<
event->pixelDelta()
404 <<
"@" <<
point.
position() <<
"in parent" << centroidParentPos
406 <<
"multiplier" << multiplier <<
"scale" << scaleWas
407 <<
"->" << activePropertyValue;
408 d->targetMetaProperty().write(
t, activePropertyValue);
409 if (
d->targetTransformAroundCursor) {
411 multiplier =
t->scale() / scaleWas;
413 centroidParentPos, positionWas,
QVector2D(), scaleWas, multiplier,
t->rotation(), 0);
414 qCDebug(lcWheelHandler) <<
"adjusting item pos" << adjPos <<
"in scene" <<
t->parentItem()->mapToScene(adjPos);
415 t->setPosition(adjPos);
418 const QPointF positionWas =
t->position();
419 const qreal rotationWas =
t->rotation();
420 const qreal activePropertyValue = rotationWas + angleDelta *
d->rotationScale;
422 qCDebug(lcWheelHandler) <<
objectName() <<
"angle delta" <<
event->angleDelta() <<
"pixel delta" <<
event->pixelDelta()
423 <<
"@" <<
point.
position() <<
"in parent" << centroidParentPos
425 <<
"->" << activePropertyValue;
426 d->targetMetaProperty().write(
t, activePropertyValue);
427 if (
d->targetTransformAroundCursor) {
430 centroidParentPos, positionWas,
QVector2D(),
431 t->scale(), 1, rotationWas,
t->rotation() - rotationWas);
432 qCDebug(lcWheelHandler) <<
"adjusting item pos" << adjPos <<
"in scene" <<
t->parentItem()->mapToScene(adjPos);
433 t->setPosition(adjPos);
436 qCDebug(lcWheelHandler) <<
objectName() <<
"angle delta" <<
event->angleDelta() <<
"scaled" << angleDelta
437 <<
"total" <<
d->rotation <<
"pixel delta" <<
event->pixelDelta()
440 if (
event->hasPixelDelta()) {
442 qCDebug(lcWheelHandler) <<
"changing target" <<
d->propertyName <<
"by pixel delta" << delta <<
"from" <<
event;
444 delta = angleDelta *
d->rotationScale;
445 qCDebug(lcWheelHandler) <<
"changing target" <<
d->propertyName <<
"by scaled angle delta" << delta <<
"from" <<
event;
452 qWarning() <<
"failed to read property" <<
d->propertyName <<
"of" <<
t;
455 switch (
event->phase()) {
457 qCDebug(lcWheelHandler) <<
objectName() <<
"deactivating due to ScrollEnd phase";
461 d->deactivationTimer.start(
qRound(
d->activeTimeout * 1000),
this);
474 d->metaPropertyDirty =
true;
481 d->deactivationTimer.stop();
487 if (
event->timerId() ==
d->deactivationTimer.timerId()) {
511 const QMetaObject *targetMeta =
q->target()->metaObject();
541#include "moc_qquickwheelhandler_p.cpp"
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QEventPoint class provides information about a point in a QPointerEvent.
Type type() const
Returns the event type.
QString objectName
the name of this object
\inmodule QtCore\reentrant
A base class for pointer events.
static QQuickItemPrivate * get(QQuickItem *item)
QPointF adjustedPosForTransform(const QPointF ¢roid, const QPointF &startPos, const QVector2D &activeTranslatation, qreal startScale, qreal activeScale, qreal startRotation, qreal activeRotation)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QInputDevice::DeviceTypes acceptedDevices
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
bool parentContains(const QEventPoint &point) const
Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(),...
virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point)
Returns true if the given point (as part of event) could be relevant at all to this handler,...
void setActive(bool active)
virtual void handleEventPoint(QPointerEvent *event, QEventPoint &point)
QMetaProperty metaProperty
QMetaProperty & targetMetaProperty() const
QQuickWheelHandlerPrivate()
\qmlsignal QtQuick::WheelHandler::wheel(WheelEvent event)
void setOrientation(Qt::Orientation orientation)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void setTargetScaleMultiplier(qreal targetScaleMultiplier)
bool isInvertible() const
\qmlproperty bool QtQuick::WheelHandler::invertible
void onActiveChanged() override
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
void activeTimeoutChanged()
void setInvertible(bool invertible)
qreal targetScaleMultiplier
void setBlocking(bool blocking)
void wheel(QQuickWheelEvent *event)
void setProperty(const QString &name)
void setTargetTransformAroundCursor(bool ttac)
void setActiveTimeout(qreal timeout)
bool isBlocking() const
\qmlproperty bool QtQuick::WheelHandler::blocking
void setRotation(qreal rotation)
void targetTransformAroundCursorChanged()
void orientationChanged()
void targetScaleMultiplierChanged()
void handleEventPoint(QPointerEvent *event, QEventPoint &point) override
bool isTargetTransformAroundCursor() const
\qmlproperty bool QtQuick::WheelHandler::targetTransformAroundCursor
void rotationScaleChanged()
void setRotationScale(qreal rotationScale)
void onTargetChanged(QQuickItem *oldTarget) override
Qt::Orientation orientation
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toLocal8Bit() const &
The QVector2D class represents a vector or vertex in 2D space.
Combined button and popup list for selecting options.
@ MouseEventNotSynthesized
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLbitfield GLuint64 timeout
[4]
GLdouble GLdouble GLdouble GLdouble q
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent