diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-03-23 17:12:52 +0100 |
---|---|---|
committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-04-20 22:02:39 +0200 |
commit | b65c0ce1339ab44a8bb48e0556c042316f402e51 (patch) | |
tree | 9ea0171c66fbb207ec3174ba6a427059896c3162 /examples/quick | |
parent | 66f167aedce5d9739859bd00dab5c1e1091aacb4 (diff) | |
download | qtdeclarative-b65c0ce1339ab44a8bb48e0556c042316f402e51.tar.gz |
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.
Pick-to: 6.5
Change-Id: I2a6792800ef3b8a0dc596632dcd3b7d76aa08fe3
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/particles/system/dynamiccomparison.qml | 25 | ||||
-rw-r--r-- | examples/quick/particles/system/dynamicemitters.qml | 40 | ||||
-rw-r--r-- | examples/quick/particles/system/multiplepainters.qml | 15 | ||||
-rw-r--r-- | examples/quick/particles/system/startstop.qml | 11 |
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; |