aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/particles/system/dynamicemitters.qml
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2023-03-23 17:12:52 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-25 17:39:09 +0000
commit33beb3ff2ae487cf86adfcb1903fb7e17524692b (patch)
treeaa188f5f4e7c6f9d807a3a31ea486e6cff654305 /examples/quick/particles/system/dynamicemitters.qml
parentee35560dacedfb0264ccdf1c5d4863a6a791e8bb (diff)
Particle system example: qmllint and qsTr()
User facing strings are being translated, and all qmllint warnings are gone. JavaScript statments no longer end with semi-colon, and some whitespace changes have been made. Change-Id: I2a6792800ef3b8a0dc596632dcd3b7d76aa08fe3 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit b65c0ce1339ab44a8bb48e0556c042316f402e51) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quick/particles/system/dynamicemitters.qml')
-rw-r--r--examples/quick/particles/system/dynamicemitters.qml40
1 files changed, 22 insertions, 18 deletions
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
}