diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2021-11-08 16:46:32 +0100 |
---|---|---|
committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2021-11-11 12:11:40 +0100 |
commit | aa4897e017c027c935cd349450bf787393ce5552 (patch) | |
tree | 239bf7ca49641dae579ed8b1fa88a1bb9cd1eb1d /examples/quick/particles/imageparticle | |
parent | 56f00a8429bf6932e9bd92f21eda71aee9c64690 (diff) |
Particle examples: use new cmake api
The particles directory contains 5 different examples
and a shared directory with some images files.
This patch changes the examples to use qt_add_qml_module()
in the CMakeLists.txt project files, and changes the .qrc
files to directory reference the files needed by the individual
projects, which removes the need for images.qrc.
(The .pro files still reference the shared.qrc file)
The "content" directories located in the different example
projects, have been removed, and the containing files have simply
been moved to the parent directories instead.
Some unused files in the itemparticle example have also been
deleted. This example looks very outdated and should ideally
be improved, or perhaps simply removed, but I decided to leave
it for now.
Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: If05986b4347814715bca50b8d3f6a5cddbf9ced4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/quick/particles/imageparticle')
21 files changed, 101 insertions, 162 deletions
diff --git a/examples/quick/particles/imageparticle/CMakeLists.txt b/examples/quick/particles/imageparticle/CMakeLists.txt index 4487e04316..387c5bdd41 100644 --- a/examples/quick/particles/imageparticle/CMakeLists.txt +++ b/examples/quick/particles/imageparticle/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from imageparticle.pro. - cmake_minimum_required(VERSION 3.16) project(imageparticle LANGUAGES CXX) @@ -7,7 +5,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,115 +12,50 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/imageparticle") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) + +add_subdirectory("../../shared" "shared") -qt_add_executable(imageparticle +qt_add_executable(imageparticleexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(imageparticle PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(imageparticle PUBLIC +target_link_libraries(imageparticleexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) +add_dependencies(imageparticleexample imageparticle_shared) # Resources: -set(imageparticle_resource_files - "content/allatonce.qml" - "content/colored.qml" - "content/colortable.qml" - "content/deformation.qml" - "content/rotation.qml" - "content/sharing.qml" - "content/sprites.qml" - "imageparticle.qml" -) - -qt6_add_resources(imageparticle "imageparticle" - PREFIX - "/particles/imageparticle" - FILES - ${imageparticle_resource_files} -) -set(images_resource_files - "../images/_explo.png" - "../images/backgroundLeaves.jpg" - "../images/bear_tiles.png" - "../images/candle.png" - "../images/colortable.png" - "../images/finalfrontier.png" - "../images/flower.png" - "../images/matchmask.png" - "../images/meteor.png" - "../images/meteor_explo.png" - "../images/meteors.png" - "../images/nullRock.png" - "../images/particle2.png" - "../images/particle3.png" - "../images/particleA.png" - "../images/portal_bg.png" - "../images/realLeaf1.png" - "../images/realLeaf2.png" - "../images/realLeaf3.png" - "../images/realLeaf4.png" - "../images/rocket.png" - "../images/rocket2.png" - "../images/sizeInOut.png" - "../images/snowflake.png" - "../images/sparkleSize.png" - "../images/starfish_0.png" - "../images/starfish_1.png" - "../images/starfish_2.png" - "../images/starfish_3.png" - "../images/starfish_4.png" - "../images/starfish_mask.png" -) - -qt6_add_resources(imageparticle "images" - PREFIX - "/particles" - BASE - ".." - FILES - ${images_resource_files} -) -set(shared_resource_files - "../../shared/Button.qml" - "../../shared/CheckBox.qml" - "../../shared/FlickrRssModel.qml" - "../../shared/Label.qml" - "../../shared/LauncherList.qml" - "../../shared/SimpleLauncherDelegate.qml" - "../../shared/Slider.qml" - "../../shared/TabSet.qml" - "../../shared/TextField.qml" - "../../shared/images/back.png" - "../../shared/images/checkmark.png" - "../../shared/images/next.png" - "../../shared/images/qt-logo.png" - "../../shared/images/slider_handle.png" - "../../shared/images/tab.png" -) - -qt6_add_resources(imageparticle "shared" - PREFIX - "/shared" - BASE - "../../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS imageparticle +qt_add_qml_module(imageparticleexample + URI imageparticle + VERSION 1.0 + QML_FILES + "allatonce.qml" + "colored.qml" + "colortable.qml" + "deformation.qml" + "imageparticle.qml" + "rotation.qml" + "sharing.qml" + "sprites.qml" + RESOURCES + "images/bear_tiles.png" + "images/colortable.png" + "images/starfish_0.png" + "images/starfish_1.png" + "images/starfish_2.png" + "images/starfish_3.png" + "images/starfish_4.png" + "images/flower.png" +) + +install(TARGETS imageparticleexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +bundle_shared(imageparticleexample) diff --git a/examples/quick/particles/imageparticle/content/allatonce.qml b/examples/quick/particles/imageparticle/allatonce.qml index 4b6c9b35cc..5a250bc79a 100644 --- a/examples/quick/particles/imageparticle/content/allatonce.qml +++ b/examples/quick/particles/imageparticle/allatonce.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { color: "white" @@ -64,14 +64,14 @@ Rectangle { sprites: [ Sprite { name: "bear" - source: "../../images/bear_tiles.png" + source: "images/bear_tiles.png" frameCount: 13 frameDuration: 120 } ] colorVariation: 0.5 rotationVelocityVariation: 360 - colorTable: "../../images/colortable.png" + colorTable: "images/colortable.png" // ![0] system: sys } diff --git a/examples/quick/particles/imageparticle/content/colored.qml b/examples/quick/particles/imageparticle/colored.qml index 3452cad805..11c4304457 100644 --- a/examples/quick/particles/imageparticle/content/colored.qml +++ b/examples/quick/particles/imageparticle/colored.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { width: 360 diff --git a/examples/quick/particles/imageparticle/content/colortable.qml b/examples/quick/particles/imageparticle/colortable.qml index 5f88c1a8b3..809ad345f9 100644 --- a/examples/quick/particles/imageparticle/content/colortable.qml +++ b/examples/quick/particles/imageparticle/colortable.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick.Particles 2.0 -import QtQuick 2.0 +import QtQuick.Particles +import QtQuick Rectangle { id: root @@ -66,8 +66,8 @@ Rectangle { //! [0] source: "qrc:///particleresources/glowdot.png" - colorTable: "../../images/colortable.png" - sizeTable: "../../images/colortable.png" + colorTable: "images/colortable.png" + sizeTable: "images/colortable.png" //! [0] } diff --git a/examples/quick/particles/imageparticle/content/deformation.qml b/examples/quick/particles/imageparticle/deformation.qml index ce672c8fa3..f8f0f31e33 100644 --- a/examples/quick/particles/imageparticle/content/deformation.qml +++ b/examples/quick/particles/imageparticle/deformation.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { color: "goldenrod" @@ -61,7 +61,7 @@ Rectangle { ImageParticle { system: sys groups: ["goingLeft", "goingRight"] - source: "../../images/starfish_4.png" + source: "images/starfish_4.png" rotation: 90 rotationVelocity: 90 autoRotation: true @@ -71,7 +71,7 @@ Rectangle { ImageParticle { system: sys groups: ["goingDown"] - source: "../../images/starfish_0.png" + source: "images/starfish_0.png" rotation: 180 yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } } diff --git a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc index 6a71e1f5fd..9ef3228126 100644 --- a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc +++ b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc @@ -35,25 +35,25 @@ Each example is a small QML file emphasizing a particular type or feature. All at once shows off several of the features of ImageParticle at the same time. - \snippet particles/imageparticle/content/allatonce.qml 0 + \snippet particles/imageparticle/allatonce.qml 0 Colored shows a simple ImageParticle with some color variation. - \snippet particles/imageparticle/content/colored.qml 0 + \snippet particles/imageparticle/colored.qml 0 Color Table sets the color over life on the particles to provide a fixed rainbow effect. - \snippet particles/imageparticle/content/colortable.qml 0 + \snippet particles/imageparticle/colortable.qml 0 Deformation spins and squishes a starfish particle. - \snippet particles/imageparticle/content/deformation.qml spin - \snippet particles/imageparticle/content/deformation.qml deform + \snippet particles/imageparticle/deformation.qml spin + \snippet particles/imageparticle/deformation.qml deform Rotation demonstrates the autoRotate property, so that particles rotate in the direction that they travel. Sharing demonstrates what happens when multiple ImageParticles try to render the same particle. The following ImageParticle renders the particles inside the ListView: - \snippet particles/imageparticle/content/sharing.qml 0 + \snippet particles/imageparticle/sharing.qml 0 The following ImageParticle is placed inside the list highlight, and renders the particles above the other ImageParticle. - \snippet particles/imageparticle/content/sharing.qml 1 + \snippet particles/imageparticle/sharing.qml 1 Note that because it sets the color and alpha in this ImageParticle, it renders the particles in a different color. Since it doesn't specify anything about the rotation, it shares the rotation with the other ImageParticle so that the flowers are rotated the same way in both. Note that you can undo rotation in another ImageParticle, you just need to explicitly set rotationVariation to 0. diff --git a/examples/quick/particles/imageparticle/imageparticle.pro b/examples/quick/particles/imageparticle/imageparticle.pro index e639c7423a..c9c5e59eb0 100644 --- a/examples/quick/particles/imageparticle/imageparticle.pro +++ b/examples/quick/particles/imageparticle/imageparticle.pro @@ -4,7 +4,6 @@ QT += quick qml SOURCES += main.cpp RESOURCES += \ imageparticle.qrc \ - ../images.qrc \ ../../shared/shared.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/imageparticle diff --git a/examples/quick/particles/imageparticle/imageparticle.qml b/examples/quick/particles/imageparticle/imageparticle.qml index a8dfa6a0c9..0423e72e28 100644 --- a/examples/quick/particles/imageparticle/imageparticle.qml +++ b/examples/quick/particles/imageparticle/imageparticle.qml @@ -48,23 +48,23 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../shared" as Examples +import QtQuick +import shared Item { height: 480 width: 320 - Examples.LauncherList { + LauncherList { id: ll anchors.fill: parent Component.onCompleted: { - addExample("All at once", "Uses all ImageParticle features", Qt.resolvedUrl("content/allatonce.qml")); - addExample("Colored", "Colorized image particles", Qt.resolvedUrl("content/colored.qml")); - addExample("Color Table", "Color-over-life rainbow particles", Qt.resolvedUrl("content/colortable.qml")); - addExample("Deformation", "Deformed particles", Qt.resolvedUrl("content/deformation.qml")); - addExample("Rotation", "Rotated particles", Qt.resolvedUrl("content/rotation.qml")); - addExample("Sharing", "Multiple ImageParticles on the same particles", Qt.resolvedUrl("content/sharing.qml")); - addExample("Sprites", "Particles rendered with sprites", Qt.resolvedUrl("content/sprites.qml")); + addExample("All at once", "Uses all ImageParticle features", Qt.resolvedUrl("allatonce.qml")); + addExample("Colored", "Colorized image particles", Qt.resolvedUrl("colored.qml")); + addExample("Color Table", "Color-over-life rainbow particles", Qt.resolvedUrl("colortable.qml")); + addExample("Deformation", "Deformed particles", Qt.resolvedUrl("deformation.qml")); + addExample("Rotation", "Rotated particles", Qt.resolvedUrl("rotation.qml")); + addExample("Sharing", "Multiple ImageParticles on the same particles", Qt.resolvedUrl("sharing.qml")); + addExample("Sprites", "Particles rendered with sprites", Qt.resolvedUrl("sprites.qml")); } } } diff --git a/examples/quick/particles/imageparticle/imageparticle.qrc b/examples/quick/particles/imageparticle/imageparticle.qrc index d9e4115e3e..ef9bddaaae 100644 --- a/examples/quick/particles/imageparticle/imageparticle.qrc +++ b/examples/quick/particles/imageparticle/imageparticle.qrc @@ -1,12 +1,20 @@ <RCC> - <qresource prefix="/particles/imageparticle"> + <qresource prefix="/imageparticle"> <file>imageparticle.qml</file> - <file>content/allatonce.qml</file> - <file>content/colored.qml</file> - <file>content/colortable.qml</file> - <file>content/deformation.qml</file> - <file>content/rotation.qml</file> - <file>content/sharing.qml</file> - <file>content/sprites.qml</file> + <file>allatonce.qml</file> + <file>colored.qml</file> + <file>colortable.qml</file> + <file>deformation.qml</file> + <file>rotation.qml</file> + <file>sharing.qml</file> + <file>sprites.qml</file> + <file>images/bear_tiles.png</file> + <file>images/colortable.png</file> + <file>images/starfish_0.png</file> + <file>images/starfish_1.png</file> + <file>images/starfish_2.png</file> + <file>images/starfish_3.png</file> + <file>images/starfish_4.png</file> + <file>images/flower.png</file> </qresource> </RCC> diff --git a/examples/quick/particles/imageparticle/images/bear_tiles.png b/examples/quick/particles/imageparticle/images/bear_tiles.png Binary files differnew file mode 100644 index 0000000000..6bbb2a9b6d --- /dev/null +++ b/examples/quick/particles/imageparticle/images/bear_tiles.png diff --git a/examples/quick/particles/imageparticle/images/colortable.png b/examples/quick/particles/imageparticle/images/colortable.png Binary files differnew file mode 100644 index 0000000000..15509ab5b7 --- /dev/null +++ b/examples/quick/particles/imageparticle/images/colortable.png diff --git a/examples/quick/particles/imageparticle/images/flower.png b/examples/quick/particles/imageparticle/images/flower.png Binary files differnew file mode 100644 index 0000000000..b5c606210e --- /dev/null +++ b/examples/quick/particles/imageparticle/images/flower.png diff --git a/examples/quick/particles/imageparticle/images/starfish_0.png b/examples/quick/particles/imageparticle/images/starfish_0.png Binary files differnew file mode 100644 index 0000000000..8747f0236e --- /dev/null +++ b/examples/quick/particles/imageparticle/images/starfish_0.png diff --git a/examples/quick/particles/imageparticle/images/starfish_1.png b/examples/quick/particles/imageparticle/images/starfish_1.png Binary files differnew file mode 100644 index 0000000000..1f3f159d5e --- /dev/null +++ b/examples/quick/particles/imageparticle/images/starfish_1.png diff --git a/examples/quick/particles/imageparticle/images/starfish_2.png b/examples/quick/particles/imageparticle/images/starfish_2.png Binary files differnew file mode 100644 index 0000000000..c6c7e5a676 --- /dev/null +++ b/examples/quick/particles/imageparticle/images/starfish_2.png diff --git a/examples/quick/particles/imageparticle/images/starfish_3.png b/examples/quick/particles/imageparticle/images/starfish_3.png Binary files differnew file mode 100644 index 0000000000..307a89f815 --- /dev/null +++ b/examples/quick/particles/imageparticle/images/starfish_3.png diff --git a/examples/quick/particles/imageparticle/images/starfish_4.png b/examples/quick/particles/imageparticle/images/starfish_4.png Binary files differnew file mode 100644 index 0000000000..d61c26545a --- /dev/null +++ b/examples/quick/particles/imageparticle/images/starfish_4.png diff --git a/examples/quick/particles/imageparticle/main.cpp b/examples/quick/particles/imageparticle/main.cpp index ff0764a730..a831728d0b 100644 --- a/examples/quick/particles/imageparticle/main.cpp +++ b/examples/quick/particles/imageparticle/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(particles/imageparticle/imageparticle) +DECLARATIVE_EXAMPLE_MAIN(imageparticle/imageparticle) diff --git a/examples/quick/particles/imageparticle/content/rotation.qml b/examples/quick/particles/imageparticle/rotation.qml index d118bb1d97..f7b101d0c2 100644 --- a/examples/quick/particles/imageparticle/content/rotation.qml +++ b/examples/quick/particles/imageparticle/rotation.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { color: "goldenrod" @@ -59,7 +59,7 @@ Rectangle { ImageParticle { id: up system: sys - source: "../../images/starfish_2.png" + source: "images/starfish_2.png" autoRotation: true //leaving these two settings at default allows you to test going up performance levels rotation: -90 } diff --git a/examples/quick/particles/imageparticle/content/sharing.qml b/examples/quick/particles/imageparticle/sharing.qml index 13ca1aa2d1..e6e333083c 100644 --- a/examples/quick/particles/imageparticle/content/sharing.qml +++ b/examples/quick/particles/imageparticle/sharing.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -52,8 +52,8 @@ // that uses a SpringAnimation to provide custom movement when the // highlight bar is moved between items. -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { id: root @@ -108,7 +108,7 @@ Rectangle { ImageParticle { anchors.fill: parent system: particles - source: "../../images/flower.png" + source: "images/flower.png" color: "red" clip: true alpha: 1.0 @@ -147,7 +147,7 @@ Rectangle { ImageParticle { anchors.fill: parent system: particles - source: "../../images/flower.png" + source: "images/flower.png" alpha: 0.1 color: "white" rotationVariation: 180 diff --git a/examples/quick/particles/imageparticle/content/sprites.qml b/examples/quick/particles/imageparticle/sprites.qml index c8ffe6c0e5..3e7d09bdde 100644 --- a/examples/quick/particles/imageparticle/content/sprites.qml +++ b/examples/quick/particles/imageparticle/sprites.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { color: "lightsteelblue" @@ -60,7 +60,7 @@ Rectangle { SpriteSequence { sprites: Sprite { name: "bear" - source: "../../images/bear_tiles.png" + source: "images/bear_tiles.png" frameCount: 13 frameDuration: 120 } @@ -80,25 +80,25 @@ Rectangle { system: sys sprites: [Sprite { name: "happy" - source: "../../images/starfish_1.png" + source: "images/starfish_1.png" frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "angry": 1} }, Sprite { name: "angry" - source: "../../images/starfish_0.png" + source: "images/starfish_0.png" frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "angry": 1} }, Sprite { name: "silly" - source: "../../images/starfish_2.png" + source: "images/starfish_2.png" frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "noticedbear": 0} }, Sprite { name: "noticedbear" - source: "../../images/starfish_3.png" + source: "images/starfish_3.png" frameCount: 1 frameDuration: 2600 }] |