From 76ef6c81115636bf0167b847f3b594384740a624 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 31 Jan 2021 12:00:31 +0200 Subject: [PATCH] move Animations AbilityClient into library --- .../abilities/client/Animations.qml | 10 +++- .../package/contents/ui/AppletAbilities.qml | 2 +- .../contents/ui/abilities/Animations.qml | 58 ------------------- plasmoid/package/contents/ui/main.qml | 12 ++++ .../ui/task/animations/LauncherAnimation.qml | 2 +- .../ui/task/animations/NewWindowAnimation.qml | 4 +- .../task/animations/RealRemovalAnimation.qml | 2 +- .../RemoveWindowFromGroupAnimation.qml | 2 +- .../task/animations/ShowWindowAnimation.qml | 4 +- 9 files changed, 29 insertions(+), 67 deletions(-) delete mode 100644 plasmoid/package/contents/ui/abilities/Animations.qml diff --git a/declarativeimports/abilities/client/Animations.qml b/declarativeimports/abilities/client/Animations.qml index 8bbb5a4c3..318b34cf6 100644 --- a/declarativeimports/abilities/client/Animations.qml +++ b/declarativeimports/abilities/client/Animations.qml @@ -19,6 +19,7 @@ import QtQuick 2.7 +import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.abilities.definition 0.1 as AbilityDefinition AbilityDefinition.Animations { @@ -44,7 +45,14 @@ AbilityDefinition.Animations { //! requirements requirements: local.requirements - readonly property AbilityDefinition.Animations local: AbilityDefinition.Animations{} + readonly property AbilityDefinition.Animations local: AbilityDefinition.Animations{ + active: local.speedFactor.current !== 0 + hoverPixelSensitivity: 1 + speedFactor.normal: active ? speedFactor.current : 1.0 + + duration.small: LatteCore.Environment.shortDuration + duration.large: LatteCore.Environment.longDuration + } Item { id: ref diff --git a/plasmoid/package/contents/ui/AppletAbilities.qml b/plasmoid/package/contents/ui/AppletAbilities.qml index 085d9c5f7..36b03066d 100644 --- a/plasmoid/package/contents/ui/AppletAbilities.qml +++ b/plasmoid/package/contents/ui/AppletAbilities.qml @@ -50,7 +50,7 @@ Item { //! optional readonly property alias launchers: _launchers - Ability.Animations { + AbilityClient.Animations { id: _animations bridge: _abilityContainer.bridge } diff --git a/plasmoid/package/contents/ui/abilities/Animations.qml b/plasmoid/package/contents/ui/abilities/Animations.qml deleted file mode 100644 index fab19a457..000000000 --- a/plasmoid/package/contents/ui/abilities/Animations.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright 2020 Michail Vourlakos -* -* This file is part of Latte-Dock -* -* Latte-Dock is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* Latte-Dock is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -import QtQuick 2.7 - -import org.kde.plasma.plasmoid 2.0 - -import org.kde.latte.core 0.2 as LatteCore -import org.kde.latte.abilities.client 0.1 as AbilityClient - -AbilityClient.Animations { - //! Public Local Properties - local { - active: speedFactor.current !== 0 - hoverPixelSensitivity: 1 - - speedFactor.normal: active ? speedFactor.current : 1.0 - speedFactor.current: plasmoid.configuration.durationTime - - duration.small: LatteCore.Environment.shortDuration - duration.large: LatteCore.Environment.longDuration - - requirements.zoomFactor: { - if (!active || !LatteCore.WindowSystem.compositingActive) { - return 1; - } - - var hasHighThicknessAnimation = launcherBouncingEnabled || windowInAttentionEnabled || windowAddedInGroupEnabled; - - return hasHighThicknessAnimation ? 1.65 : 1.0; - } - } - - //! Private Local Properties - readonly property bool launcherBouncingEnabled: active && plasmoid.configuration.animationLauncherBouncing - readonly property bool windowInAttentionEnabled: active && plasmoid.configuration.animationWindowInAttention - readonly property bool newWindowSlidingEnabled: active && plasmoid.configuration.animationNewWindowSliding - readonly property bool windowAddedInGroupEnabled: active && plasmoid.configuration.animationWindowAddedInGroup - readonly property bool windowRemovedFromGroupEnabled: active && plasmoid.configuration.animationWindowRemovedFromGroup - -} - diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index eb28066c6..319c3848c 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -127,6 +127,15 @@ Item { readonly property alias containsDrag: mouseHandler.containsDrag + //! Animations + readonly property bool launcherBouncingEnabled: appletAbilities.animations.active && plasmoid.configuration.animationLauncherBouncing + readonly property bool newWindowSlidingEnabled: appletAbilities.animations.active && plasmoid.configuration.animationNewWindowSliding + readonly property bool windowInAttentionEnabled: appletAbilities.animations.active && plasmoid.configuration.animationWindowInAttention + readonly property bool windowAddedInGroupEnabled: appletAbilities.animations.active && plasmoid.configuration.animationWindowAddedInGroup + readonly property bool windowRemovedFromGroupEnabled: appletAbilities.animations.active && plasmoid.configuration.animationWindowRemovedFromGroup + + readonly property bool hasHighThicknessAnimation: launcherBouncingEnabled || windowInAttentionEnabled || windowAddedInGroupEnabled + //BEGIN properties property bool groupTasksByDefault: plasmoid.configuration.groupTasksByDefault property bool highlightWindows: hoverAction === LatteTasks.Types.HighlightWindows || hoverAction === LatteTasks.Types.PreviewAndHighlightWindows @@ -686,6 +695,9 @@ Item { layout: icList.contentItem tasksModel: tasksModel + animations.local.speedFactor.current: plasmoid.configuration.durationTime + animations.local.requirements.zoomFactor: hasHighThicknessAnimation && LatteCore.WindowSystem.compositingActive ? 1.65 : 1.0 + indexer.updateIsBlocked: root.inDraggingPhase || root.inActivityChange indicators.local.isEnabled: !plasmoid.configuration.isInLatteDock diff --git a/plasmoid/package/contents/ui/task/animations/LauncherAnimation.qml b/plasmoid/package/contents/ui/task/animations/LauncherAnimation.qml index 0d45a9ae9..17a4e0ab7 100644 --- a/plasmoid/package/contents/ui/task/animations/LauncherAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/LauncherAnimation.qml @@ -95,7 +95,7 @@ Item{ } function startLauncherAnimation(){ - if(taskItem.abilities.animations.launcherBouncingEnabled){ + if(root.launcherBouncingEnabled){ taskItem.animationStarted(); init(); taskItem.launcherAction(); diff --git a/plasmoid/package/contents/ui/task/animations/NewWindowAnimation.qml b/plasmoid/package/contents/ui/task/animations/NewWindowAnimation.qml index bfe50444a..53aba2c8f 100644 --- a/plasmoid/package/contents/ui/task/animations/NewWindowAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/NewWindowAnimation.qml @@ -98,8 +98,8 @@ Item{ function startNewWindowAnimation(){ if (!taskItem.abilities.myView.isHidden - && ((taskItem.abilities.animations.windowInAttentionEnabled && isDemandingAttention) - || taskItem.abilities.animations.windowAddedInGroupEnabled)){ + && ((root.windowInAttentionEnabled && isDemandingAttention) + || root.windowAddedInGroupEnabled)){ newWindowAnimation.init(); newWindowAnimationLoader.item.start(); } diff --git a/plasmoid/package/contents/ui/task/animations/RealRemovalAnimation.qml b/plasmoid/package/contents/ui/task/animations/RealRemovalAnimation.qml index 290ced182..a33ae4961 100644 --- a/plasmoid/package/contents/ui/task/animations/RealRemovalAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/RealRemovalAnimation.qml @@ -48,7 +48,7 @@ SequentialAnimation { && LatteCore.WindowSystem.compositingActive) property bool enabledAnimation: (animation1 || animation4) - && (taskItem.abilities.animations.newWindowSlidingEnabled) + && root.newWindowSlidingEnabled && !taskItem.inBouncingAnimation && !taskItem.isSeparator && taskItem.visible diff --git a/plasmoid/package/contents/ui/task/animations/RemoveWindowFromGroupAnimation.qml b/plasmoid/package/contents/ui/task/animations/RemoveWindowFromGroupAnimation.qml index 2cce0ad75..70ef209e0 100644 --- a/plasmoid/package/contents/ui/task/animations/RemoveWindowFromGroupAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/RemoveWindowFromGroupAnimation.qml @@ -41,7 +41,7 @@ Item{ } function removeTask(){ - if(!taskIconContainer.toBeDestroyed && taskItem.abilities.animations.windowRemovedFromGroupEnabled){ + if(!taskIconContainer.toBeDestroyed && root.windowRemovedFromGroupEnabled){ removingAnimation.init(); } } diff --git a/plasmoid/package/contents/ui/task/animations/ShowWindowAnimation.qml b/plasmoid/package/contents/ui/task/animations/ShowWindowAnimation.qml index ff4bee301..a901c226c 100644 --- a/plasmoid/package/contents/ui/task/animations/ShowWindowAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/ShowWindowAnimation.qml @@ -27,7 +27,7 @@ import org.kde.latte.core 0.2 as LatteCore ///item's added Animation SequentialAnimation{ id:showWindowAnimation - property int speed: taskItem.abilities.animations.newWindowSlidingEnabled ? (1.2 * taskItem.abilities.animations.speedFactor.normal * taskItem.abilities.animations.duration.large) : 0 + property int speed: root.newWindowSlidingEnabled ? (1.2 * taskItem.abilities.animations.speedFactor.normal * taskItem.abilities.animations.duration.large) : 0 property bool animationSent: false readonly property string needLengthEvent: showWindowAnimation + "_showwindow" @@ -38,7 +38,7 @@ SequentialAnimation{ property: "opacity" to: 0 //it is not depend to durationTime when animations are active - duration: taskItem.abilities.animations.newWindowSlidingEnabled ? 750 : 0 + duration: root.newWindowSlidingEnabled ? 750 : 0 easing.type: Easing.InQuad } //end of ghost animation