diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-03-06 21:28:41 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-24 05:54:18 +0000 |
commit | c6238ece82f252bdd5b08b0e891f804d4afa62f7 (patch) | |
tree | 3bf6b9eda20ff276d4671a69743c502c984b1acb | |
parent | 465d6741411064b5424faac9602e160caa1a4548 (diff) | |
download | qtdoc-c6238ece82f252bdd5b08b0e891f804d4afa62f7.tar.gz |
photosurface: Add a "welcome" slide show at startup
The PDF is transparent, so the background shows through.
Task-number: QTBUG-108924
Change-Id: I2fb78ad1b9453109a2d2eb19f2aad91f31679a0d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 80404e00bb294bd358c93c9c5fefb490a8edb485)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/demos/photosurface/CMakeLists.txt | 2 | ||||
-rw-r--r-- | examples/demos/photosurface/photosurface.qml | 39 | ||||
-rw-r--r-- | examples/demos/photosurface/resources/SlideShow.qml | 91 | ||||
-rw-r--r-- | examples/demos/photosurface/resources/welcome.pdf | bin | 0 -> 152703 bytes |
4 files changed, 116 insertions, 16 deletions
diff --git a/examples/demos/photosurface/CMakeLists.txt b/examples/demos/photosurface/CMakeLists.txt index d60b9d18..d5249109 100644 --- a/examples/demos/photosurface/CMakeLists.txt +++ b/examples/demos/photosurface/CMakeLists.txt @@ -51,8 +51,10 @@ qt_add_qml_module(photosurfaceexample QML_FILES "photosurface.qml" "resources/MomentumAnimation.qml" + "resources/SlideShow.qml" RESOURCES "resources/folder.png" + "resources/welcome.pdf" ) qt6_add_shaders(photosurfaceexample "shaders" diff --git a/examples/demos/photosurface/photosurface.qml b/examples/demos/photosurface/photosurface.qml index c70e0b34..063c7b48 100644 --- a/examples/demos/photosurface/photosurface.qml +++ b/examples/demos/photosurface/photosurface.qml @@ -133,6 +133,8 @@ Window { } Image { + id: folderIcon + visible: false anchors.top: parent.top anchors.left: parent.left anchors.margins: 10 @@ -154,32 +156,37 @@ Window { } Text { + visible: folderDialog.visible anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - anchors.margins: 10 - color: "darkgrey" + anchors.margins: 20 + color: "white" wrapMode: Text.WordWrap - font.pointSize: 8 - text: qsTr(`On a touchscreen: use two fingers to zoom and rotate, one finger to drag - \nWith a mouse: drag and scroll normally, shift-wheel to zoom, control-wheel to rotate`) + text: qsTr("Choose your own photo folder") } 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)) { + SlideShow { + id: welcomeSlides + multiFrameSource: "welcome.pdf" + anchors.fill: parent + Component.onDestruction: { + folderIcon.visible = true + const lastArg = Application.arguments.slice(-1)[0] + const standardPicturesLocations = StandardPaths.standardLocations(StandardPaths.PicturesLocation) + const hasValidPicturesLocation = standardPicturesLocations.length > 0 if (hasValidPicturesLocation) - folderModel.folder = standardPicturesLocations[0] + folderDialog.currentFolder = standardPicturesLocations[0] + if (/.*hotosurface.*|--+/.test(lastArg)) { + if (hasValidPicturesLocation) + folderModel.folder = standardPicturesLocations[0] + else + folderDialog.open() + } else - folderDialog.open() + folderModel.folder = Qt.resolvedUrl("file:" + lastArg) } - else - folderModel.folder = Qt.resolvedUrl("file:" + lastArg) } } diff --git a/examples/demos/photosurface/resources/SlideShow.qml b/examples/demos/photosurface/resources/SlideShow.qml new file mode 100644 index 00000000..9ba218f8 --- /dev/null +++ b/examples/demos/photosurface/resources/SlideShow.qml @@ -0,0 +1,91 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtQuick + +Item { + id: root + required property url multiFrameSource + property int pageDuration: 5000 + + Image { + id: imgEven + anchors { + horizontalCenter: parent.horizontalCenter + horizontalCenterOffset: -150 + verticalCenter: parent.verticalCenter + } + source: root.multiFrameSource + sourceSize.width: width + width: root.width - 400 + opacity: seq.currentFrame % 2 == 0 ? 1 : 0 + Behavior on opacity { + NumberAnimation { duration: 500 } + } + } + + Image { + id: imgOdd + anchors.centerIn: imgEven + source: root.multiFrameSource + sourceSize.width: width + width: imgEven.width + opacity: 1 - imgEven.opacity + } + + Rectangle { + width: Math.min(330, root.width / 5.8) + height: width / 3.8 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + color: mouse.hovered || tap.pressed ? "white" : "#009b87" + border.color: mouse.hovered || tap.pressed ? "#009b87" : "transparent" + border.width: 2 + Text { + color: mouse.hovered || tap.pressed ? "#009b87" : "white" + anchors.centerIn: parent + font.pixelSize: parent.width / 10 + text: seq.currentFrame < imgEven.frameCount - 1 ? qsTr("Skip Intro") : qsTr("Ready to go") + } + HoverHandler { + id: mouse + } + TapHandler { + id: tap + onTapped: quit() + } + } + + function quit() { + root.destroy() + } + + SequentialAnimation { + id: seq + loops: Animation.Infinite + property int currentFrame: -1 + onCurrentFrameChanged: if (currentFrame >= imgEven.frameCount) root.quit() + + ScriptAction { + script: { + imgEven.currentFrame = ++seq.currentFrame + } + } + + PauseAnimation { + duration: root.pageDuration + } + + ScriptAction { + script: { + imgOdd.currentFrame = ++seq.currentFrame + } + } + + PauseAnimation { + duration: root.pageDuration + } + } + + Component.onCompleted: seq.start() +} diff --git a/examples/demos/photosurface/resources/welcome.pdf b/examples/demos/photosurface/resources/welcome.pdf Binary files differnew file mode 100644 index 00000000..16ac75cb --- /dev/null +++ b/examples/demos/photosurface/resources/welcome.pdf |