diff --git a/imports/NeoChat/Component/FancyEffectsContainer.qml b/imports/NeoChat/Component/FancyEffectsContainer.qml new file mode 100644 index 000000000..7a5c85409 --- /dev/null +++ b/imports/NeoChat/Component/FancyEffectsContainer.qml @@ -0,0 +1,131 @@ +/** + * SPDX-FileCopyrightText: 2021 Alexey Andreyev + * + * 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 + } + } + } +} diff --git a/imports/NeoChat/Component/qmldir b/imports/NeoChat/Component/qmldir index acb10bad8..3b788a24c 100644 --- a/imports/NeoChat/Component/qmldir +++ b/imports/NeoChat/Component/qmldir @@ -2,3 +2,4 @@ module NeoChat.Component AutoMouseArea 1.0 AutoMouseArea.qml FullScreenImage 1.0 FullScreenImage.qml ChatTextInput 1.0 ChatTextInput.qml +FancyEffectsContainer 1.0 FancyEffectsContainer.qml diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 2024a3e92..985d23147 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -595,6 +595,14 @@ Kirigami.ScrollablePage { Layout.fillWidth: true } + FancyEffectsContainer { + id: fancyEffectsContainer + + Layout.fillWidth: true + Layout.fillHeight: true + enabled: Config.showFancyEffects + } + Kirigami.Theme.colorSet: Kirigami.Theme.View function goToEvent(eventID) { diff --git a/imports/NeoChat/Page/SettingsPage.qml b/imports/NeoChat/Page/SettingsPage.qml index 570719f67..b34397e51 100644 --- a/imports/NeoChat/Page/SettingsPage.qml +++ b/imports/NeoChat/Page/SettingsPage.qml @@ -70,5 +70,14 @@ Kirigami.ScrollablePage { Config.save() } } + QQC2.CheckBox { + Kirigami.FormData.label: i18n("Timeline:") + text: i18n("Show Fancy Effects") + checked: Config.showFancyEffects + onToggled: { + Config.showFancyEffects = checked + Config.save() + } + } } } diff --git a/res.qrc b/res.qrc index 8d980bce0..f40650612 100644 --- a/res.qrc +++ b/res.qrc @@ -18,6 +18,7 @@ imports/NeoChat/Component/ChatTextInput.qml imports/NeoChat/Component/AutoMouseArea.qml imports/NeoChat/Component/FullScreenImage.qml + imports/NeoChat/Component/FancyEffectsContainer.qml imports/NeoChat/Component/Emoji/EmojiPicker.qml imports/NeoChat/Component/Emoji/qmldir imports/NeoChat/Component/Timeline/qmldir