mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Pause ParticleEmitter when not in use (#1284)
* Pause ParticleEmitter when not in use * Use timer instead to pause particle system
This commit is contained in:
parent
e25fd5f4fc
commit
8835040db6
3 changed files with 45 additions and 21 deletions
|
@ -25,6 +25,7 @@ Item {
|
||||||
property var room: null
|
property var room: null
|
||||||
property var roomPreview: null
|
property var roomPreview: null
|
||||||
property bool showBackButton: false
|
property bool showBackButton: false
|
||||||
|
property bool shouldEffectsRun: false
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
onRoomChanged: if (room != null) room.triggerSpecialEffects()
|
onRoomChanged: if (room != null) room.triggerSpecialEffects()
|
||||||
|
@ -344,7 +345,10 @@ Item {
|
||||||
onClicked: Rooms.resetCurrentRoom()
|
onClicked: Rooms.resetCurrentRoom()
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleSystem { id: confettiParticleSystem }
|
ParticleSystem { id: confettiParticleSystem
|
||||||
|
Component.onCompleted: pause();
|
||||||
|
paused: !shouldEffectsRun
|
||||||
|
}
|
||||||
|
|
||||||
Emitter {
|
Emitter {
|
||||||
id: confettiEmitter
|
id: confettiEmitter
|
||||||
|
@ -356,6 +360,7 @@ Item {
|
||||||
emitRate: Math.min(400 * Math.sqrt(parent.width * parent.height) / 870, 1000)
|
emitRate: Math.min(400 * Math.sqrt(parent.width * parent.height) / 870, 1000)
|
||||||
lifeSpan: 15000
|
lifeSpan: 15000
|
||||||
system: confettiParticleSystem
|
system: confettiParticleSystem
|
||||||
|
maximumEmitted: 500
|
||||||
velocityFromMovement: 8
|
velocityFromMovement: 8
|
||||||
size: 16
|
size: 16
|
||||||
sizeVariation: 4
|
sizeVariation: 4
|
||||||
|
@ -365,27 +370,27 @@ Item {
|
||||||
xVariation: Math.min(4 * parent.width / 7, 450)
|
xVariation: Math.min(4 * parent.width / 7, 450)
|
||||||
yVariation: 250
|
yVariation: 250
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImageParticle {
|
ImageParticle {
|
||||||
system: confettiParticleSystem
|
system: confettiParticleSystem
|
||||||
source: "qrc:/confettiparticle.svg"
|
source: "qrc:/confettiparticle.svg"
|
||||||
rotationVelocity: 0
|
rotationVelocity: 0
|
||||||
rotationVelocityVariation: 360
|
rotationVelocityVariation: 360
|
||||||
colorVariation: 1
|
colorVariation: 1
|
||||||
color: "white"
|
color: "white"
|
||||||
entryEffect: ImageParticle.None
|
entryEffect: ImageParticle.None
|
||||||
xVector: PointDirection {
|
xVector: PointDirection {
|
||||||
x: 1
|
x: 1
|
||||||
y: 0
|
y: 0
|
||||||
xVariation: 0.2
|
xVariation: 0.2
|
||||||
yVariation: 0.2
|
yVariation: 0.2
|
||||||
}
|
}
|
||||||
yVector: PointDirection {
|
yVector: PointDirection {
|
||||||
x: 0
|
x: 0
|
||||||
y: 0.5
|
y: 0.5
|
||||||
xVariation: 0.2
|
xVariation: 0.2
|
||||||
yVariation: 0.2
|
yVariation: 0.2
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,6 +406,14 @@ Item {
|
||||||
roomid: room ? room.roomId : ""
|
roomid: room ? room.roomId : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: effectsTimer
|
||||||
|
onTriggered: shouldEffectsRun = false;
|
||||||
|
interval: confettiEmitter.lifeSpan
|
||||||
|
repeat: false
|
||||||
|
running: false
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onOpenReadReceiptsDialog(rr) {
|
function onOpenReadReceiptsDialog(rr) {
|
||||||
var dialog = readReceiptsDialog.createObject(timelineRoot, {
|
var dialog = readReceiptsDialog.createObject(timelineRoot, {
|
||||||
|
@ -424,10 +437,19 @@ Item {
|
||||||
if (!Settings.fancyEffects)
|
if (!Settings.fancyEffects)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
shouldEffectsRun = true;
|
||||||
confettiEmitter.pulse(parent.height * 2)
|
confettiEmitter.pulse(parent.height * 2)
|
||||||
room.markSpecialEffectsDone()
|
room.markSpecialEffectsDone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onConfettiDone()
|
||||||
|
{
|
||||||
|
if (!Settings.fancyEffects)
|
||||||
|
return
|
||||||
|
|
||||||
|
effectsTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
target: room
|
target: room
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1998,6 +1998,7 @@ void
|
||||||
TimelineModel::markSpecialEffectsDone()
|
TimelineModel::markSpecialEffectsDone()
|
||||||
{
|
{
|
||||||
needsSpecialEffects_ = false;
|
needsSpecialEffects_ = false;
|
||||||
|
emit confettiDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
|
|
@ -451,6 +451,7 @@ signals:
|
||||||
void newCallEvent(const mtx::events::collections::TimelineEvents &event);
|
void newCallEvent(const mtx::events::collections::TimelineEvents &event);
|
||||||
void scrollToIndex(int index);
|
void scrollToIndex(int index);
|
||||||
void confetti();
|
void confetti();
|
||||||
|
void confettiDone();
|
||||||
|
|
||||||
void lastMessageChanged();
|
void lastMessageChanged();
|
||||||
void notificationsChanged();
|
void notificationsChanged();
|
||||||
|
|
Loading…
Reference in a new issue