Warning, /plasma/latte-dock/plasmoid/package/contents/ui/task/animations/RealRemovalAnimation.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.0
0008 
0009 import org.kde.plasma.plasmoid 2.0
0010 import org.kde.plasma.core 2.0 as PlasmaCore
0011 
0012 import org.kde.latte.core 0.2 as LatteCore
0013 
0014 SequentialAnimation {
0015     id: taskRealRemovalAnimation
0016     PropertyAction { target: taskItem; property: "ListView.delayRemove"; value: !taskItem.isSeparator } //try to delete separators instantly, this way maybe tasks model does not break when switching activities fastly
0017     PropertyAction { target: taskItem; property: "inAnimation"; value: true }
0018     PropertyAction { target: taskItem; property: "inAddRemoveAnimation"; value: true }
0019     PropertyAction { target: taskItem; property: "inRemoveStage"; value: true }
0020 
0021     //Animation Add/Remove (1) - when is window with no launcher in current activity, animations enabled
0022     //Animation Add/Remove (4) - the user removes a launcher, animation enabled
0023     property bool animation1: ( (tasksModel.launcherPosition(taskItem.launcherUrl) === -1 /*no-launcher*/
0024                                  && tasksModel.launcherPosition(taskItem.launcherUrlWithIcon) === -1)
0025                                || ((!taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrl)/*no-launcher-in-current-activity*/
0026                                     && !taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrlWithIcon)))
0027                                && !taskItem.isStartup
0028                                && LatteCore.WindowSystem.compositingActive)
0029 
0030     property bool animation4: (tasksExtendedManager.launchersToBeRemovedCount /*update trigger*/
0031                                && (tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrl)
0032                                  || tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrlWithIcon))
0033                                && !taskItem.isStartup
0034                                && LatteCore.WindowSystem.compositingActive)
0035 
0036     property bool enabledAnimation: (animation1 || animation4)
0037                                     && root.newWindowSlidingEnabled
0038                                     && !taskItem.inBouncingAnimation
0039                                     && !taskItem.isSeparator
0040                                     && taskItem.visible
0041 
0042     readonly property string needLengthEvent: taskRealRemovalAnimation + "_realremoval"
0043 
0044     ScriptAction{
0045         script:{
0046             //! When a window is removed and afterwards its launcher must be shown immediately!
0047             if (!enabledAnimation && taskItem.isWindow && !taskItem.isSeparator
0048                     && (taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrl)
0049                         || taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrlWithIcon))
0050                     && !tasksExtendedManager.immediateLauncherExists(taskItem.launcherUrl)){
0051                 tasksExtendedManager.addImmediateLauncher(taskItem.launcherUrl);
0052             }
0053 
0054             //trying to fix the ListView nasty behavior
0055             //during the removal the anchoring for ListView children changes a lot
0056             var previousTask = icList.childAtIndex(taskItem.lastValidIndex-1);
0057 
0058             //! When removing a task and there are surrounding separators then the hidden spacers
0059             //! are updated immediately for the neighbour tasks. In such case in order to not break
0060             //! the removal animation a small margin must applied
0061             var spacer = taskItem.headItemIsSeparator ? -(2+taskItem.abilities.metrics.totals.lengthEdge) : ( taskItem.headItemIsSeparator ? (2+taskItem.abilities.metrics.totals.lengthEdge)/2 : 0);
0062 
0063             if (!taskItem.inBouncingAnimation && !animation4) {
0064                 //! Is this really needed ??
0065                 //! That hidden reanchoring was creating issue :#433359
0066                 //! this needs to be reinvestigated - reapproached in case the following
0067                 //! commented lines are really needed
0068 
0069             /*    //! real slide-out case
0070                 var taskInListPos = mapToItem(icList, 0, 0);
0071                 taskItem.parent = icList;
0072 
0073                 if (root.vertical) {
0074                     taskItem.anchors.top = icList.top;
0075                     taskItem.anchors.topMargin = taskInListPos.y + spacer;
0076 
0077                     if (root.location===PlasmaCore.Types.LeftEdge) {
0078                         taskItem.anchors.left = icList.left;
0079                     } else {
0080                         taskItem.anchors.right = icList.right;
0081                     }
0082                 } else {
0083                     taskItem.anchors.left = icList.left;
0084                     taskItem.anchors.leftMargin = taskInListPos.x + spacer;
0085 
0086                     if (root.location===PlasmaCore.Types.TopEdge) {
0087                         taskItem.anchors.top = icList.top;
0088                     } else {
0089                         taskItem.anchors.bottom = icList.bottom;
0090                     }
0091                 }*/
0092             } else if (previousTask !== undefined && !previousTask.isStartup && !previousTask.inBouncingAnimation ) {
0093                 // bouncing case
0094                 if (root.vertical) {
0095                     taskItem.anchors.top = previousTask.bottom;
0096                     taskItem.anchors.topMargin = spacer;
0097                 } else {
0098                     taskItem.anchors.left = previousTask.right;
0099                     taskItem.anchors.leftMargin = spacer;
0100                 }
0101             }
0102 
0103             //console.log("1." + taskItem.launcherUrl + " - " + taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrl) + "__" +
0104             //            animation1 + ":" + animation4 + "=>" + taskRealRemovalAnimation.enabledAnimation + "  index:" + taskItem.lastValidIndex);
0105             //console.log("2." + taskItem.isLauncher);
0106 
0107             taskItem.abilities.animations.needLength.addEvent(needLengthEvent);
0108 
0109             if (taskItem.parabolicItem.zoom > 1 && !taskRealRemovalAnimation.enabledAnimation
0110                     && !taskItem.inBouncingAnimation && LatteCore.WindowSystem.compositingActive) {
0111                 tasksExtendedManager.setFrozenTask(taskItem.launcherUrl, taskItem.parabolicItem.zoom);
0112             } else {
0113                 //! remove frozen task if it is deprecated. This fixes the libreoffice launcher issue with custom indicator launcher animations,
0114                 //! steps to reproduce:
0115                 //! 1. set an indicator that provides its own launcher animation such as "Animated Dot"
0116                 //! 2. enable parabolic effect zoom
0117                 //! 3. click on libreoffice writer launcher and keep the mouse inside the launcher
0118                 //! 4. close libreoffice writer window from its decoration close button
0119                 //! 5. libreoffice writer launcher is zoomed even though it should not
0120                 var frozenTask = tasksExtendedManager.getFrozenTask(taskItem.launcherUrl);
0121                 if (frozenTask && frozenTask.zoom>1) {
0122                     tasksExtendedManager.removeFrozenTask(taskItem.launcherUrl);
0123                 }
0124             }
0125 
0126             if (taskItem.isLauncherAnimationRunning && !taskItem.isSeparator) {
0127                 taskRealRemovalAnimation.pause();
0128             }
0129         }
0130     }
0131 
0132     //! Wait for launcher animation to finish before continue with real removal
0133     PauseAnimation {
0134         duration: taskItem.isLauncherAnimationRunning && !taskItem.isSeparator ? 50 : 0
0135     }
0136 
0137     PropertyAnimation {
0138         target: taskItem.parabolicItem
0139         property: "zoom"
0140         to: 1
0141         duration: taskRealRemovalAnimation.enabledAnimation ? showWindowAnimation.speed : 0
0142         easing.type: Easing.InQuad
0143     }
0144 
0145     //PropertyAction { target: taskItem.parabolicItem; property: "opacity"; value: isWindow ? 0 : 1 }
0146     //animation mainly for launchers removal and startups
0147     ParallelAnimation{
0148         id: removalAnimation
0149 
0150         // property int speed: (IsStartup && !taskItem.visible)? 0 : 400
0151         //property int speed: 400
0152         NumberAnimation {
0153             target: taskItem.parabolicItem;
0154             property: "opacity";
0155             to: 0;
0156             duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
0157             easing.type: Easing.InQuad
0158         }
0159 
0160         PropertyAnimation {
0161             target: taskItem
0162             property: taskItem.isVertical ? "iconAnimatedOffsetX" : "iconAnimatedOffsetY"
0163             to: -0.7*taskItem.abilities.metrics.iconSize
0164             duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
0165             easing.type: Easing.InQuad
0166         }
0167     }
0168 
0169     //smooth move into place the surrounding tasks
0170     PropertyAnimation {
0171         target: taskItem.parabolicItem
0172         property: "zoomLength"
0173         to: 0
0174         duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
0175         easing.type: Easing.InQuad
0176     }
0177 
0178     ScriptAction{
0179         script:{
0180             if (showWindowAnimation.animationSent){
0181                 //console.log("SAFETY REMOVAL 1: animation removing ended");
0182                 showWindowAnimation.animationSent = false;
0183                 taskItem.abilities.animations.needLength.removeEvent(showWindowAnimation.needLengthEvent);
0184             }
0185 
0186             taskItem.abilities.animations.needLength.removeEvent(needLengthEvent);
0187 
0188             if(tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrl) && taskItem.isLauncher) {
0189                 tasksExtendedManager.removeToBeRemovedLauncher(taskItem.launcherUrl);
0190             }
0191 
0192             if (windowsPreviewDlg.visible && windowsPreviewDlg.mainItem.parentTask === taskItem
0193                     && isWindow && !isGroupParent){
0194                 hidePreview();
0195             }
0196 
0197             if (root.showWindowsOnlyFromLaunchers || root.disableAllWindowsFunctionality) {
0198                 if (root.vertical) {
0199                     taskItem.anchors.top = undefined;
0200                     taskItem.anchors.topMargin = 0;
0201                 } else {
0202                     taskItem.anchors.left = undefined;
0203                     taskItem.anchors.leftMargin = 0;
0204                 }
0205             }
0206 
0207             taskItem.visible = false;
0208 
0209             //send signal that the launcher is really removing
0210             if (taskItem.hasAddedWaitingLauncher) {
0211                 tasksExtendedManager.removeWaitingLauncher(taskItem.launcherUrl);
0212 
0213                 if (!taskItem.abilities.indicators.info.providesTaskLauncherAnimation) {
0214                     //! this is needed only from in-built launcher animation to restore zoom smoothly to neighbour tasks
0215                     taskItem.abilities.parabolic.setDirectRenderingEnabled(false);
0216                 }
0217             }
0218         }
0219     }
0220 
0221     PropertyAction { target: taskItem; property: "inAnimation"; value: false }
0222     PropertyAction { target: taskItem; property: "inAddRemoveAnimation"; value: false }
0223     PropertyAction { target: taskItem; property: "inRemoveStage"; value: false }
0224 
0225     PropertyAction { target: taskItem; property: "ListView.delayRemove"; value: false }
0226 }