diff options
Diffstat (limited to 'tests/manual/pointer')
23 files changed, 192 insertions, 44 deletions
diff --git a/tests/manual/pointer/content/CheckBox.qml b/tests/manual/pointer/content/CheckBox.qml index fd89337963..bd5661d76b 100644 --- a/tests/manual/pointer/content/CheckBox.qml +++ b/tests/manual/pointer/content/CheckBox.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml new file mode 100644 index 0000000000..413bc9979d --- /dev/null +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -0,0 +1,102 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import Qt.labs.animation + +Item { + id: root + objectName: "viewport" + default property alias data: __contentItem.data + property alias velocity: anim.velocity + property alias contentX: __contentItem.x // sign is reversed compared to Flickable.contentX + property alias contentY: __contentItem.y // sign is reversed compared to Flickable.contentY + property alias contentWidth: __contentItem.width + property alias contentHeight: __contentItem.height + signal flickStarted + signal flickEnded + + Item { + id: __contentItem + objectName: "__contentItem" + width: childrenRect.width + height: childrenRect.height + + BoundaryRule on x { + id: xbr + minimum: root.width - __contentItem.width + maximum: 0 + minimumOvershoot: 100 + maximumOvershoot: 100 + overshootFilter: BoundaryRule.Peak + } + + BoundaryRule on y { + id: ybr + minimum: root.height - __contentItem.height + maximum: 0 + minimumOvershoot: 100 + maximumOvershoot: 100 + overshootFilter: BoundaryRule.Peak + } + + DragHandler { + id: dragHandler + onActiveChanged: + if (active) { + anim.stop() + root.flickStarted() + } else { + var vel = centroid.velocity + if (xbr.returnToBounds()) + vel.x = 0 + if (ybr.returnToBounds()) + vel.y = 0 + if (vel.x !== 0 || vel.y !== 0) + anim.restart(vel) + else + root.flickEnded() + } + } + WheelHandler { + rotationScale: 15 + property: "x" + orientation: Qt.Horizontal + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + onActiveChanged: + // emitting signals in both instances is redundant but hard to avoid + // when the touchpad is flicking along both axes + if (active) { + anim.stop() + root.flickStarted() + } else { + xbr.returnToBounds() + root.flickEnded() + } + } + WheelHandler { + rotationScale: 15 + property: "y" + orientation: Qt.Vertical + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + onActiveChanged: + if (active) { + anim.stop() + root.flickStarted() + } else { + ybr.returnToBounds() + root.flickEnded() + } + } + MomentumAnimation { + id: anim + target: __contentItem + onStarted: root.flickStarted() + onStopped: { + xbr.returnToBounds() + ybr.returnToBounds() + root.flickEnded() + } + } + } +} diff --git a/tests/manual/pointer/content/FlashAnimation.qml b/tests/manual/pointer/content/FlashAnimation.qml index 09d0ab5e4e..ef19f4d427 100644 --- a/tests/manual/pointer/content/FlashAnimation.qml +++ b/tests/manual/pointer/content/FlashAnimation.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/content/MomentumAnimation.qml b/tests/manual/pointer/content/MomentumAnimation.qml index 23d2a60623..2ea6a55379 100644 --- a/tests/manual/pointer/content/MomentumAnimation.qml +++ b/tests/manual/pointer/content/MomentumAnimation.qml @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/content/MouseAreaButton.qml b/tests/manual/pointer/content/MouseAreaButton.qml index b495d59066..2c1ddb7295 100644 --- a/tests/manual/pointer/content/MouseAreaButton.qml +++ b/tests/manual/pointer/content/MouseAreaButton.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import QtQuick.Window 2.12 diff --git a/tests/manual/pointer/content/MouseAreaSlider.qml b/tests/manual/pointer/content/MouseAreaSlider.qml index e19e46d621..9f0553c9a7 100644 --- a/tests/manual/pointer/content/MouseAreaSlider.qml +++ b/tests/manual/pointer/content/MouseAreaSlider.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/content/MptaButton.qml b/tests/manual/pointer/content/MptaButton.qml index 19b9d907bb..444269b1ba 100644 --- a/tests/manual/pointer/content/MptaButton.qml +++ b/tests/manual/pointer/content/MptaButton.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import QtQuick.Window 2.12 diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index f20b634778..bcf19b6b4b 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.14 import Qt.labs.animation 1.0 diff --git a/tests/manual/pointer/content/TapHandlerButton.qml b/tests/manual/pointer/content/TapHandlerButton.qml index 1cfc8d8bc3..84a45b777f 100644 --- a/tests/manual/pointer/content/TapHandlerButton.qml +++ b/tests/manual/pointer/content/TapHandlerButton.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import QtQuick.Window 2.12 diff --git a/tests/manual/pointer/content/TextBox.qml b/tests/manual/pointer/content/TextBox.qml index 9eb77a85a3..1443019dc9 100644 --- a/tests/manual/pointer/content/TextBox.qml +++ b/tests/manual/pointer/content/TextBox.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/content/TouchpointFeedbackSprite.qml b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml index 36efc5195b..2bc4a805ce 100644 --- a/tests/manual/pointer/content/TouchpointFeedbackSprite.qml +++ b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/flickablesWithHandlers.qml b/tests/manual/pointer/flickablesWithHandlers.qml index 08826ed858..abfe57bfac 100644 --- a/tests/manual/pointer/flickablesWithHandlers.qml +++ b/tests/manual/pointer/flickablesWithHandlers.qml @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import "content" diff --git a/tests/manual/pointer/hoverpropagation.qml b/tests/manual/pointer/hoverpropagation.qml index f79b9e754e..42d431c4ea 100644 --- a/tests/manual/pointer/hoverpropagation.qml +++ b/tests/manual/pointer/hoverpropagation.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.1 import QtQuick.Window diff --git a/tests/manual/pointer/map2.qml b/tests/manual/pointer/map2.qml index 0c83e58a26..fa2f1157df 100644 --- a/tests/manual/pointer/map2.qml +++ b/tests/manual/pointer/map2.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/manual/pointer/photosurface.qml b/tests/manual/pointer/photosurface.qml index 9bf5d5875a..489c11e12d 100644 --- a/tests/manual/pointer/photosurface.qml +++ b/tests/manual/pointer/photosurface.qml @@ -1,9 +1,10 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -import QtQuick 2.12 -import QtQuick.Dialogs 1.0 -import Qt.labs.folderlistmodel 1.0 +import QtCore +import QtQuick +import QtQuick.Dialogs +import Qt.labs.folderlistmodel import "content" Rectangle { @@ -11,36 +12,37 @@ Rectangle { visible: true width: 1024; height: 600 color: "black" - property int highestZ: 0 property real defaultSize: 200 property real surfaceViewportRatio: 1.5 - FileDialog { - id: fileDialog + FolderDialog { + id: folderDialog title: "Choose a folder with some images" - selectFolder: true - onAccepted: folderModel.folder = fileUrl + "/" + onAccepted: folderModel.folder = selectedFolder + "/" } Shortcut { id: openShortcut sequence: StandardKey.Open - onActivated: fileDialog.open() + onActivated: folderDialog.open() } FakeFlickable { id: flick anchors.fill: parent - contentWidth: width * 2 - contentHeight: height * 2 + contentWidth: width * root.surfaceViewportRatio + contentHeight: height * root.surfaceViewportRatio + property int highestZ: 0 Repeater { model: FolderListModel { id: folderModel - folder: "resources/" objectName: "folderModel" showDirs: false nameFilters: ["*.png", "*.jpg", "*.gif"] } - Rectangle { + delegate: Rectangle { + required property string fileModified + required property string fileName + required property string fileUrl id: photoFrame objectName: "frame-" + fileName width: image.width * (1 + 0.10 * image.height / image.width) @@ -58,21 +60,34 @@ Rectangle { y = Math.random() * root.height - height / 2 rotation = Math.random() * 13 - 6 } + Image { id: image anchors.centerIn: parent fillMode: Image.PreserveAspectFit - source: folderModel.folder + fileName + source: photoFrame.fileUrl antialiasing: true } - MomentumAnimation { id: anim; target: photoFrame } + Text { + text: fileName + " ❖ " + Qt.formatDateTime(fileModified, Locale.LongFormat) + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + font.pixelSize: (parent.height - image.height) / 3 + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + margins: font.pixelSize / 5 + } + } - DragHandler { - id: dragHandler - onActiveChanged: { - if (!active) - anim.restart(point.velocity) + MomentumAnimation { + id: anim + target: photoFrame + onFinished: { + flick.contentWidth = Math.max(photoFrame.x + photoFrame.width, flick.contentWidth) + flick.contentHeight = Math.max(photoFrame.y + photoFrame.height, flick.contentHeight) } } @@ -82,7 +97,18 @@ Rectangle { maximumRotation: 360 minimumScale: 0.1 maximumScale: 10 - property real zRestore: 0 + grabPermissions: PointerHandler.CanTakeOverFromAnything // and never gonna give it up + onActiveChanged: if (active) photoFrame.z = ++flick.highestZ + } + + DragHandler { + id: dragHandler + onActiveChanged: { + if (active) + photoFrame.z = ++flick.highestZ + else + anim.restart(centroid.velocity) + } } } } @@ -134,4 +160,22 @@ Rectangle { "On a touchscreen: use two fingers to zoom and rotate, one finger to drag\n" + "With a mouse: drag normally" } + + Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() } + + Component.onCompleted: { + const lastArg = Application.arguments.slice(-1)[0] + const standardPicturesLocations = StandardPaths.standardLocations(StandardPaths.PicturesLocation) + const hasValidPicturesLocation = standardPicturesLocations.length > 0 + if (hasValidPicturesLocation) + folderDialog.currentFolder = standardPicturesLocations[0] + if (/.*hotosurface.*|--+/.test(lastArg)) { + if (hasValidPicturesLocation) + folderModel.folder = standardPicturesLocations[0] + else + folderDialog.open() + } + else + folderModel.folder = Qt.resolvedUrl("file:" + lastArg) + } } diff --git a/tests/manual/pointer/pinchAndWheel.qml b/tests/manual/pointer/pinchAndWheel.qml index fa60f4a79c..bd588fabf1 100644 --- a/tests/manual/pointer/pinchAndWheel.qml +++ b/tests/manual/pointer/pinchAndWheel.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.14 import Qt.labs.animation 1.0 @@ -25,7 +25,9 @@ Rectangle { function getTransformationDetails(item, pinchhandler) { return "\n\npinch.scale:" + pinchhandler.scale.toFixed(2) + "\npinch.rotation:" + pinchhandler.rotation.toFixed(2) - + "°\npinch.translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + + "°\npinch.activeTranslation:" + "(" + pinchhandler.activeTranslation.x.toFixed(2) + "," + pinchhandler.activeTranslation.y.toFixed(2) + ")" + + "\npinch.persistentTranslation:" + "(" + pinchhandler.persistentTranslation.x.toFixed(2) + "," + pinchhandler.persistentTranslation.y.toFixed(2) + ")" + + " item pos " + "(" + transformable.x.toFixed(2) + "," + transformable.y.toFixed(2) + ")" + "\nscale wheel.rotation:" + scaleWheelHandler.rotation.toFixed(2) + "°\nhorizontal wheel.rotation:" + horizontalRotationWheelHandler.rotation.toFixed(2) + "°\ncontrol-rotation wheel.rotation:" + controlRotationWheelHandler.rotation.toFixed(2) diff --git a/tests/manual/pointer/pinchDragFlingMPTA.qml b/tests/manual/pointer/pinchDragFlingMPTA.qml index 3c268a0d4b..45d2b56182 100644 --- a/tests/manual/pointer/pinchDragFlingMPTA.qml +++ b/tests/manual/pointer/pinchDragFlingMPTA.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import "content" diff --git a/tests/manual/pointer/pinchFlickable.qml b/tests/manual/pointer/pinchFlickable.qml index 1084a45e99..7b22461507 100644 --- a/tests/manual/pointer/pinchFlickable.qml +++ b/tests/manual/pointer/pinchFlickable.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/manual/pointer/pinchNullTarget.qml b/tests/manual/pointer/pinchNullTarget.qml index 79c6047991..d7f0c7e279 100644 --- a/tests/manual/pointer/pinchNullTarget.qml +++ b/tests/manual/pointer/pinchNullTarget.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.15 diff --git a/tests/manual/pointer/pointHandlerOnFlickable.qml b/tests/manual/pointer/pointHandlerOnFlickable.qml index 852df89f6a..db6b8c7257 100644 --- a/tests/manual/pointer/pointHandlerOnFlickable.qml +++ b/tests/manual/pointer/pointHandlerOnFlickable.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 import "content" diff --git a/tests/manual/pointer/pointerDrag.qml b/tests/manual/pointer/pointerDrag.qml index 0d603c71d0..85d91113db 100644 --- a/tests/manual/pointer/pointerDrag.qml +++ b/tests/manual/pointer/pointerDrag.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.15 import "content" diff --git a/tests/manual/pointer/rubberbandOnTable.qml b/tests/manual/pointer/rubberbandOnTable.qml index dacd549f12..bc3506ee73 100644 --- a/tests/manual/pointer/rubberbandOnTable.qml +++ b/tests/manual/pointer/rubberbandOnTable.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 diff --git a/tests/manual/pointer/tapWithModifiers.qml b/tests/manual/pointer/tapWithModifiers.qml index 8455a45f86..724754502d 100644 --- a/tests/manual/pointer/tapWithModifiers.qml +++ b/tests/manual/pointer/tapWithModifiers.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.12 |