summaryrefslogtreecommitdiff
path: root/examples/quick/pointerhandlers
Commit message (Collapse)AuthorAgeFilesLines
* Examples: Use versioned CMake targets for Qt modulesKai Köhne2023-05-021-5/+5
| | | | | | | | | | | | Use e.g. Qt6::Core instead of Qt::Core. This is better matching the find_package(Qt6 ...) call, and also avoids issues that the versionless targets have. Pick-to: 6.5 Task-number: QTBUG-113277 Change-Id: Ib80f885e9f73fb9ad54b9e9b22cae2318877dc07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix button handling in MouseFeedbackSprite of pointerhandler exampleMatthias Rauter2023-04-201-4/+9
| | | | | | | | | | HoverHandler does not react to button presses. Images to indicate button presses are loaded but never shown because of this. This patch adds an additional PointHandler which reacts to button presses. Pick-to: 6.5 Change-Id: I60c1daef5144d7431605b0dc7dbedc0723a17fe0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change hierarchy level of MouseFeedbackSprite in pointerhandler exampleMatthias Rauter2023-04-211-2/+2
| | | | | | | | | | | Hover events are no longer propagated to siblings when they have been accepted by an item, at least for the time being. This patch changes the hierarchy such that it works either way. Fixes: QTBUG-111322 Pick-to: 6.5 Change-Id: Ied953a423954342c02e613af618be0784d6397ee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* handlers example: Add TapHandler single/doubleTapped signal feedbackShawn Rutledge2023-03-101-6/+28
| | | | | | | | | | | | | | | | | | | | | - reserve the borderBlink feedback for these signals: the flashAnimation feedback is enough to show the regular tapped signal - make the flashing border more obvious: wider on a lighter background - make the border even wider for a double-tap - just blink once; the 3-blink animation looked nice, like classic macOS, but was a bit disorienting if you are tapping multiple times and trying to count which signals got emitted - stop the animation before starting the double-tap animation, to avoid missing it: usually the double-click interval is less than 500ms Followup to d3f2c6ac4205bbe5a1c7174965dbce6f90972be3 Task-number: QTBUG-65088 Task-number: QTBUG-107264 Pick-to: 6.5 Change-Id: Ia2f78a7d1e758fc717078b6aa44a0f6716afd227 Reviewed-by: Matthias Rauter <matthias.rauter@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Document the Pointer Handlers exampleShawn Rutledge2023-03-0211-0/+170
| | | | | | | | | | | 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>
* PointerHanders FakeFlickable: Fix ambiguous referencesOliver Eftevaag2023-02-241-2/+2
| | | | | | | | | | The max property is declared inside the "knob" rectangle. The id of the rectangle should be used, in order to reference it correctly. Pick-to: 6.5 Change-Id: I157ab9c3ba687f6e0998f907f064014d03c5902f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Replace AUTO_RESOURCE_PREFIX with Qt CMake Policy in examples, testsAmir Masoud Abdol2023-02-211-2/+1
| | | | | | | | | | | | | | | | Every instance of AUTO_RESOURCE_PREFIX has been replaced by either qt_standard_project_setup(REQUIRES 6.5) or with qt_policy(SET QTP0001 NEW), mainly in tests. In addition, I added a warning message for the case where AUTO_RESOURCE_PREFIX is used. Pick-to: 6.5 Task-number: QTBUG-96233 Change-Id: I323a15e9d0bb5fe6ba649365314af9fc2ad67bda Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Use SequentialAnimation.loops in FlashAnimation in handlers exampleShawn Rutledge2023-02-211-7/+1
| | | | | | | | It looks less tedious. Amends 8503f884bbdb50c4bebc8f8a9fce05275b0612b1 Pick-to: 6.2 6.4 6.5 Change-Id: I85690e6a8ceac4ebec1c00bcbbf6a81108096e6c Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-271-1/+0
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Quick examples: Modernize cmake files according to our guidelinesOliver Eftevaag2023-01-161-3/+3
| | | | | | | | | | | | | | | | The following changes are made to the CMakeLists.txt files in all quick examples: - Use PRIVATE linkage when possible. - Use qt_standard_project_setup() - Set WIN32 and MACOSX_BUNDLE in qt_add_executable() instead of set_target_properties() Pick-to: 6.5 Change-Id: I18217585aec56794b327f103d6959879df59d68a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use inline component in sidebar example rather than LoaderShawn Rutledge2023-01-051-64/+57
| | | | | | | | | | | Originally in ca9e2a0d7488cbbb94d8343c43eb49c6ee5f6519 I used Loader as a way of reusing some content in two places in one QML file, not necessarily to test hover behavior with Loader. Inline components are a little cleaner. Pick-to: 6.2 6.4 6.5 Change-Id: Ib064bdb460704bec0c714550d8935dcef8af0637 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* map example: don't restrict pinch-zoom to centerShawn Rutledge2023-01-021-2/+0
| | | | | | | | | | A big advantage of PinchHandler over PinchArea is the ability to zoom into a particular location in the target Item, so let's not fail to show that off. Pick-to: 6.2 6.4 6.5 Change-Id: I0f22abff99bdc60bac27e72fd5f66be4796794df Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add PinchHandler.scaleAxis, rotationAxis; hold values in axesShawn Rutledge2022-12-101-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add TapHandler.exclusiveSignals to enable single/double tap exclusivityShawn Rutledge2022-10-192-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Do not use import version numbers anymoreKai Köhne2022-08-311-1/+1
| | | | | | | | Pick-to: 6.4 Change-Id: I1f4d4920bb9d132a846ac2dbcfdb8b660759d540 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix the pointerhandlers exampleShawn Rutledge2022-07-111-0/+1
| | | | | | | Amends d270c51f812b5f0ffe6208b38c8ea0e898535e50 Change-Id: I616850c04facbcd7662c479d34b1a3f0a7220556 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1126-1274/+52
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Sidebar example: nest content in MouseArea to restore hover propagationShawn Rutledge2022-03-281-5/+5
| | | | | | | | | | | | | After 499828b855d125ac236917f6ed01d8f1e7d88505 if you want a MouseArea underneath some other contents to receive propagated hover events, the content must be inside the MouseArea, not a sibling. HoverHandler still does not have this restriction (handlers cannot have items as children, and the handler is not considered a sibling: it's an event-handling facet added to the item in which it's declared). Pick-to: 6.3 6.2 Change-Id: I5ac31d982e429ac002cb0bd7ae9c071ab927032b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Improve examples CMakeLists.txtKai Köhne2022-01-241-6/+3
| | | | | | | | | | | | | | | | | | - Remove # generated from xyz.pro comment from pro2cmake - Remove "# special case" markers for pro2cmake - Remove automatic use of CMAKE_AUTORCC - Only opt into CMAKE_AUTOUIC if .ui files are involved - Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR - Combine multiple find_package(Qt6 ... calls) - use REQUIRED COMPONENTS - sort components alphabetically - Fix wrong indentations - Use (only) one empty line after multi-line commands Pick-to: 6.3 Change-Id: I0d6bfb06c4b25e9921d3d2bf31d977150f12b31b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix pointer handlers example build: include piemenu, qmake supportShawn Rutledge2021-12-123-3/+15
| | | | | | | | | | Amends e17bfffc075202ff9ee8fba0f378f95037514740 and 8503f884bbdb50c4bebc8f8a9fce05275b0612b1 : all qml files need to be listed in CMakeLists.txt, we need to keep qml.qrc updated too, and we decided to keep the qmake project files. Change-Id: Idaa4bbddabd59e79a0ae3b907319c6843d8a026a Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Instantiator: don't interfere with delegates that assign parentsShawn Rutledge2021-12-101-7/+4
| | | | | | | | | | | | [ChangeLog][QtQml][Instantiator] Instantiator now avoids re-assigning a delegate object's parent to itself if it was already set; thus, you can now declare a parent assignment. Task-number: QTBUG-64546 Task-number: QTBUG-84730 Change-Id: I7d95fa76e71c363b4cb5b7a512c2e984488c8af4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Pointer Handlers example: show mouse wheel feedbackShawn Rutledge2021-12-104-3/+27
| | | | | | | | MouseFeedbackSprite now shows a mouse wheel animating in the same direction as the physical mouse wheel is being rotated. Change-Id: I08709ead3b85065723d2320d17d49adb51a00f92 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add HoverHandler.blocking propertyShawn Rutledge2021-12-091-5/+21
| | | | | | | | | | | | | | | As with WheelHandler, sometimes users want to let the hover events propagate (which has been the default all along), but sometimes it's not appropriate to allow parents of nested items to show hover feedback. [ChangeLog][QtQuick][HoverHandler] HoverHandler now has a property called blocking, which is false by default; but if set to true, it prevents hover events from propagating to items "under" this handler's parent, and their HoverHandlers. Task-number: QTBUG-85926 Change-Id: I26f89482e294c7a6b30a55a7e23ac444a0d1ac7f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add TapHandler.gesturePolicy: DragWithinBounds enum value; examplesShawn Rutledge2021-12-024-7/+259
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On a touchscreen, right-clicking is not directly possible; so sometimes a long-press gesture is used as a substitute. The next thing a UI designer would want would then be a way of showing feedback that a long-press is in progress, rather than simply waiting for the long-press to occur and then surprising the user with some instant action. For example, a menu might begin to open as the user holds down the touchpoint; but before the long-press gesture is complete, the user can simply release, to cancel the gesture and close the menu. The timeHeld property could drive the animation, to avoid needing a separate animation type; in fact the reason timeHeld exists is to make it easy to emulate this sort of touch-press animation, like one that occurs on touchscreens since Windows 7. But after the menu is open, the user would probably expect to be able to drag the finger to a menu item and release, to select the menu item. For such a purpose, the existing gesture policies weren't very useful: each of them resets the timeHeld property if the user drags beyond the drag threshold; so if the user expects to drag and release over a menu item, then the timeHeld property cannot drive the menu-opening animation, because the menu would disappear as soon as the user drags a little. So it makes more sense to have a gesturePolicy that acts like WithinBounds, but also applies the same policy to the timeHeld property and the longPressed signal. We don't care about the drag threshold: if the user is holding down a finger, it's considered to be a long-press-in-progress, regardless of how far it has moved since press (as long as it stays within the parent's bounds). An example of such a menu is added. The menu must have TapHandler as its root object, because it reacts to press-and-drag within some larger item, larger than the menu itself. For example such a menu could be used in a canvas-like application (drawing, diagramming, dragging things like photos or file icons, or something like that): dragging items on the canvas is possible, but long-pressing anywhere will open a context menu. But in this example so far, only the menu is implemented. It's a pie menu, because those are particularly touch-friendly; but perhaps for the mouse, a conventional context menu would be used. [ChangeLog][QtQuick][Event Handlers] TapHandler now has one more gesturePolicy value: DragWithinBounds; it is similar to WithinBounds, except that timeHeld is not reset during dragging, and the longPressed signal can be emitted regardless of the drag threshold. This is useful for implementing press-drag-release components such as menus, while using timeHeld to directly drive an "opening" animation. Change-Id: I298f8b1ad8f8d7d3c241ef4fdd68e7ec8d8b5bdd Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Update examples to use new PropertyChangesUlf Hermann2021-11-031-36/+30
| | | | | | | | Also, prefer the multi-line syntax over ';'-separated bindings for readability. Change-Id: I3d6eb854e514ee257ca83773a11e6e9e10770bff Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove import versions from qml files in the pointerhandlers exampleShawn Rutledge2021-10-2715-17/+17
| | | | | | | | | | | Many of these are portable to Qt 5; but we don't need the version numbers in Qt 6, and the components that use "palette" refer to Item.palette, which was added in Qt 6. Pick-to: 6.2 Change-Id: Ic799fba5dd66db51a8808c52dce01d27c6da62bb Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix pointerhandlers/fakeFlickable exampleShawn Rutledge2021-10-261-4/+4
| | | | | | | | | TapHandlerButton is not in this example: we just call it Button. Amends 8503f884bbdb50c4bebc8f8a9fce05275b0612b1 Pick-to: 6.2 Change-Id: I49bc6081f05642cd938a257c14c10497bfafb8a8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Pointerhandlers example: fix CMakeLists.txt linking errorOliver Eftevaag2021-10-261-5/+6
| | | | | | | | Fixes: QTBUG-97466 Pick-to: 6.2 Change-Id: I9bb0b79b12cbd43209f56137bbdb67ca2457ca6c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Large Text: populate only lines visible in Window into SGShawn Rutledge2021-09-291-6/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Text is rendered top-to-bottom: QQuickTextNode::addTextLayout() iterates lines of text. Now it first maps the window size() rectangle into the Text item's coordinate system, and treats that as the viewport: lines whose y coordinates fall outside are omitted. This saves a huge amount of time and memory when the text is large. So Flickable { Text { } } can actually be used in an ebook reader now, for example. QQuickItemPrivate::transformChanged(parent) is now used to inform all children when a parent moves; so e.g. when a content item is moved inside a "viewport" item (like a Flickable, or any other item that is being used as a clipping viewport or just as a holder), all children of the content item will be notified; and QQuickTextPrivate uses this occasion to mark itself dirty so that the updatePaintNode() will be called again. This happens directly after the actual movement: QQuickTextPrivate::transformChanged qquicktext.cpp 2990 QQuickItemPrivate::transformChanged qquickitem.cpp 5200 QQuickItemPrivate::dirty qquickitem.cpp 6339 QQuickItem::setY qquickitem.cpp 6830 QQuickFlickablePrivate::setViewportY qquickflickable.cpp 1800 Task-number: QTBUG-60491 Task-number: QTBUG-90734 Change-Id: I152d23caa725f194a186a604fbc8d0c07f597b16 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Move most of the pointer manual tests to a new pointerhandlers exampleShawn Rutledge2021-09-2445-0/+3261
They were always meant to be examples eventually. Now they will be used for an example of how to implement custom controls using only basic items and handlers. Some components are very similar to those in the shared directory; but most examples will use Qt Quick Controls, so those shared components can be removed when we no longer use them. This example should remain as the one that shows how to build reusable controls "from scratch". Removed InputInspector because it's inefficient, has limited usefulness, tends to require building the manual test to be able to run it, and could be better built as a reusable Qt.labs component later on, providing a model with all known devices and taking advantage of the QPointingDevice::grabChanged signal to track the grab states rather than polling. Pick-to: 6.2 Change-Id: I47ab6ebb2cecab07a69cf96e546ffd0db3026a60 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>