summaryrefslogtreecommitdiff
path: root/src/quick/handlers
Commit message (Collapse)AuthorAgeFilesLines
* Quick: Update documentation of TapHandler to reflect renamed enumDavid Edmundson2023-05-051-1/+1
| | | | | | | | | PointerDevice.GenericPointer was the enum value in Qt5, but in Qt6 this changed to PointerDevice.Generic Pick-to: 6.2 6.5 Change-Id: Ic5e4a5fe5fd91f7478d00e0d2c643b99eaa7ab14 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove reference to QQuickPointerScrollEvent in documentationMatthias Rauter2023-04-201-1/+1
| | | | | | | | It does not exist in Qt6 and was apparently replaced by WheelEvent. Pick-to: 6.5 Change-Id: I6b833e664d8e5e5d6e2bd23ed90695d43073decd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use correct names for QEventPoint::State, PointerDevice::GrabTransitionShawn Rutledge2023-04-141-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Qt::TouchPointState is not the actual type here, and we should not encourage e.g. making a comparison between eventPoint.state and Qt.TouchPointMoved in an onGrabChanged handler. The equivalence is an internal detail; and eventPoint can come from any pointing device, not only from a touchscreen. QEventPoint is a Q_GADGET; we keep the registration to expose it as a value type (eventPoint). But such types cannot be created in QML, and we also need to give it an uppercase name to scope the enum values that it declares: that's a new foreign namespace called EventPoint. So it's possible to compare an eventPoint instance's state property against EventPoint.Pressed, and so on. Also show complete QML syntax in the \value tables where PointerDevice::GrabTransition is emitted to QML, namely PointerDevice::grabChanged and PointerHandler::grabChanged. Amends b43a873264d012dc0a0e574ea53335a40af8aa38 Task-number: QTBUG-102160 Change-Id: If1a97f21d8e005e3692298b8512f7f8b56a92c97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix TapHandler signals in combination with exclusiveSignalsShawn Rutledge2023-04-112-20/+29
| | | | | | | | | | | | | TapHandler does not emit any singleTapped or doubleTapped signals after emitting it once, if exclusiveSignals is set to `SingleTap | DoubleTap`. This change corrects the behavior by resetting m_tapCount properly. Fixes: QTBUG-111800 Pick-to: 6.5 Change-Id: Ice7af2f41c2f30448004033d8330e733abe44110 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix PinchHandler.persistentTranslation; test cumulative native gesturesShawn Rutledge2023-04-112-27/+17
| | | | | | | | | | | | | | | | | | | | | Since we do not want persistentTranslation to be always the same as target.position, clearly we cannot use xAxis/yAxis to store the initial target position: thus the startPos() function was wrong, and is now removed. We need to store it in a separate m_startTargetPos variable like DragHandler does, and as PinchHandler did before 7867a683fcb938939fb2837a26ac8e1941e3fe08. Add an internal doc comment to clarify the arguments to QQuickItemPrivate::adjustedPosForTransform(). tst_QQuickPinchHandler::cumulativeNativeGestures() now checks the result of adjustedPosForTransform(): how far the target item moved. Pick-to: 6.5 Fixes: QTBUG-111220 Change-Id: I04237cb82a1abaaeab873a0d887acaf322f262ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* doc: Customize and update docs for PointHandlerShawn Rutledge2023-03-142-3/+125
| | | | | | | | | | | | | | | | Many of the inherited docs were inappropriate or insufficiently specific to PointHandler. Now we have more snippets with more ideas for how it can be used. As a drive-by, fix a typo in the docs for PointerDeviceHandler::acceptedPointerTypes and add a link to the new PointerDevice page added in e283c05af745210d4a1f6c0aa9c33bf4da23a1e0 Pick-to: 6.2 6.4 6.5 6.5.0 Fixes: QTBUG-74020 Fixes: QTBUG-106878 Change-Id: I028e1577ac5d4ef0b927c94259d6ab25b6028885 Reviewed-by: Doris Verria <doris.verria@qt.io>
* Don't emit doubleTapped when the buttons are differentMatthias Rauter2023-03-091-4/+8
| | | | | | | | | | | | A left-click followed by right-click was interpreted as a double-click. This is different from what I am used to and different from what I expect. This patch changes the behavior such that only clicks of the same button are interpreted as double click. Pick-to: 6.2 6.4 6.5 6.5.0 Fixes: QTBUG-111557 Change-Id: Id0d83ca66944497710d8f659ed5a6d1e4260a2d9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* TapHandler ExclusiveSignal flags: start with 1Shawn Rutledge2023-03-071-2/+2
| | | | | | | | | | | 1 << 1 is 2 of course, not 1, and there's no reason to avoid using the LSB here. Duh. Amends d3f2c6ac4205bbe5a1c7174965dbce6f90972be3 Pick-to: 6.5 6.5.0 Change-Id: If8d231d6dc82f8d833703ca7a75247ddae6b38c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Remove duplicate words (typos)Andreas Eliasson2023-03-072-2/+2
| | | | | | Pick-to: 6.5 6.4 6.2 Change-Id: Ibd29739b894598e5d7837ed5f9150e08ca07fa35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Document the Pointer Handlers exampleShawn Rutledge2023-03-026-6/+8
| | | | | | | | | | | Animated gifs were captured with byzanz-record, then converted to webp: gif2webp -lossy -min_size -q 40 -m 6 -mt -metadata none in.gif -o out.webp Pick-to: 6.2 6.4 6.5 Fixes: QTBUG-96915 Change-Id: Iee2f4ef774de7862d93c7e4cdf7b2b5e0553bec4 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
* doc: Add snippets and animations illustrating TapHandler.GesturePolicyShawn Rutledge2023-03-021-43/+88
| | | | | | | | | | | | | | | | | | | | | | People are constantly confused by GesturePolicy and its default value, so we really need a "glanceable" reference in the docs to show the differences between use cases. Also clarify the pitfalls with the default DragThreshold value. We switch from the \value tag to a 2-column \table because the \image would otherwise break the table, and also because it saves space and acts as a meaningful reminder to have the animation right under the enum value that is being documented. Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-70397 Task-number: QTBUG-73262 Task-number: QTBUG-100534 Task-number: QTBUG-107239 Task-number: QTBUG-111310 Change-Id: I1ff45f58a8a8edf55f4a8696d881aa9e0bedcfe3 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* doc: remove docs for PinchHandler.acceptedButtonsShawn Rutledge2023-03-021-0/+7
| | | | | | | | Mouse buttons are irrelevant to PinchHandler, of course. Pick-to: 6.2 6.4 6.5 Change-Id: Idfe65d3408ff3a33314979174a886f3e51f2eb7b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* doc: remove docs for HoverHandler.dragThresholdShawn Rutledge2023-03-021-0/+7
| | | | | | | | | Like acceptedButtons, HoverHandler.dragThreshold is irrelevant. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-95395 Change-Id: I059e99449cff946b2caa945022b1f4bd4d2f845b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* doc: Update QML eventPoint; fix GrabTransition linkShawn Rutledge2023-02-216-29/+29
| | | | | | | | | | | | | | | | | | | | Amends outdated stuff from 507efe5a8a2390813fb620a91b0b3b6b383f599d and c248a32fe69dfe1c685105d0c6aeaeb15d7ba29f. "eventPoint" should now always link to docs added in b43a873264d012dc0a0e574ea53335a40af8aa38. Replace the phrase "event point" with a link to the QML eventPoint value type. QPointingDevice is called PointerDevice in QML, so the GrabTransition enum ought to be found in those docs, in theory, for use in the PointerHandler::grabChanged doc. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-102160 Task-number: QTBUG-104761 Change-Id: I5d1a8dedd9d98e6dee3fbca457aa38f42ea7bfb1 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* TapHandler: ignore untracked moving points; treat touchpad as mouseShawn Rutledge2023-02-212-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | TapHandler must decide on press whether it's interested in tracking a particular point further, to see if a qualifying tap occurs, and should only care about those points it decided to track. But if it did not decide to track it, wantsEventPoint() should never care about the point movement after press; nor about hovering points either. The line in QQuickPointerDeviceHandler::wantsPointerEvent() checking pointingDevice()->pointerType() != Finger was also making touchpad behavior inconsistent with mouse behavior, which is why this bug appeared on macOS but not on Linux: QQuickPointerDeviceHandler needs to care about the incoming event's buttons on all devices except touchscreens. It's probably been causing other symptoms on touchpads since a97760a336c597327cb82eebc9f45c793aec32c9. For the test, a05cbaaae505dba2546c593e22fe2f9047c0de4b restored the cumulative native gesture scaling as it should be: so if we try to scale by 1.1 twice in a row, the result is it's scaled by 1.21. Pick-to: 6.2 6.4 6.5 Fixes: QTBUG-108896 Change-Id: I3da8878648b89cce5d1a48fa02dffaefead2ac90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Doris Verria <doris.verria@qt.io>
* Fix dummy variable in QQuickPinchHandler::setPersistentScaleShawn Rutledge2023-02-211-3/+3
| | | | | | Pick-to: 6.5 Change-Id: Iac2cecbda2eba15d6b11026b172cd79c3bb2463c Reviewed-by: Doris Verria <doris.verria@qt.io>
* Fix and test PinchHandler native-gesture scalingShawn Rutledge2023-02-171-1/+1
| | | | | | | | | | | | We didn't have test coverage for several gesture events in a row (the usual case in reality), nor for RotateNativeGesture at all. Amends a432970b258edb9ff041d221b2155df30cad4799 which incorrectly treated QNativeGestureEvent::value() as an absolute zoom rather than a delta. Pick-to: 6.5 Fixes: QTBUG-111204 Change-Id: Ib95cab5cd3f97229abac1668e59d20ce50d24975 Reviewed-by: Doris Verria <doris.verria@qt.io>
* doc: Rename QML type HandlerPoint to handlerPointShawn Rutledge2023-02-174-18/+18
| | | | | | | | | | | | | | It's a Q_GADGET value type so it needs a lowercase name. Link eventPoint to handlerPoint to help reduce confusion. There's already a link in the other direction. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-104761 Task-number: QTBUG-104570 Change-Id: I962d2d44690ec2f75190e07be7489eb3883d0657 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Remove dead code in DragHandlerShawn Rutledge2023-02-172-13/+0
| | | | | | | | | Left intact since 124181973f586a67990c9a68e25a3642623b998a but could have been removed some time ago, because handlePointerEventImpl() needs to call enforceAxisConstraints() with an adjusted position. Change-Id: I79bd5c1ae3394838a22b992e65f1a9717926e0df Reviewed-by: Doris Verria <doris.verria@qt.io>
* doc: Add the handlerPoint.device propertyShawn Rutledge2023-02-171-0/+7
| | | | | | | | | | Amends a1c91787264f6f535b5cf094b57ee53058856df4 Task-number: QTBUG-76381 Pick-to: 6.2 6.4 6.5 Change-Id: I7fdd15abbe15805815f5d2b2fc298501e1ab34d7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Remove Q_REVISION from "new" PinchHandler signalsShawn Rutledge2023-02-121-3/+3
| | | | | | | | | | | | | | | | | | They were added in a432970b258edb9ff041d221b2155df30cad4799; however, although we had the updated() signal being reused as the notifier for several properties before that, the QML engine provided synthetic signals matching the naming convention. We had Q_PROPERTY(qreal scale READ scale NOTIFY updated) and it was already possible to write onScaleChanged: in QML anyway. So in that sense, scaleChanged, rotationChanged and translationChanged are not new, and marking them with Q_REVISION made them unavailable to QML code that was already using older import versions. We have to avoid the Q_REVISION to keep QML source compatibility. Fixes: QTBUG-109637 Pick-to: 6.5 Change-Id: If72b566b1e261d0fec1b1e056eec558f263758c4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix [-Wmicrosoft-include] clang-cl warningsPeter Varga2022-12-165-12/+17
| | | | | Change-Id: I49ccce92e470897fa530bab0335cf49b99d231bf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Stop using deprecated QQuickPinchHandler functions and signalsIvan Solovev2022-12-161-1/+2
| | | | | | | | | Amends a432970b258edb9ff041d221b2155df30cad4799. Task-number: QTBUG-109392 Pick-to: 6.5 Change-Id: I394f2c4b3dc430bbaa2cb55081b6047160ea291b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Remove QQuickDragAxis::persistentValue and changed signal for nowShawn Rutledge2022-12-164-29/+12
| | | | | | | | | | | | | | | | It's better to avoid releasing with this new property until we are sure we know its proper meaning. So far it seems that it should end up being identical to the target-item property to be set, rather than e.g. DragHandler.xAxis.persistentValue being the same as DragHandler.persistentTranslation.x. That is, it's an item property's current value, not a delta to adjust the value. Reverts part of 7867a683fcb938939fb2837a26ac8e1941e3fe08 Pick-to: 6.5 Task-number: QTBUG-109373 Change-Id: Id3a78332194c714e75b69cbaef111229d75318e0 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Pointer handlers: don't emit canceled() when an extra button interruptsShawn Rutledge2022-12-151-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the intention is that a handler should react only to the left mouse button (by default, acceptedButtons == Qt.LeftButton), and the user presses the right button while the handler is already active, it de-activates, because wantsPointerEvent() returns false. But now it will no longer emit canceled() in that case. The docs for the canceled signal say "If this handler has already grabbed the given point, this signal is emitted when the grab is stolen by a different Pointer Handler or Item." But in this case the handler gives up its grab voluntarily, it's not being stolen by anything else. Probably we were emitting canceled because it's intuitive that the gesture is being canceled because something weird happened. But that's not the documented reason for emitting this signal, and it's perhaps inconsistent with the fact that dragging can be resumed. The mechanism for emitting when another handler or item takes over the grab begins in QPointingDevicePrivate::setExclusiveGrabber(), which emits grabChanged(), which is connected to QQuickDeliveryAgentPrivate::onGrabChanged(), which will call onGrabChanged() on the handler, and the base class implementation QQuickPointerHandler::onGrabChanged() will emit canceled(). At least in this case a handler does not need to decide on its own to emit. [ChangeLog][QtQuick][Event Handlers] A Pointer Handler no longer emits the canceled() signal when it deactivates due to violating conditions (such as pressing the right button when acceptedButtons == LeftButton). Fixes: QTBUG-102201 Pick-to: 6.5 Change-Id: Ibe67c8f2a5e44d96df3a788ca1ee4e43f7de658d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PinchHandler: don't confine activeScale and activeRotation to min/maxShawn Rutledge2022-12-123-9/+6
| | | | | | | | | | | | | | | | | | | | | It was inconsistent to do this for the active values only on one handler's axis objects. The main purpose of the minimum and maximum values is to avoid modifying the target item's respective properties beyond reasonable limits, whereas the active values are supposed to be derived directly from the gesture. If the users modify target properties based on active values, or based on the activeValueChanged signal argument, they need to enforce the property limits themselves. [ChangeLog][QtQuick][Event Handlers] PinchHandler's activeScale (which was previously called scale) is no longer restricted to the range between minimumScale and maximumScale: these limits apply only to persistentScale. Likewise, activeRotation (previously rotation) is no longer restricted to the range between minimumRotation and maximumRotation. Change-Id: I5757e3d931e6165c81cecff19fc30b50033d89ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Deprecate PinchAxis minimum/maximum scale and rotation propertiesShawn Rutledge2022-12-102-4/+12
| | | | | | | | | | | | | ...in favor of the minimum and maximum properties in the new scaleAxis and rotationAxis. [ChangeLog][QtQuick][Event Handlers] PinchHandler.minimumScale, maximumScale, minimumRotation and maximumRotation are deprecated in favor of the minimum and maximum properties in the new scaleAxis and rotationAxis. Change-Id: Iecaa4321d5ea7ebf7131b1e84fbc83ab29ad506e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Standardize Drag/PinchHandler active/persistent scale, rotation, translationShawn Rutledge2022-12-104-83/+272
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PinchHandler.scale is persistent between gestures, whereas rotation and translation were active-gesture properties; that wasn't consistent. We fixed up DragHandler in just this way in 6.2. The translationChanged() signal now comes with a vector delta, which is often useful when writing an onTranslationChanged JS handler. Likewise, scaleChanged() and rotationChanged() come with qreal deltas. The scaleChanged() delta is multiplicative rather than additive, because an additive delta would not be useful in cases when some target item's scale can be adjusted by alternative means: you need to multiply it in your onScaleChanged function. Now that PinchHandler has 4 axes as grouped properties, some properties in the handlers themselves begin to look redundant; but at least the translation properties are useful to group x and y together. So in this patch we continue to follow the pattern that was set in 60d11e1f69470d588666b76092cd40ae5644a855. PinchHandler.scale is equivalent to persistentScale, whereas rotation is equivalent to activeRotation; so we have a reason to deprecate those properties, as in ea63ee523377bd11b957a9e74185792edd9b32e8. The persistent values have setters, to provide another way for applications to compensate when the values are adjusted by other means, as an alternative to incremental changes via a script such as rotationAxis.onValueDelta, onRotationChanged etc. [ChangeLog][QtQuick][Event Handlers] PinchHandler.activeTranslation now holds the amount of movement since the pinch gesture began. PinchHandler.persistentTranslation holds the accumulated sum of movement that has occurred during subsequent pinch gestures, and can be set to arbitrary values between gestures. Likewise, activeScale, persistentScale, activeRotation and persistentRotation follow the same pattern. The scaleChanged, rotationChanged, and translationChanged signals include delta arguments, which are useful for incrementally adjusting a non-default item property when the target is null. Fixes: QTBUG-76739 Task-number: QTBUG-94168 Change-Id: I6aaa1aa3356b85e6d27abc64bfa67781ecb4f062 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add PinchHandler.scaleAxis, rotationAxis; hold values in axesShawn Rutledge2022-12-106-115/+288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pointer Handlers that manipulate target item properties should now use QQuickDragAxis consistently to: - enforce minimum and maximum values - hold the persistent and active values - make those available via properties - emit a new activeValueChanged(delta) signal when the value changes, so that it's possible to incrementally update a target item property in JS (onValueDelta: target.property += delta) In the pinchHandler.qml example, you can use the PinchHandler to adjust 4 properties of one Rectangle independently (it requires coordination). m_boundedActiveValue controls whether m_activeValue will be kept between minimum and maximum. For rotation, tst_QQuickPinchHandler::scaleNativeGesture() expects it to be, although that seems questionable now, and may be addressed later. [ChangeLog][QtQuick][Event Handlers] PinchHandler now has scaleAxis and rotationAxis grouped properties, alongside the existing xAxis and yAxis; and all of these now have activeValue and persistentValue properties. The activeValueChanged signal includes a delta value, giving the incremental change since the previous activeValue. The persistentValue is settable, in case some target item property can be adjusted in multiple ways: the handler's stored value can then be synced up with the item property value after each external change. These features are also added to DragHandler's xAxis and yAxis properties. Task-number: QTBUG-68108 Task-number: QTBUG-76380 Task-number: QTBUG-76379 Task-number: QTBUG-94168 Change-Id: I78a5b43e9ba580448ef05054b6c4bc71b1834dd6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* doc: Add note to PinchHandler.translation property about macOS trackpadShawn Rutledge2022-11-301-0/+3
| | | | | | | | | Translation doesn't happen with trackpad native gestures. Fixes: QTBUG-109002 Pick-to: 5.15 6.2 6.4 Change-Id: I7d42b0d737d45405732a389560a6c77624831c9e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* PinchHandler null target: remember accumulated scale between pinchesShawn Rutledge2022-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | This restores behavior from b4d31c9ff5f0c5821ea127c663532d9fc2cae43e which got broken in fc636af3a723ee8b4ee42cf71864ae0df5ca4621. As documented, PinchHandler.scale is the accumulated scale that would be applied to the target item (even if there is no target), whereas activeScale is the scale during one pinch gesture. After the first gesture, these two values are supposed to diverge, even if there is no target; that way you can bind scale to some property, to scale something else in the same way that PinchHandler would normally scale its target. Pick-to: 6.2 6.4 Fixes: QTBUG-108549 Task-number: QTBUG-68941 Task-number: QTBUG-92064 Change-Id: I32ff37e394fd8466128603eddd5697ba1cc1a0ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add FOREIGN declaration for QEventPointSami Shalayel2022-11-112-5/+5
| | | | | | | | | | | | Add a foreign declaration to QEventPoint such that qml compilers can work correctly with it. Also fix the links to eventPointer in the documentation, and duplicate the list of properties of the C++ api. Fixes: QTBUG-107624 Change-Id: I11c4a4a416a40d40fc7ce45d7f894406035a6d87 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickHoverHandler: listen for parent changes, and update hasHoverInChildRichard Moe Gustavsen2022-10-313-13/+44
| | | | | | | | | | | | | | | | | | | A QQuickHoverHandler is normally created by the QML engine, but can sometimes also be created directly from C++. And for the latter case, QQuickHoverHandler::componentComplete() will not be called. This causes a problem, since it takes care of subscribing for hover events on the parent item. To support creating hover handlers from c++, we therefore need to also subscribe to hover events from the constructor. Moreover, since the parentItem can change at runtime, we also need a virtual function that informs it when the parent item changes, so that we can remove hover subscription from the old parent, and subscribe for it on the new parent. Pick-to: 6.4 Change-Id: I52f3cd16d6bbfbbe2e4c3c019efdc7f06c5f2c31 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTapHandler: add missing Q_DECLARE_OPERATORS_FOR_FLAGSRichard Moe Gustavsen2022-10-241-0/+2
| | | | | | | | ...so that you can write: tapHandler->setExclusiveSignals(QQuickTapHandler::SingleTap | QQuickTapHandler::DoubleTap); Change-Id: Idef4b3afdbb9ce4c50cd5ad2d1b4c16c231b61e1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* TapHandler: don't cancel on releaseShawn Rutledge2022-10-231-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous fix for QTBUG-94012 was in conflict with the idea that TapHandler could be used to augment behavior on other event-handling Items: it would emit canceled rather than tapped whenever there was a rival exclusive grabber, unless that grabber was an event-filtering item. The bug I was trying to fix was in the Qt Quick 3D dynamictexture example: if you click on a TextEdit in a subscene to set the cursor position, a TapHandler on the entire View3D should not react, because something in the subscene was already reacting. The event accepted flag also does not stop propagation in other subscenes. This bug should rather be fixed by changing gesturePolicy so that the outer TapHandler does try to take the exclusive grab, and then it is stolen by TextEdit because TapHandler's default grabPermissions include ApprovesTakeOverByAnything. Handlers in general are useful to augment existing behavior of Items. At least gesturePolicy and grabPermisions are available to fine-tune the stealing of the exclusive grab; but when TapHandler is using a stealthy passive grab (which it does with the default gesturePolicy), we don't want to prevent it from reacting. This reverts the TapHandler changes from commit d342b8f77658537c4fd3318982d2ae7a964b6426 but keeps the autotest, which is now improved by checking multiple gesturePolicy values and checking for the canceled signal if the policy specifies an exclusive grab. Also call QEventPoint::setAccepted(false) if the gesturePolicy is DragThreshold, because if the TapHandler is getting by with a passive grab, it should not interfere with delivery to other items. This makes touch behavior more consistent with mouse behavior. Pick-to: 6.4 Fixes: QTBUG-99887 Fixes: QTBUG-105609 Task-number: QTBUG-94012 Change-Id: Ib8f80d4e6523b01ef204a69f1f30f010bee6eb8f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* qquickpointerhandler_p.h: Clean up includesFabian Kosmale2022-10-1916-25/+19
| | | | | | | | | | | | | | | | | The referenced bug report specifically complained about warnings caused by including qquickpointerhandler_p.h. All of those -Wshorten-64-to-32 warnings come from headers that aren't strictly needed for qquickpointerhandler_p, though. So fix the issue by only including what is actually need, which also slightly improves compile times. This requires adding a few transitive includes in select places. As a drive-by, remove the unneeded QML_DECLARE_TYPE. Fixes: QTBUG-105055 Change-Id: I24d78e7131771a4bbcb402e6838a5a9a11abbbec Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add TapHandler.exclusiveSignals to enable single/double tap exclusivityShawn Rutledge2022-10-192-6/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If exclusiveSignals == NotExclusive (the default), behavior remains as it was: singleTapped() and doubleTapped() are emitted as the taps occur, so it's not very useful to react on singleTapped() if you mean to distinguish these two cases. If exclusiveSignals == SingleTap, the doubleTapped signal will not be emitted at all, and therefore singleTapped can be emitted immediately and unambiguously. If exclusiveSignals == DoubleTap, the singleTapped signal will not be emitted at all, and therefore doubleTapped can be emitted immediately and unambiguously. If exclusiveSignals == SingleTap | DoubleTap, we must wait qApp->styleHints()->mouseDoubleClickInterval() milliseconds after a tap is detected before emitting either signal, so that they are distinct and can be used to drive behavior that should not occur in other cases. A triple-tap will not trigger either signal. [ChangeLog][QtQuick][Event Handlers] TapHandler.exclusiveSignals now lets you make the singleTapped and doubleTapped signals exclusive. Task-number: QTBUG-65088 Fixes: QTBUG-107264 Change-Id: Ifb2c4b72759246c64b3bfa2f776c28266806b985 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* doc: Change \qmlproperty enum to enumerationShawn Rutledge2022-10-141-1/+1
| | | | | | | | It was mostly consistent already, but not in these two cases. Pick-to: 6.2 6.4 Change-Id: I5ed7b9cf7fd7e7dc6f4b43085035b375e1e9cc1e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix typo in docsShawn Rutledge2022-10-081-1/+1
| | | | | | | | I can guess which keyboard I wrote that with. Pick-to: 6.4 Change-Id: I9b99e142a117b8c7dd81399e65659fee93f95104 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-074-7/+7
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Ensure that item appearance is updated when hover state changesShawn Rutledge2022-09-271-2/+8
| | | | | | | | | | | | | | If a HoverHandler is enabled/disabled, or a MouseArea.hoverEnabled is set or unset, its parent may need to change its hovered appearance. Marking an item dirty is enough to ensure that flushFrameSynchronousEvents() will be called, in case there was no other event or property change to trigger that. Pick-to: 6.4 Task-number: QTBUG-46460 Fixes: QTBUG-106704 Change-Id: I5ced5f673baf387bbd0ee678e120538d1bb61c0e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickHoverHandler: setHasHoverInChild to false when disabledRichard Moe Gustavsen2022-09-164-1/+27
| | | | | | | | | | | | | | | | Toggle setHasHoverInChild in sync with the handler being enabled. This fixes a bug: if a HoverHandler is hovered, and somehow the enabled property is programmatically set to false with no mouse moveement and without any other scenegraph changes (i.e. no item gets marked dirty and therefore flushFrameSynchronousEvents() doesn't run), its hovered property now changes to false immediately, as it should. The DA will get less items to traverse, so this is also an optimization. Pick-to: 6.4 Change-Id: I24be7d25ee15180fff010cc1c532266cd6e73ffb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* DA: ignore disabled HoverHandlers when delivering hover eventsRichard Moe Gustavsen2022-09-161-3/+1
| | | | | | | | | | | | | | | | | | | | | According to the documentation for HoverHandler::enabled, a disabled hover handler will not accept any mouse events. It therefore follows naturally that a disabled HoverHandler should also not affect event propagation elsewhere. This patch will change the implementation, so that we don't deliver hover events to HoverHandlers that are disabled. This also means that disabled HoverHandlers will no longer block propagation to its siblings. [ChangeLog][QtQuick][HoverHandler] Disabled hover handlers will no longer receive hover events, or block siblings from being hovered. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-106548 Change-Id: I7f2e459ba39f1e23cdb13bf94f8754e185dcd0c1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: Enforce min/max scale limits with native gesturesShawn Rutledge2022-09-011-0/+1
| | | | | | | | | | | So far the qBound() using m_minimumScale and m_maximumScale was only applied for normal pointer events: there were no limits when using a touchpad that sends native gestures. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106110 Change-Id: Ibf8d955e5f1dac517e0a3e9588fb117d83f443a6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize QQuickMultiPointHandler::grabPoints slightlyShawn Rutledge2022-09-011-1/+1
| | | | | | | | Clazy reminded me about the usual const-ref optimization in a range for. Pick-to: 6.4 6.3 6.2 Change-Id: I2eafb49d341758829ce8fc43a8e5432a2d6dd4f6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Ensure that multiple HoverHandlers can react to multiple device typesShawn Rutledge2022-08-253-0/+5
| | | | | | | | | | | | | | | | | | | | | | | 1c44804600ad3dbeb60d1f5209ce9cf937d30ab3 had some known incompleteness in QQuickItemPrivate::effectiveCursorHandler because it couldn't be finished in Qt 5; but HoverHandlers with different acceptedDevices and acceptedPointerTypes were working together in Qt 6.0 and 6.1 to an extent. Perhaps for this case it helped that HoverHandlers got passive grabs, but we stopped that in bbcc2657fa0dbf715e6db7d675662e4be94a1e04. So now, as with mouse events, we need to ensure that when a HoverHandler detects a particular stylus device in a QTabletEvent and chooses a different cursor, it is applied to the window. At this time, since QQuickDeliveryAgentPrivate::deliverHoverEvent() sends a synth-mouse event, it's not suitable for tablet hover; so we depend on correct implementation of allPointsGrabbed() to ensure that QQuickDeliveryAgentPrivate::deliverUpdatedPoints() will visit all the HoverHandlers, in this case only. Pick-to: 6.3 6.4 Fixes: QTBUG-101932 Change-Id: Ia8f31610e9252825afc7151be58765ac5217b0e8 Reviewed-by: Doris Verria <doris.verria@qt.io>
* doc: Add missing PointerHandler.CanTakeOverFromItems enum valueShawn Rutledge2022-08-161-0/+2
| | | | | | | | Amends 0a3eec60cab3c453b378ee45ac335e0dc2951f4b Pick-to: 6.2 6.3 6.4 5.15 Change-Id: Iae9d1b2b68dc48a52adf0438a09af8e53f5527f1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QtQuick: Fix type issues with QQuickPointHandlersMaximilian Goldstein2022-08-013-4/+6
| | | | | | | Now uses the proper enums and exposes all necessary classes to QML. Change-Id: I04cc390469c5811ad4683454b460829fa1e86582 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove Qt key words from header filesYuhang Zhao2022-07-193-3/+3
| | | | | | | | | | | So that users can use QT_NO_KEYWORDS when linking against QtDeclarative, even if they are using private headers. Docs, examples and tools are not touched because it's not necessary. Pick-to: 6.4 Change-Id: Idc30797074aaa72576429ebdaaf915d7f5acf84e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>