From 4a96dae57de32d76917d5aa7a8c871e487678ce9 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 21 Apr 2024 10:50:45 +0000 Subject: [PATCH] Fancy Effects 2021-2024 gone but never forgotten Remove fancy effects as it's busted and causing CPU spikes. (cherry picked from commit dc2f11eb2bfb5e325951b3ba8ab7fdfa89a8d899) --- src/CMakeLists.txt | 4 - src/models/messageeventmodel.cpp | 28 --- src/models/messageeventmodel.h | 1 - src/neochatconfig.kcfg | 4 - src/qml/FancyEffectsContainer.qml | 304 ------------------------ src/qml/TimelineView.qml | 40 ---- src/qml/confetti.png | Bin 1052 -> 0 bytes src/qml/glowdot.png | Bin 1613 -> 0 bytes src/settings/AppearanceSettingsPage.qml | 16 -- 9 files changed, 397 deletions(-) delete mode 100644 src/qml/FancyEffectsContainer.qml delete mode 100644 src/qml/confetti.png delete mode 100644 src/qml/glowdot.png diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 382c50554..1948cbbe8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/models/messageeventmodel.cpp b/src/models/messageeventmodel.cpp index a7385c4ee..452b3134d 100644 --- a/src/models/messageeventmodel.cpp +++ b/src/models/messageeventmodel.cpp @@ -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()) { m_currentRoom->createPollHandler(eventCast(event.get())); diff --git a/src/models/messageeventmodel.h b/src/models/messageeventmodel.h index 203162b4a..8ae8891f0 100644 --- a/src/models/messageeventmodel.h +++ b/src/models/messageeventmodel.h @@ -140,5 +140,4 @@ private: Q_SIGNALS: void roomChanged(); - void fancyEffectsReasonFound(const QString &fancyEffect); }; diff --git a/src/neochatconfig.kcfg b/src/neochatconfig.kcfg index f03e97d7c..039a6b6b6 100644 --- a/src/neochatconfig.kcfg +++ b/src/neochatconfig.kcfg @@ -100,10 +100,6 @@ false - - - true - 540 diff --git a/src/qml/FancyEffectsContainer.qml b/src/qml/FancyEffectsContainer.qml deleted file mode 100644 index b1a1a10f5..000000000 --- a/src/qml/FancyEffectsContainer.qml +++ /dev/null @@ -1,304 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Alexey Andreyev -// 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; - } - } - } -} diff --git a/src/qml/TimelineView.qml b/src/qml/TimelineView.qml index cf3f81fd9..070c49e75 100644 --- a/src/qml/TimelineView.qml +++ b/src/qml/TimelineView.qml @@ -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 diff --git a/src/qml/confetti.png b/src/qml/confetti.png deleted file mode 100644 index ee4e08af850fbc8934268b5c6d4db3b374ecf4b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1052 zcmV+%1mpXOP)28E^$tdfIC8LpqZ)LvsPoN_f@N z@{WrhdKqLYqFcty!a|U`Cn(BJfRzAPIy{4xS2B)?+SP8 z$w*ZAMA&P}0fldst~vasIN|V@Vsj}p3og~ulc-{?iuI(K79JHIN~iLA`8?_-9kI;v zqSStw16YKZBY+2uJR79Q;ggz?%xe4mCEq+*@#yk5C}4^sK~lV4QS;I@CN(a4OuiHa zmHYoZt@!wu)4d}A&9AooISeiPP~5Za-&5NzoIw0cd!2eF`H;1 zQK62g00009a7bBm000XT000XT0n*)m`~Uy~Qb|NXR9M5sm%U3IK^Vq&&qEOofM(-}%mv=jP zUU&wEacA#l-8*0Sv3GmBGtayqGw+3grzxfM#}&{7OXlxk7zRBx5kS6!OYjan)c1RC zoaixVfQVd!6)?~*0lSs}#jAK^-tf{bvJfy1s>bA6fELjLM_{5?0zPn(IE$>XY=Ys; z1Ym$?pc%7rm)(FvFq@Ttw;q#g0g@M2;Psu76fcj0KOU3YA^8HP>~V7*8kWJR>@^pxCcJCYm>lyLh3PW`(&s>e=9a-vU=bKP)D$Yv4rx6S@xpa%|6}O|t*7 W4d1yu&SIAU000028E^$tdfIC8LpqZ)LvsPoN_f@N z@{WrhdKqLYqFcty!a|U`Cn(BJfRzAPIy{4xS2B)?+SP8 z$w*ZAMA&P}0fldst~vasIN|V@Vsj}p3og~ulc-{?iuI(K79JHIN~iLA`8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