Fancy Effects 2021-2024 gone but never forgotten
Remove fancy effects as it's busted and causing CPU spikes.
This commit is contained in:
@@ -204,7 +204,6 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
||||
qml/InviteUserPage.qml
|
||||
qml/ImageEditorPage.qml
|
||||
qml/NeochatMaximizeComponent.qml
|
||||
qml/FancyEffectsContainer.qml
|
||||
qml/TypingPane.qml
|
||||
qml/QuickSwitcher.qml
|
||||
qml/HoverActions.qml
|
||||
@@ -281,9 +280,6 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
||||
qml/ConfirmLeaveDialog.qml
|
||||
qml/CodeMaximizeComponent.qml
|
||||
qml/EditStateDialog.qml
|
||||
RESOURCES
|
||||
qml/confetti.png
|
||||
qml/glowdot.png
|
||||
)
|
||||
|
||||
add_subdirectory(settings)
|
||||
|
||||
@@ -117,34 +117,6 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
|
||||
if (message != nullptr) {
|
||||
createEventObjects(message);
|
||||
if (NeoChatConfig::self()->showFancyEffects()) {
|
||||
QString planBody = message->plainBody();
|
||||
// snowflake
|
||||
const QString snowlakeEmoji = QString::fromUtf8("\xE2\x9D\x84");
|
||||
if (planBody.contains(snowlakeEmoji)) {
|
||||
Q_EMIT fancyEffectsReasonFound(QStringLiteral("snowflake"));
|
||||
}
|
||||
// fireworks
|
||||
const QString fireworksEmoji = QString::fromUtf8("\xF0\x9F\x8E\x86");
|
||||
if (planBody.contains(fireworksEmoji)) {
|
||||
Q_EMIT fancyEffectsReasonFound(QStringLiteral("fireworks"));
|
||||
}
|
||||
// sparkler
|
||||
const QString sparklerEmoji = QString::fromUtf8("\xF0\x9F\x8E\x87");
|
||||
if (planBody.contains(sparklerEmoji)) {
|
||||
Q_EMIT fancyEffectsReasonFound(QStringLiteral("fireworks"));
|
||||
}
|
||||
// party pooper
|
||||
const QString partyEmoji = QString::fromUtf8("\xF0\x9F\x8E\x89");
|
||||
if (planBody.contains(partyEmoji)) {
|
||||
Q_EMIT fancyEffectsReasonFound(QStringLiteral("confetti"));
|
||||
}
|
||||
// confetti ball
|
||||
const QString confettiEmoji = QString::fromUtf8("\xF0\x9F\x8E\x8A");
|
||||
if (planBody.contains(confettiEmoji)) {
|
||||
Q_EMIT fancyEffectsReasonFound(QStringLiteral("confetti"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event->is<PollStartEvent>()) {
|
||||
m_currentRoom->createPollHandler(eventCast<const PollStartEvent>(event.get()));
|
||||
|
||||
@@ -140,5 +140,4 @@ private:
|
||||
|
||||
Q_SIGNALS:
|
||||
void roomChanged();
|
||||
void fancyEffectsReasonFound(const QString &fancyEffect);
|
||||
};
|
||||
|
||||
@@ -100,10 +100,6 @@
|
||||
<label>Minimize to system tray on startup</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="ShowFancyEffects" type="bool">
|
||||
<label>Show Fancy Effects</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="MediaMaxWidth" type="int">
|
||||
<label>The maximum width any media item in the timeline can be.</label>
|
||||
<default>540</default>
|
||||
|
||||
@@ -1,304 +0,0 @@
|
||||
// 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
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Particles
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property bool enabled: false
|
||||
property int effectInterval: Kirigami.Units.veryLongDuration * 10
|
||||
property color darkSnowColor: "grey"
|
||||
property bool isThemeDark: Kirigami.Theme.backgroundColor.hslLightness <= darkSnowColor.hslLightness
|
||||
|
||||
function showConfettiEffect() {
|
||||
confettiTimer.start();
|
||||
}
|
||||
|
||||
function showSnowEffect() {
|
||||
snowTimer.start();
|
||||
}
|
||||
|
||||
function showFireworksEffect() {
|
||||
fireworksTimer.start();
|
||||
}
|
||||
|
||||
// Confetti
|
||||
|
||||
Timer {
|
||||
id: confettiTimer
|
||||
interval: root.effectInterval
|
||||
running: false
|
||||
repeat: false
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
if (root.enabled) {
|
||||
confettiSystem.running = !confettiSystem.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ParticleSystem {
|
||||
id: confettiSystem
|
||||
anchors.fill: parent
|
||||
|
||||
running: false
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
opacity = 1;
|
||||
} else {
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageParticle {
|
||||
source: "qrc:/qt/qml/org/kde/neochat/qml/confetti.png"
|
||||
entryEffect: ImageParticle.Scale
|
||||
rotationVariation: 360
|
||||
rotationVelocity: 90
|
||||
color: Qt.hsla(Math.random(), 0.5, 0.6, 1)
|
||||
colorVariation: 1
|
||||
}
|
||||
|
||||
Emitter {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
}
|
||||
|
||||
sizeVariation: Kirigami.Units.iconSizes.small / 2
|
||||
lifeSpan: Kirigami.Units.veryLongDuration * 10
|
||||
size: Kirigami.Units.iconSizes.small
|
||||
|
||||
velocity: AngleDirection {
|
||||
angle: 90
|
||||
angleVariation: 42
|
||||
magnitude: 500
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Snow
|
||||
|
||||
Timer {
|
||||
id: snowTimer
|
||||
interval: root.effectInterval
|
||||
running: false
|
||||
repeat: false
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
if (root.enabled) {
|
||||
snowSystem.running = !snowSystem.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ParticleSystem {
|
||||
id: snowSystem
|
||||
anchors.fill: parent
|
||||
|
||||
running: false
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
opacity = 1;
|
||||
} else {
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemParticle {
|
||||
delegate: Rectangle {
|
||||
width: 10
|
||||
height: width
|
||||
radius: width
|
||||
color: root.isThemeDark ? "white" : darkSnowColor
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fireworks
|
||||
|
||||
Timer {
|
||||
id: fireworksTimer
|
||||
interval: root.effectInterval
|
||||
running: false
|
||||
repeat: false
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
if (root.enabled) {
|
||||
fireworksInternalTimer.running = !fireworksInternalTimer.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: fireworksInternalTimer
|
||||
interval: 300
|
||||
triggeredOnStart: true
|
||||
running: false
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
var x = Math.random() * parent.width;
|
||||
var y = Math.random() * parent.height;
|
||||
customEmit(x, y);
|
||||
customEmit(x, y);
|
||||
customEmit(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
ParticleSystem {
|
||||
id: fireworksSystem
|
||||
anchors.fill: parent
|
||||
running: fireworksInternalTimer.running
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
opacity = 1;
|
||||
} else {
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageParticle {
|
||||
id: fireworksParticleA
|
||||
system: fireworksSystem
|
||||
source: "qrc:/qt/qml/org/kde/neochat/qml/glowdot.png"
|
||||
alphaVariation: root.isThemeDark ? 0.1 : 0.1
|
||||
alpha: root.isThemeDark ? 0.5 : 1
|
||||
groups: ["a"]
|
||||
opacity: fireworksSystem.opacity
|
||||
entryEffect: ImageParticle.Scale
|
||||
rotationVariation: 360
|
||||
}
|
||||
|
||||
ImageParticle {
|
||||
system: fireworksSystem
|
||||
source: "qrc:/qt/qml/org/kde/neochat/qml/glowdot.png"
|
||||
color: root.isThemeDark ? "white" : "gold"
|
||||
alphaVariation: root.isThemeDark ? 0.1 : 0.1
|
||||
alpha: root.isThemeDark ? 0.5 : 1
|
||||
groups: ["light"]
|
||||
opacity: fireworksSystem.opacity
|
||||
entryEffect: ImageParticle.Scale
|
||||
rotationVariation: 360
|
||||
}
|
||||
|
||||
ImageParticle {
|
||||
id: fireworksParticleB
|
||||
system: fireworksSystem
|
||||
source: "qrc:/qt/qml/org/kde/neochat/qml/glowdot.png"
|
||||
alphaVariation: root.isThemeDark ? 0.1 : 0.1
|
||||
alpha: root.isThemeDark ? 0.5 : 1
|
||||
groups: ["b"]
|
||||
opacity: fireworksSystem.opacity
|
||||
entryEffect: ImageParticle.Scale
|
||||
rotationVariation: 360
|
||||
}
|
||||
|
||||
Component {
|
||||
id: emitterComp
|
||||
Emitter {
|
||||
id: container
|
||||
property int life: 23
|
||||
property real targetX: 0
|
||||
property real targetY: 0
|
||||
width: 1
|
||||
height: 1
|
||||
system: fireworksSystem
|
||||
size: 16
|
||||
endSize: 8
|
||||
sizeVariation: 5
|
||||
Timer {
|
||||
interval: life
|
||||
running: true
|
||||
onTriggered: {
|
||||
container.destroy();
|
||||
var randomHue = Math.random();
|
||||
var lightness = root.isThemeDark ? 0.8 : 0.7;
|
||||
fireworksParticleA.color = Qt.hsla(randomHue, 0.8, lightness, 1);
|
||||
fireworksParticleB.color = Qt.hsla(1 - randomHue, 0.8, lightness, 1);
|
||||
}
|
||||
}
|
||||
velocity: AngleDirection {
|
||||
angleVariation: 360
|
||||
magnitude: 200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function customEmit(x, y) {
|
||||
var currentSize = Math.round(Math.random() * 200) + 40;
|
||||
var currentLifeSpan = Math.round(Math.random() * 1000) + 100;
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var obj = emitterComp.createObject(parent);
|
||||
obj.x = x;
|
||||
obj.y = y;
|
||||
obj.targetX = Math.random() * currentSize - currentSize / 2 + obj.x;
|
||||
obj.targetY = Math.random() * currentSize - currentSize / 2 + obj.y;
|
||||
obj.life = Math.round(Math.random() * 23) + 150;
|
||||
obj.emitRate = Math.round(Math.random() * 32) + 5;
|
||||
obj.lifeSpan = currentLifeSpan;
|
||||
const group = Math.round(Math.random() * 3);
|
||||
switch (group) {
|
||||
case 0:
|
||||
obj.group = "light";
|
||||
break;
|
||||
case 1:
|
||||
obj.group = "a";
|
||||
break;
|
||||
case 2:
|
||||
obj.group = "b";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,46 +312,6 @@ QQC2.ScrollView {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
FancyEffectsContainer {
|
||||
id: fancyEffectsContainer
|
||||
anchors.fill: parent
|
||||
z: 100
|
||||
|
||||
enabled: Config.showFancyEffects
|
||||
|
||||
function processFancyEffectsReason(fancyEffect) {
|
||||
if (fancyEffect === "snowflake") {
|
||||
fancyEffectsContainer.showSnowEffect();
|
||||
}
|
||||
if (fancyEffect === "fireworks") {
|
||||
fancyEffectsContainer.showFireworksEffect();
|
||||
}
|
||||
if (fancyEffect === "confetti") {
|
||||
fancyEffectsContainer.showConfettiEffect();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
//enabled: Config.showFancyEffects
|
||||
target: root.timelineModel.messageEventModel
|
||||
|
||||
function onFancyEffectsReasonFound(fancyEffect) {
|
||||
fancyEffectsContainer.processFancyEffectsReason(fancyEffect);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
enabled: Config.showFancyEffects
|
||||
target: actionsHandler
|
||||
|
||||
function onShowEffect(fancyEffect) {
|
||||
fancyEffectsContainer.processFancyEffectsReason(fancyEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goToLastMessage() {
|
||||
root.currentRoom.markAllMessagesAsRead();
|
||||
// scroll to the very end, i.e to messageListView.YEnd
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -227,22 +227,6 @@ FormCard.FormCardPage {
|
||||
|
||||
FormCard.FormCard {
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||
FormCard.FormCheckDelegate {
|
||||
id: showFancyEffectsDelegate
|
||||
text: i18n("Show fancy effects in chat")
|
||||
checked: Config.showFancyEffects
|
||||
enabled: !Config.isShowFancyEffectsImmutable
|
||||
onToggled: {
|
||||
Config.showFancyEffects = checked;
|
||||
Config.save();
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: showFancyEffectsDelegate
|
||||
below: hasWindowSystemDelegate
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: hasWindowSystemDelegate
|
||||
visible: WindowController.hasWindowSystem
|
||||
|
||||
Reference in New Issue
Block a user