aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/particles/system
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
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')
-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
4 files changed, 48 insertions, 43 deletions
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;