aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/particles
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/particles')
-rw-r--r--examples/quick/particles/CMakeLists.txt3
-rw-r--r--examples/quick/particles/affectors/CMakeLists.txt34
-rw-r--r--examples/quick/particles/affectors/GreyButton.qml2
-rw-r--r--examples/quick/particles/affectors/attractor.qml1
-rw-r--r--examples/quick/particles/affectors/doc/src/affectors.qdoc1
-rw-r--r--examples/quick/particles/affectors/spritegoal.qml3
-rw-r--r--examples/quick/particles/affectors/turbulence.qml1
-rw-r--r--examples/quick/particles/affectors/wander.qml6
-rw-r--r--examples/quick/particles/emitters/CMakeLists.txt34
-rw-r--r--examples/quick/particles/emitters/customemitter.qml6
-rw-r--r--examples/quick/particles/emitters/doc/src/emitters.qdoc1
-rw-r--r--examples/quick/particles/emitters/velocityfrommotion.qml12
-rw-r--r--examples/quick/particles/imageparticle/CMakeLists.txt34
-rw-r--r--examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc1
-rw-r--r--examples/quick/particles/itemparticle/CMakeLists.txt50
-rw-r--r--examples/quick/particles/itemparticle/delegates.qml58
-rw-r--r--examples/quick/particles/itemparticle/images/rocket.pngbin7315 -> 0 bytes
-rw-r--r--examples/quick/particles/itemparticle/itemparticle.pro10
-rw-r--r--examples/quick/particles/itemparticle/itemparticle.qml262
-rw-r--r--examples/quick/particles/itemparticle/itemparticle.qrc8
-rw-r--r--examples/quick/particles/itemparticle/main.cpp4
-rw-r--r--examples/quick/particles/itemparticle/script.js27
-rw-r--r--examples/quick/particles/particles.pro1
-rw-r--r--examples/quick/particles/system/CMakeLists.txt34
-rw-r--r--examples/quick/particles/system/doc/src/system.qdoc1
-rw-r--r--examples/quick/particles/system/dynamiccomparison.qml25
-rw-r--r--examples/quick/particles/system/dynamicemitters.qml40
-rw-r--r--examples/quick/particles/system/multiplepainters.qml15
-rw-r--r--examples/quick/particles/system/startstop.qml11
29 files changed, 133 insertions, 552 deletions
diff --git a/examples/quick/particles/CMakeLists.txt b/examples/quick/particles/CMakeLists.txt
index d34300510f..ce9658b74a 100644
--- a/examples/quick/particles/CMakeLists.txt
+++ b/examples/quick/particles/CMakeLists.txt
@@ -1,8 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(affectors)
qt_internal_add_example(emitters)
qt_internal_add_example(imageparticle)
-qt_internal_add_example(itemparticle)
qt_internal_add_example(system)
diff --git a/examples/quick/particles/affectors/CMakeLists.txt b/examples/quick/particles/affectors/CMakeLists.txt
index 5f710fbdd8..dc29e1787b 100644
--- a/examples/quick/particles/affectors/CMakeLists.txt
+++ b/examples/quick/particles/affectors/CMakeLists.txt
@@ -1,18 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(affectors LANGUAGES CXX)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/affectors")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-qt_standard_project_setup()
+qt_standard_project_setup(REQUIRES 6.5)
add_subdirectory("../../shared" "shared")
@@ -21,10 +15,10 @@ qt_add_executable(affectorsexample WIN32 MACOSX_BUNDLE
)
target_link_libraries(affectorsexample PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
add_dependencies(affectorsexample affectors_shared)
@@ -32,7 +26,6 @@ add_dependencies(affectorsexample affectors_shared)
# Resources:
qt_add_qml_module(affectorsexample
URI affectors
- AUTO_RESOURCE_PREFIX
QML_FILES
"affectors.qml"
"GreyButton.qml"
@@ -65,9 +58,16 @@ qt_add_qml_module(affectorsexample
)
install(TARGETS affectorsexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-bundle_shared(affectorsexample)
+qt_generate_deploy_qml_app_script(
+ TARGET affectorsexample
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/particles/affectors/GreyButton.qml b/examples/quick/particles/affectors/GreyButton.qml
index 0d29246c2b..412a6dfa60 100644
--- a/examples/quick/particles/affectors/GreyButton.qml
+++ b/examples/quick/particles/affectors/GreyButton.qml
@@ -6,7 +6,7 @@ import QtQuick
Item {
id: container
- property string text: "Button"
+ required property string text
property string subText: ""
signal clicked
diff --git a/examples/quick/particles/affectors/attractor.qml b/examples/quick/particles/affectors/attractor.qml
index a0793b5fed..c5b95ee2a0 100644
--- a/examples/quick/particles/affectors/attractor.qml
+++ b/examples/quick/particles/affectors/attractor.qml
@@ -69,7 +69,6 @@ Rectangle {
groups: ["engine"]
source: "qrc:///particleresources/fuzzydot.png"
- color: "orange"
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation {
diff --git a/examples/quick/particles/affectors/doc/src/affectors.qdoc b/examples/quick/particles/affectors/doc/src/affectors.qdoc
index 5d98029b44..73f99aabed 100644
--- a/examples/quick/particles/affectors/doc/src/affectors.qdoc
+++ b/examples/quick/particles/affectors/doc/src/affectors.qdoc
@@ -4,6 +4,7 @@
/*!
\title Qt Quick Particles Examples - Affectors
\example particles/affectors
+ \examplecategory {Graphics}
\brief This is a collection of examples using Affectors in the QML particle system.
\image qml-affectors-example.png
diff --git a/examples/quick/particles/affectors/spritegoal.qml b/examples/quick/particles/affectors/spritegoal.qml
index 8d157be7d9..98d793d304 100644
--- a/examples/quick/particles/affectors/spritegoal.qml
+++ b/examples/quick/particles/affectors/spritegoal.qml
@@ -114,7 +114,7 @@ Item {
id: circle
x: root.width / 1.2
y: root.height / 1.7
- property real percent: 0
+ property real percent
SequentialAnimation on percent {
id: circleAnim1
@@ -135,7 +135,6 @@ Item {
groups: ["exhaust"]
source: "qrc:///particleresources/fuzzydot.png"
- color: "orange"
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation {
diff --git a/examples/quick/particles/affectors/turbulence.qml b/examples/quick/particles/affectors/turbulence.qml
index dac3a5c46d..049e1a584d 100644
--- a/examples/quick/particles/affectors/turbulence.qml
+++ b/examples/quick/particles/affectors/turbulence.qml
@@ -31,7 +31,6 @@ Rectangle {
width: parent.width
x: parent. width / 4
anchors.fill: parent
- strength: 32
NumberAnimation on strength{from: 16; to: 64; easing.type: Easing.InOutBounce; duration: 1800; loops: -1}
}
//! [0]
diff --git a/examples/quick/particles/affectors/wander.qml b/examples/quick/particles/affectors/wander.qml
index e93bfe200c..c4c2914d49 100644
--- a/examples/quick/particles/affectors/wander.qml
+++ b/examples/quick/particles/affectors/wander.qml
@@ -45,15 +45,15 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 4
GreyButton {
- text:"dx/dt"
+ text: qsTr("dx/dt")
onClicked: wanderer.affectedParameter = Wander.Position;
}
GreyButton {
- text:"dv/dt"
+ text: qsTr("dv/dt")
onClicked: wanderer.affectedParameter = Wander.Velocity;
}
GreyButton {
- text:"da/dt"
+ text: qsTr("da/dt")
onClicked: wanderer.affectedParameter = Wander.Acceleration;
}
}
diff --git a/examples/quick/particles/emitters/CMakeLists.txt b/examples/quick/particles/emitters/CMakeLists.txt
index 8bb31beba6..772f45fa0a 100644
--- a/examples/quick/particles/emitters/CMakeLists.txt
+++ b/examples/quick/particles/emitters/CMakeLists.txt
@@ -1,18 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(emitters LANGUAGES CXX)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/emitters")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-qt_standard_project_setup()
+qt_standard_project_setup(REQUIRES 6.5)
add_subdirectory("../../shared" "shared")
@@ -21,10 +15,10 @@ qt_add_executable(emittersexample WIN32 MACOSX_BUNDLE
)
target_link_libraries(emittersexample PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
add_dependencies(emittersexample emitters_shared)
@@ -32,7 +26,6 @@ add_dependencies(emittersexample emitters_shared)
# Resources:
qt_add_qml_module(emittersexample
URI emitters
- AUTO_RESOURCE_PREFIX
QML_FILES
"burstandpulse.qml"
"customemitter.qml"
@@ -48,9 +41,16 @@ qt_add_qml_module(emittersexample
)
install(TARGETS emittersexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-bundle_shared(emittersexample)
+qt_generate_deploy_qml_app_script(
+ TARGET emittersexample
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/particles/emitters/customemitter.qml b/examples/quick/particles/emitters/customemitter.qml
index 5aba7d1b9f..ed23d68720 100644
--- a/examples/quick/particles/emitters/customemitter.qml
+++ b/examples/quick/particles/emitters/customemitter.qml
@@ -16,7 +16,7 @@ ParticleSystem {
}
property real petalLength: 180
- property real petalRotation: 0
+ property real petalRotation
NumberAnimation on petalRotation {
from: 0;
to: 360;
@@ -34,9 +34,9 @@ ParticleSystem {
//! [0]
onEmitParticles: (particles) => {
for (var i=0; i<particles.length; i++) {
- var particle = particles[i];
+ let particle = particles[i];
particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
- var theta = Math.floor(Math.random() * 6.0);
+ let theta = Math.floor(Math.random() * 6.0);
particle.red = theta == 0 || theta == 1 || theta == 2 ? 0.2 : 1;
particle.green = theta == 2 || theta == 3 || theta == 4 ? 0.2 : 1;
particle.blue = theta == 4 || theta == 5 || theta == 0 ? 0.2 : 1;
diff --git a/examples/quick/particles/emitters/doc/src/emitters.qdoc b/examples/quick/particles/emitters/doc/src/emitters.qdoc
index db06577422..51a1ac308a 100644
--- a/examples/quick/particles/emitters/doc/src/emitters.qdoc
+++ b/examples/quick/particles/emitters/doc/src/emitters.qdoc
@@ -3,6 +3,7 @@
/*!
\title Qt Quick Particles Examples - Emitters
\example particles/emitters
+ \examplecategory {Graphics}
\brief This is a collection of examples using Emitters in the QML particle system.
\image qml-emitters-example.png
diff --git a/examples/quick/particles/emitters/velocityfrommotion.qml b/examples/quick/particles/emitters/velocityfrommotion.qml
index df8070e768..aa65ac7d9e 100644
--- a/examples/quick/particles/emitters/velocityfrommotion.qml
+++ b/examples/quick/particles/emitters/velocityfrommotion.qml
@@ -25,7 +25,6 @@ Rectangle {
ImageParticle {
system: sys1
source: "qrc:///particleresources/glowdot.png"
- color: "cyan"
alpha: 0
SequentialAnimation on color {
loops: Animation.Infinite
@@ -73,7 +72,6 @@ Rectangle {
//! [0]
ParticleSystem { id: sys2 }
ImageParticle {
- color: "cyan"
system: sys2
alpha: 0
SequentialAnimation on color {
@@ -114,7 +112,6 @@ Rectangle {
ImageParticle {
source: "qrc:///particleresources/glowdot.png"
system: sys3
- color: "orange"
alpha: 0
SequentialAnimation on color {
loops: Animation.Infinite
@@ -155,7 +152,6 @@ Rectangle {
ImageParticle {
system: sys4
source: "qrc:///particleresources/star.png"
- color: "green"
alpha: 0
SequentialAnimation on color {
loops: Animation.Infinite
@@ -199,12 +195,12 @@ Rectangle {
Item {
id: circle
//anchors.fill: parent
- property real radius: 0
+ property real radius
property real dx: root.width / 2
property real dy: root.height / 2
property real cx: radius * Math.sin(percent*6.283185307179) + dx
property real cy: radius * Math.cos(percent*6.283185307179) + dy
- property real percent: 0
+ property real percent
SequentialAnimation on percent {
loops: Animation.Infinite
@@ -247,7 +243,7 @@ Rectangle {
property real dy: root.height / 2
property real cx: radius * Math.sin(percent*6.283185307179) + dx
property real cy: radius * Math.cos(percent*6.283185307179) + dy
- property real percent: 0
+ property real percent
SequentialAnimation on percent {
loops: Animation.Infinite
@@ -263,7 +259,7 @@ Rectangle {
property real dy: circle3.cy
property real cx: radius * Math.sin(percent*6.283185307179) + dx
property real cy: radius * Math.cos(percent*6.283185307179) + dy
- property real percent: 0
+ property real percent
SequentialAnimation on percent {
loops: Animation.Infinite
diff --git a/examples/quick/particles/imageparticle/CMakeLists.txt b/examples/quick/particles/imageparticle/CMakeLists.txt
index 1bc4acd678..c587d9bcc3 100644
--- a/examples/quick/particles/imageparticle/CMakeLists.txt
+++ b/examples/quick/particles/imageparticle/CMakeLists.txt
@@ -1,18 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(imageparticle LANGUAGES CXX)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/imageparticle")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-qt_standard_project_setup()
+qt_standard_project_setup(REQUIRES 6.5)
add_subdirectory("../../shared" "shared")
@@ -21,10 +15,10 @@ qt_add_executable(imageparticleexample WIN32 MACOSX_BUNDLE
)
target_link_libraries(imageparticleexample PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
add_dependencies(imageparticleexample imageparticle_shared)
@@ -32,7 +26,6 @@ add_dependencies(imageparticleexample imageparticle_shared)
# Resources:
qt_add_qml_module(imageparticleexample
URI imageparticle
- AUTO_RESOURCE_PREFIX
QML_FILES
"allatonce.qml"
"colored.qml"
@@ -54,9 +47,16 @@ qt_add_qml_module(imageparticleexample
)
install(TARGETS imageparticleexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-bundle_shared(imageparticleexample)
+qt_generate_deploy_qml_app_script(
+ TARGET imageparticleexample
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
index d4c8c5d66b..4bbbc6a430 100644
--- a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
+++ b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
@@ -4,6 +4,7 @@
/*!
\title Qt Quick Particles Examples - Image Particles
\example particles/imageparticle
+ \examplecategory {Graphics}
\brief This is a collection of examples using Affectors in the QML particle system.
\image qml-imageparticle-example.png
diff --git a/examples/quick/particles/itemparticle/CMakeLists.txt b/examples/quick/particles/itemparticle/CMakeLists.txt
deleted file mode 100644
index 77fe5a4961..0000000000
--- a/examples/quick/particles/itemparticle/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(itemparticle LANGUAGES CXX)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/itemparticle")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-
-qt_standard_project_setup()
-
-add_subdirectory("../../shared" "shared")
-
-qt_add_executable(itemparticleexample WIN32 MACOSX_BUNDLE
- main.cpp
-)
-
-target_link_libraries(itemparticleexample PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
-)
-
-add_dependencies(itemparticleexample itemparticle_shared)
-
-# Resources:
-qt_add_qml_module(itemparticleexample
- URI itemparticle
- AUTO_RESOURCE_PREFIX
- QML_FILES
- "itemparticle.qml"
- "delegates.qml"
- "script.js"
- RESOURCES
- "images/rocket.png"
-)
-
-install(TARGETS itemparticleexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-
-bundle_shared(itemparticleexample)
diff --git a/examples/quick/particles/itemparticle/delegates.qml b/examples/quick/particles/itemparticle/delegates.qml
deleted file mode 100644
index 35bbbc7132..0000000000
--- a/examples/quick/particles/itemparticle/delegates.qml
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Particles
-
-Rectangle {
- id: root;
- width: 360
- height: 600
- color: "black"
-
- function newPithySaying() {
- switch (Math.floor(Math.random()*16)) {
- case 0: return "Hello World";
- case 1: return "G'day Mate";
- case 2: return "Code Less";
- case 3: return "Create More";
- case 4: return "Deploy Everywhere";
- case 5: return "Qt Meta-object Language";
- case 6: return "Qt Magic Language";
- case 7: return "Fluid UIs";
- case 8: return "Touchable";
- case 9: return "How's it going?";
- case 10: return "Do you like text?";
- case 11: return "Enjoy!";
- case 12: return "ERROR: Out of pith";
- case 13: return "Punctuation Failure";
- case 14: return "I can go faster";
- case 15: return "I can go slower";
- default: return "OMGWTFBBQ";
- }
- }
-
- ParticleSystem {
- anchors.fill: parent
- id: syssy
- MouseArea {
- anchors.fill: parent
- onClicked: syssy.running = !syssy.running
- }
- Emitter {
- anchors.centerIn: parent
- emitRate: 1
- lifeSpan: 4800
- lifeSpanVariation: 1600
- velocity: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20}
- }
- ItemParticle {
- delegate: Text {
- text: root.newPithySaying();
- color: "white"
- font.pixelSize: 18
- font.bold: true
- }
- }
- }
-}
diff --git a/examples/quick/particles/itemparticle/images/rocket.png b/examples/quick/particles/itemparticle/images/rocket.png
deleted file mode 100644
index a171610b03..0000000000
--- a/examples/quick/particles/itemparticle/images/rocket.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/particles/itemparticle/itemparticle.pro b/examples/quick/particles/itemparticle/itemparticle.pro
deleted file mode 100644
index c0426cd032..0000000000
--- a/examples/quick/particles/itemparticle/itemparticle.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-
-QT += quick qml
-SOURCES += main.cpp
-RESOURCES += \
- itemparticle.qrc \
- ../../shared/shared.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/itemparticle
-INSTALLS += target
diff --git a/examples/quick/particles/itemparticle/itemparticle.qml b/examples/quick/particles/itemparticle/itemparticle.qml
deleted file mode 100644
index 6655dde939..0000000000
--- a/examples/quick/particles/itemparticle/itemparticle.qml
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Particles
-import shared
-import "script.js" as Script
-
-Item {
- id: root
- width: 640
- height: 480
- Rectangle {
- anchors.fill: parent
- color: "black"
- z: -1
- }
- Item {
- id: loading
- Behavior on opacity {NumberAnimation {}}
- anchors.fill: parent
- Text {
- anchors.centerIn: parent
- text: "Loading"
- color: "white"
- }
- }
- ParticleSystem {
- id: sys;
- running: true
- }
- Emitter {
- id: emitter
- system: sys
- height: parent.height - 132/2
- x: -132/2
- y: 132/2
- velocity: PointDirection { x: 32; xVariation: 8 }
- emitRate: 0.5
- lifeSpan: Emitter.InfiniteLife
- group: "photos"
- }
- Age {
- system: sys
- x: parent.width + 132/2
- height: parent.height
- width: 1000
- }
- ImageParticle {
- system: sys
- groups: ["fireworks"]
- source: "qrc:///particleresources/star.png"
- color: "lightsteelblue"
- alpha: 0
- colorVariation: 0
- z: 1000
- }
- ItemParticle {
- id: mp
- z: 0
- system: sys
- fade: false
- groups: ["photos"]
- }
- Component {
- id: alertDelegate
- Rectangle {
- color: "DarkSlateGray"
- border.width: 1
- border.color: "LightSteelBlue"
- width: 144
- height: 132
- antialiasing: true
- radius: 3
- NumberAnimation on scale {
- running: true
- loops: 1
- from: 0.2
- to: 1
- }
- Image {
- source: "images/rocket.png"
- anchors.centerIn: parent
- }
- Text {
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- text: "A new ship has arrived!"
- color: "LightSteelBlue"
- }
- }
- }
- property Item alertItem;
- function alert() {
- force.enabled = true;
- alertItem = alertDelegate.createObject(root);
- alertItem.x = root.width/2 - alertItem.width/2
- alertItem.y = root.height/2 - alertItem.height/2
- spawnFireworks.pulse(200);
- stopAlert.start();
- }
- focus: true
- Keys.onSpacePressed: alert();
- Timer {
- id: stopAlert
- running: false
- repeat: false
- interval: 800
- onTriggered: {
- force.enabled = false;
- mp.take(root.alertItem, true);
- centerEmitter.burst(1);
- }
- }
- Attractor {
- id: force
- system: sys
- pointX: root.width/2
- pointY: root.height/2
- strength: -10000
- enabled: false
- anchors.centerIn: parent
- width: parent.width/2
- height: parent.height/2
- groups:["photos"]
- affectedParameter: Attractor.Position
- }
- Emitter {
- id: centerEmitter
- velocity: PointDirection { x: 32; xVariation: 8;}
- emitRate: 0.5
- lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
- maximumEmitted: 20
- group: "photos"
- system: sys
- anchors.centerIn: parent
- enabled: false
-
- //TODO: Zoom in effect
- }
- Emitter {
- id: spawnFireworks
- group: "fireworks"
- system: sys
- maximumEmitted: 400
- emitRate: 400
- lifeSpan: 2800
- x: parent.width/2
- y: parent.height/2 - 64
- width: 8
- height: 8
- enabled: false
- size: 32
- endSize: 8
- velocity: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
- acceleration: PointDirection { y: 160 }
- }
- Item { x: -1000; y: -1000 //offscreen
- Repeater {//Load them here, add to system on completed
- model: flickrModel
- delegate: theDelegate
- }
- }
- FlickrRssModel {
- id: flickrModel
- tags: "particle,particles"
- }
- Component {
- id: theDelegate
- Image {
- required property int index
- required property string title
- required property string media
- required property string thumbnail
-
- id: image
- antialiasing: true;
- source: thumbnail
- cache: true
- property real depth: Math.random()
- property real darken: 0.75
- z: Math.floor(depth * 100)
- scale: (depth + 1) / 2
- sourceSize {
- width: root.width
- height: root.height
- }
- width: 132
- height: 132
- fillMode: Image.PreserveAspectFit
- Rectangle {
- // Darken based on depth
- anchors.centerIn: parent
- width: parent.paintedWidth + 1
- height: parent.paintedHeight + 1
- color: "black"
- opacity: image.darken * (1 - image.depth)
- antialiasing: true;
- }
- Text {
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottomMargin: Math.max(parent.paintedWidth, parent.paintedHeight) - Math.min(parent.width, parent.height)
- width: parent.paintedWidth - 4
- horizontalAlignment: Text.AlignHCenter
- elide: Text.ElideRight
- text: image.title
- color: "black"
- }
- ItemParticle.onDetached: mp.take(image); // respawns
- onStatusChanged: if (image.status == Image.Ready) {
- loading.opacity = 0;
- mp.take(image);
- }
- function manage()
- {
- if (state == "selected") {
- console.log("Taking " + index);
- mp.freeze(image);
- } else {
- console.log("Returning " +index);
- mp.unfreeze(image);
- }
- }
- TapHandler {
- gesturePolicy: TapHandler.ReleaseWithinBounds
- onTapped: image.state = (image.state == "" ? "selected" : "")
- }
- states: State {
- name: "selected"
- ParentChange {
- target: image
- parent: root
- }
- PropertyChanges {
- image {
- source: image.media
- x: 0
- y: 0
- width: root.width
- height: root.height
- z: 101
- opacity: 1
- rotation: 0
- darken: 0
- }
- }
- }
- transitions: Transition {
- to: "selected"
- reversible: true
- SequentialAnimation {
- ScriptAction { script: image.manage() }
- ParallelAnimation {
- ParentAnimation {NumberAnimation { properties: "x,y" }}
- PropertyAnimation { properties: "width, height, z, rotation, darken"; easing.type: Easing.InOutQuad }
- }
- }
- }
- }
- }
-}
diff --git a/examples/quick/particles/itemparticle/itemparticle.qrc b/examples/quick/particles/itemparticle/itemparticle.qrc
deleted file mode 100644
index d345d2a957..0000000000
--- a/examples/quick/particles/itemparticle/itemparticle.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<RCC>
- <qresource prefix="/qt/qml/itemparticle">
- <file>itemparticle.qml</file>
- <file>delegates.qml</file>
- <file>script.js</file>
- <file>images/rocket.png</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/particles/itemparticle/main.cpp b/examples/quick/particles/itemparticle/main.cpp
deleted file mode 100644
index 8baca3753c..0000000000
--- a/examples/quick/particles/itemparticle/main.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(itemparticle/itemparticle)
diff --git a/examples/quick/particles/itemparticle/script.js b/examples/quick/particles/itemparticle/script.js
deleted file mode 100644
index e8ef93a847..0000000000
--- a/examples/quick/particles/itemparticle/script.js
+++ /dev/null
@@ -1,27 +0,0 @@
-.pragma library
-
-function getWidth(string) {
- return (string.match(/width=\"([0-9]+)\"/))[1]
-}
-
-function getHeight(string) {
- return (string.match(/height=\"([0-9]+)\"/))[1]
-}
-
-function getImagePath(string) {
- var pattern = /src=\"http:\/\/(\S+)\"/
- return (string.match(pattern))[1]
-}
-
-function calculateScale(width, height, cellSize) {
- var widthScale = (cellSize * 1.0) / width
- var heightScale = (cellSize * 1.0) / height
- var scale = 0
-
- if (widthScale <= heightScale) {
- scale = widthScale;
- } else if (heightScale < widthScale) {
- scale = heightScale;
- }
- return scale;
-}
diff --git a/examples/quick/particles/particles.pro b/examples/quick/particles/particles.pro
index 7ef86618d5..62f7f35807 100644
--- a/examples/quick/particles/particles.pro
+++ b/examples/quick/particles/particles.pro
@@ -2,7 +2,6 @@ TEMPLATE = subdirs
SUBDIRS += affectors \
emitters \
imageparticle \
- itemparticle \
system
#Install shared images too
diff --git a/examples/quick/particles/system/CMakeLists.txt b/examples/quick/particles/system/CMakeLists.txt
index d224d607ce..0c8f8852f9 100644
--- a/examples/quick/particles/system/CMakeLists.txt
+++ b/examples/quick/particles/system/CMakeLists.txt
@@ -1,18 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(system LANGUAGES CXX)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/system")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-qt_standard_project_setup()
+qt_standard_project_setup(REQUIRES 6.5)
add_subdirectory("../../shared" "shared")
@@ -21,10 +15,10 @@ qt_add_executable(systemexample WIN32 MACOSX_BUNDLE
)
target_link_libraries(systemexample PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
add_dependencies(systemexample system_shared)
@@ -32,7 +26,6 @@ add_dependencies(systemexample system_shared)
# Resources:
qt_add_qml_module(systemexample
URI system
- AUTO_RESOURCE_PREFIX
QML_FILES
"dynamiccomparison.qml"
"dynamicemitters.qml"
@@ -47,9 +40,16 @@ qt_add_qml_module(systemexample
)
install(TARGETS systemexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-bundle_shared(systemexample)
+qt_generate_deploy_qml_app_script(
+ TARGET systemexample
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/particles/system/doc/src/system.qdoc b/examples/quick/particles/system/doc/src/system.qdoc
index da10dfdac0..b936bd8976 100644
--- a/examples/quick/particles/system/doc/src/system.qdoc
+++ b/examples/quick/particles/system/doc/src/system.qdoc
@@ -4,6 +4,7 @@
/*!
\title Qt Quick Particles Examples - System
\example particles/system
+ \examplecategory {Graphics}
\brief This is a collection of examples using Affectors in the QML particle system.
\image qml-system-example.png
diff --git a/examples/quick/particles/system/dynamiccomparison.qml b/examples/quick/particles/system/dynamiccomparison.qml
index 0d8b4cc399..d29b72f998 100644
--- a/examples/quick/particles/system/dynamiccomparison.qml
+++ b/examples/quick/particles/system/dynamiccomparison.qml
@@ -4,6 +4,8 @@
import QtQuick
import QtQuick.Particles
+pragma ComponentBehavior: Bound
+
Rectangle {
id: root
color: "black"
@@ -38,11 +40,11 @@ Rectangle {
id: fakeEmitter
function burst(number) {
while (number > 0) {
- var item = fakeParticle.createObject(root);
- item.lifeSpan = Math.random() * 5000 + 5000;
- item.x = Math.random() * (root.width/2) + (root.width/2);
- item.y = 0;
- number--;
+ let item = fakeParticle.createObject(root)
+ item.lifeSpan = Math.random() * 5000 + 5000
+ item.x = Math.random() * (root.width / 2) + (root.width / 2)
+ item.y = 0
+ number--
}
}
@@ -54,13 +56,12 @@ Rectangle {
width: 32
height: 32
source: "qrc:///particleresources/glowdot.png"
- y: 0
- PropertyAnimation on y {from: -16; to: root.height-16; duration: container.lifeSpan; running: true}
+ PropertyAnimation on y { from: -16; to: root.height - 16; duration: container.lifeSpan; running: true }
SequentialAnimation on opacity {
running: true
- NumberAnimation { from:0; to: 1; duration: 500}
- PauseAnimation { duration: container.lifeSpan - 1000}
- NumberAnimation { from:1; to: 0; duration: 500}
+ NumberAnimation { from: 0; to: 1; duration: 500 }
+ PauseAnimation { duration: container.lifeSpan - 1000 }
+ NumberAnimation { from: 1; to: 0; duration: 500 }
ScriptAction { script: container.destroy(); }
}
}
@@ -82,7 +83,7 @@ Rectangle {
Text {
anchors.left: parent.left
anchors.bottom: parent.bottom
- text: "1000 particles"
+ text: qsTr("1000 particles")
color: "white"
MouseArea {
anchors.fill: parent
@@ -92,7 +93,7 @@ Rectangle {
Text {
anchors.right: parent.right
anchors.bottom: parent.bottom
- text: "1000 items"
+ text: qsTr("1000 items")
color: "white"
MouseArea {
anchors.fill: parent
diff --git a/examples/quick/particles/system/dynamicemitters.qml b/examples/quick/particles/system/dynamicemitters.qml
index 29f9235ac8..31c70b2a6c 100644
--- a/examples/quick/particles/system/dynamicemitters.qml
+++ b/examples/quick/particles/system/dynamicemitters.qml
@@ -4,6 +4,8 @@
import QtQuick
import QtQuick.Particles
+pragma ComponentBehavior: Bound
+
Rectangle {
id: root
color: "black"
@@ -31,15 +33,18 @@ Rectangle {
lifeSpan: 600
size: 16
endSize: 8
- velocity: AngleDirection {angleVariation:360; magnitude: 60}
+ velocity: AngleDirection {
+ angleVariation: 360
+ magnitude: 60
+ }
}
property int life: 2600
property real targetX: 0
property real targetY: 0
function go() {
- xAnim.start();
- yAnim.start();
+ xAnim.start()
+ yAnim.start()
container.enabled = true
}
system: sys
@@ -49,35 +54,35 @@ Rectangle {
endSize: 8
NumberAnimation on x {
id: xAnim;
- to: targetX
- duration: life
+ to: container.targetX
+ duration: container.life
running: false
}
NumberAnimation on y {
id: yAnim;
- to: targetY
- duration: life
+ to: container.targetY
+ duration: container.life
running: false
}
Timer {
- interval: life
+ interval: container.life
running: true
- onTriggered: container.destroy();
+ onTriggered: container.destroy()
}
}
}
- function customEmit(x,y) {
+ function customEmit(x, y) {
//! [0]
- for (var i=0; i<8; i++) {
- var obj = emitterComp.createObject(root);
+ for (var i = 0; i < 8; i++) {
+ let obj = emitterComp.createObject(root)
obj.x = x
obj.y = y
obj.targetX = Math.random() * 240 - 120 + obj.x
obj.targetY = Math.random() * 240 - 120 + obj.y
obj.life = Math.round(Math.random() * 2400) + 200
obj.emitRate = Math.round(Math.random() * 32) + 32
- obj.go();
+ obj.go()
}
//! [0]
}
@@ -87,16 +92,15 @@ Rectangle {
triggeredOnStart: true
running: true
repeat: true
- onTriggered: customEmit(Math.random() * 320, Math.random() * 480)
+ onTriggered: root.customEmit(Math.random() * 320, Math.random() * 480)
}
- MouseArea {
- anchors.fill: parent
- onClicked: (mouse)=> customEmit(mouse.x, mouse.y);
+ TapHandler {
+ onTapped: function(event) { root.customEmit(event.pressPosition.x, event.pressPosition.y) }
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
- text: "Click Somewhere"
+ text: qsTr("Click Somewhere")
color: "white"
font.pixelSize: 24
}
diff --git a/examples/quick/particles/system/multiplepainters.qml b/examples/quick/particles/system/multiplepainters.qml
index dbbe3abed5..5356f5fe8a 100644
--- a/examples/quick/particles/system/multiplepainters.qml
+++ b/examples/quick/particles/system/multiplepainters.qml
@@ -13,13 +13,12 @@ Rectangle {
ParticleSystem {
id: sys
}
- MouseArea {
- anchors.fill: parent
- onClicked: cloneMode = !cloneMode;
+ TapHandler {
+ onTapped: root.cloneMode = !root.cloneMode
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
- text: "Click to Toggle"
+ text: qsTr("Click to Toggle")
color: "white"
font.pixelSize: 24
}
@@ -30,18 +29,18 @@ Rectangle {
emitRate: 200
lifeSpan: 4000
startTime: 4000
- velocity: PointDirection { y: -120; }
+ velocity: PointDirection { y: -120 }
}
ImageParticle {
system: sys
- visible: !cloneMode
+ visible: !root.cloneMode
source: "images/particle2.png"
}
ImageParticle {
system: sys
- visible: cloneMode
+ visible: root.cloneMode
z: 0
source: "images/particle3.png"
}
@@ -49,7 +48,7 @@ Rectangle {
ImageParticle {
system: sys
clip: true
- visible: cloneMode
+ visible: root.cloneMode
y: 120
height: 240
width: root.width
diff --git a/examples/quick/particles/system/startstop.qml b/examples/quick/particles/system/startstop.qml
index e275a4410b..e89c1f40f0 100644
--- a/examples/quick/particles/system/startstop.qml
+++ b/examples/quick/particles/system/startstop.qml
@@ -9,15 +9,16 @@ Rectangle {
height: 540
color: "black"
Text {
- text: "Left click to start/stop\nRight click to pause/unpause"
+ text: qsTr("Left click to start/stop\nRight click to pause/unpause")
color: "white"
font.pixelSize: 24
}
- MouseArea {
- anchors.fill: parent
+
+ TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: (mouse) => {
- if (mouse.button == Qt.LeftButton)
+ onTapped: function (event, mouseButton)
+ {
+ if (mouseButton === Qt.LeftButton)
particles.running = !particles.running
else
particles.paused = !particles.paused;