summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2023-01-13 20:23:07 -0500
committerGitHub <noreply@github.com>2023-01-14 02:23:07 +0100
commit8835040db61d039af4bab34e36b1e634bb9d1d1f (patch)
treeb1290f7631682f1d9285f706688658926e7b8f22
parente25fd5f4fc889584a6f49db8cfd413e7e8c6d1f3 (diff)
Pause ParticleEmitter when not in use (#1284)
* Pause ParticleEmitter when not in use * Use timer instead to pause particle system
-rw-r--r--resources/qml/TimelineView.qml64
-rw-r--r--src/timeline/TimelineModel.cpp1
-rw-r--r--src/timeline/TimelineModel.h1
3 files changed, 45 insertions, 21 deletions
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index b82cba65..0d47746c 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -25,6 +25,7 @@ Item {
property var room: null
property var roomPreview: null
property bool showBackButton: false
+ property bool shouldEffectsRun: false
clip: true
onRoomChanged: if (room != null) room.triggerSpecialEffects()
@@ -344,7 +345,10 @@ Item {
onClicked: Rooms.resetCurrentRoom()
}
- ParticleSystem { id: confettiParticleSystem }
+ ParticleSystem { id: confettiParticleSystem
+ Component.onCompleted: pause();
+ paused: !shouldEffectsRun
+ }
Emitter {
id: confettiEmitter
@@ -356,6 +360,7 @@ Item {
emitRate: Math.min(400 * Math.sqrt(parent.width * parent.height) / 870, 1000)
lifeSpan: 15000
system: confettiParticleSystem
+ maximumEmitted: 500
velocityFromMovement: 8
size: 16
sizeVariation: 4
@@ -365,27 +370,27 @@ Item {
xVariation: Math.min(4 * parent.width / 7, 450)
yVariation: 250
}
+ }
- ImageParticle {
- system: confettiParticleSystem
- source: "qrc:/confettiparticle.svg"
- rotationVelocity: 0
- rotationVelocityVariation: 360
- colorVariation: 1
- color: "white"
- entryEffect: ImageParticle.None
- xVector: PointDirection {
- x: 1
- y: 0
- xVariation: 0.2
- yVariation: 0.2
- }
- yVector: PointDirection {
- x: 0
- y: 0.5
- xVariation: 0.2
- yVariation: 0.2
- }
+ ImageParticle {
+ system: confettiParticleSystem
+ source: "qrc:/confettiparticle.svg"
+ rotationVelocity: 0
+ rotationVelocityVariation: 360
+ colorVariation: 1
+ color: "white"
+ entryEffect: ImageParticle.None
+ xVector: PointDirection {
+ x: 1
+ y: 0
+ xVariation: 0.2
+ yVariation: 0.2
+ }
+ yVector: PointDirection {
+ x: 0
+ y: 0.5
+ xVariation: 0.2
+ yVariation: 0.2
}
}
@@ -401,6 +406,14 @@ Item {
roomid: room ? room.roomId : ""
}
+ Timer {
+ id: effectsTimer
+ onTriggered: shouldEffectsRun = false;
+ interval: confettiEmitter.lifeSpan
+ repeat: false
+ running: false
+ }
+
Connections {
function onOpenReadReceiptsDialog(rr) {
var dialog = readReceiptsDialog.createObject(timelineRoot, {
@@ -424,10 +437,19 @@ Item {
if (!Settings.fancyEffects)
return
+ shouldEffectsRun = true;
confettiEmitter.pulse(parent.height * 2)
room.markSpecialEffectsDone()
}
+ function onConfettiDone()
+ {
+ if (!Settings.fancyEffects)
+ return
+
+ effectsTimer.start();
+ }
+
target: room
}
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index a6950870..f9df1cf9 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -1998,6 +1998,7 @@ void
TimelineModel::markSpecialEffectsDone()
{
needsSpecialEffects_ = false;
+ emit confettiDone();
}
QString
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 0bf29dc1..334a4d6f 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -451,6 +451,7 @@ signals:
void newCallEvent(const mtx::events::collections::TimelineEvents &event);
void scrollToIndex(int index);
void confetti();
+ void confettiDone();
void lastMessageChanged();
void notificationsChanged();