Introduce fancy particle effects. Contributes to #261
Add user setting. Introduce FancyEffectsContainer. And confetti and snow implementation.
This commit is contained in:
committed by
Carl Schwan
parent
cd17339847
commit
e7a862a1d9
131
imports/NeoChat/Component/FancyEffectsContainer.qml
Normal file
131
imports/NeoChat/Component/FancyEffectsContainer.qml
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||||
|
*/
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12 as Controls
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtQuick.Particles 2.12
|
||||||
|
|
||||||
|
import org.kde.kirigami 2.4 as Kirigami
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: item
|
||||||
|
property bool enabled: false
|
||||||
|
property int effectInterval: Kirigami.Units.veryLongDuration*10;
|
||||||
|
|
||||||
|
function showConfettiEffect() {
|
||||||
|
confettiTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSnowEffect() {
|
||||||
|
snowTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFireworkEffect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: confettiTimer
|
||||||
|
interval: item.effectInterval;
|
||||||
|
running: false;
|
||||||
|
repeat: false;
|
||||||
|
triggeredOnStart: true;
|
||||||
|
onTriggered: {
|
||||||
|
if (item.enabled) {
|
||||||
|
confettiSystem.running = !confettiSystem.running
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleSystem {
|
||||||
|
id: confettiSystem
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
running: false
|
||||||
|
onRunningChanged: {
|
||||||
|
visible = running
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemParticle {
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: Kirigami.Units.iconSizes.small
|
||||||
|
height: Kirigami.Units.iconSizes.smallMedium
|
||||||
|
color: Qt.hsla(Math.random(), 0.5, 0.6, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Emitter {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeVariation: Kirigami.Units.iconSizes.medium
|
||||||
|
lifeSpan: Kirigami.Units.veryLongDuration*10
|
||||||
|
size: Kirigami.Units.iconSizes.large
|
||||||
|
|
||||||
|
velocity: AngleDirection {
|
||||||
|
angle: 90
|
||||||
|
angleVariation: 42
|
||||||
|
magnitude: 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: snowTimer
|
||||||
|
interval: item.effectInterval;
|
||||||
|
running: false;
|
||||||
|
repeat: false;
|
||||||
|
triggeredOnStart: true;
|
||||||
|
onTriggered: {
|
||||||
|
if (item.enabled) {
|
||||||
|
snowSystem.running = !snowSystem.running
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleSystem {
|
||||||
|
id: snowSystem
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
running: false
|
||||||
|
onRunningChanged: {
|
||||||
|
visible = running
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemParticle {
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: 10
|
||||||
|
height: width
|
||||||
|
radius: width
|
||||||
|
color: "white"
|
||||||
|
scale: Math.random()
|
||||||
|
opacity: Math.random()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Emitter {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeVariation: Kirigami.Units.iconSizes.medium
|
||||||
|
lifeSpan: Kirigami.Units.veryLongDuration*10
|
||||||
|
size: Kirigami.Units.iconSizes.large
|
||||||
|
emitRate: 42
|
||||||
|
|
||||||
|
velocity: AngleDirection {
|
||||||
|
angle: 90
|
||||||
|
angleVariation: 10
|
||||||
|
magnitude: 300
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,3 +2,4 @@ module NeoChat.Component
|
|||||||
AutoMouseArea 1.0 AutoMouseArea.qml
|
AutoMouseArea 1.0 AutoMouseArea.qml
|
||||||
FullScreenImage 1.0 FullScreenImage.qml
|
FullScreenImage 1.0 FullScreenImage.qml
|
||||||
ChatTextInput 1.0 ChatTextInput.qml
|
ChatTextInput 1.0 ChatTextInput.qml
|
||||||
|
FancyEffectsContainer 1.0 FancyEffectsContainer.qml
|
||||||
|
|||||||
@@ -595,6 +595,14 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FancyEffectsContainer {
|
||||||
|
id: fancyEffectsContainer
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
enabled: Config.showFancyEffects
|
||||||
|
}
|
||||||
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||||
|
|
||||||
function goToEvent(eventID) {
|
function goToEvent(eventID) {
|
||||||
|
|||||||
@@ -70,5 +70,14 @@ Kirigami.ScrollablePage {
|
|||||||
Config.save()
|
Config.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QQC2.CheckBox {
|
||||||
|
Kirigami.FormData.label: i18n("Timeline:")
|
||||||
|
text: i18n("Show Fancy Effects")
|
||||||
|
checked: Config.showFancyEffects
|
||||||
|
onToggled: {
|
||||||
|
Config.showFancyEffects = checked
|
||||||
|
Config.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
res.qrc
1
res.qrc
@@ -18,6 +18,7 @@
|
|||||||
<file>imports/NeoChat/Component/ChatTextInput.qml</file>
|
<file>imports/NeoChat/Component/ChatTextInput.qml</file>
|
||||||
<file>imports/NeoChat/Component/AutoMouseArea.qml</file>
|
<file>imports/NeoChat/Component/AutoMouseArea.qml</file>
|
||||||
<file>imports/NeoChat/Component/FullScreenImage.qml</file>
|
<file>imports/NeoChat/Component/FullScreenImage.qml</file>
|
||||||
|
<file>imports/NeoChat/Component/FancyEffectsContainer.qml</file>
|
||||||
<file>imports/NeoChat/Component/Emoji/EmojiPicker.qml</file>
|
<file>imports/NeoChat/Component/Emoji/EmojiPicker.qml</file>
|
||||||
<file>imports/NeoChat/Component/Emoji/qmldir</file>
|
<file>imports/NeoChat/Component/Emoji/qmldir</file>
|
||||||
<file>imports/NeoChat/Component/Timeline/qmldir</file>
|
<file>imports/NeoChat/Component/Timeline/qmldir</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user