Warning, /plasma/latte-dock/plasmoid/package/contents/ui/task/animations/RemoveWindowFromGroupAnimation.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 import QtGraphicalEffects 1.0
0009 
0010 import org.kde.plasma.plasmoid 2.0
0011 import org.kde.plasma.core 2.0 as PlasmaCore
0012 
0013 import org.kde.kirigami 2.0 as Kirigami
0014 
0015 import org.kde.latte.core 0.2 as LatteCore
0016 
0017 /////Removing a Window from a group////
0018 Item{
0019     id:removingAnimation
0020 
0021     function init(){
0022         var relavantPoint = root.mapFromItem(taskIcon,0,0);
0023 
0024         var removingItem = removeTaskComponent.createObject(root);
0025         removingItem.x = relavantPoint.x;
0026         removingItem.y = relavantPoint.y;
0027 
0028         removingItem.start();
0029     }
0030 
0031     function removeTask(){
0032         if (taskItem.abilities.indicators.info.providesGroupedWindowRemovedAnimation) {
0033             return;
0034         }
0035 
0036         if(!taskIconContainer.toBeDestroyed && root.windowRemovedFromGroupEnabled){
0037             removingAnimation.init();
0038         }
0039     }
0040 
0041     Component.onCompleted: {
0042         taskItem.taskGroupedWindowRemoved.connect(removeTask);
0043     }
0044 
0045     Component.onDestruction: {
0046         taskItem.taskGroupedWindowRemoved.disconnect(removeTask);
0047     }
0048 
0049     ///////////// Component for animating removing window from group
0050 
0051     Component {
0052         id: removeTaskComponent
0053         Item{
0054             id: removeTask
0055             width: taskIcon.width
0056             height: taskIcon.height
0057             visible: false
0058 
0059             //! Shadow
0060             Loader{
0061                 id: tempTaskShadow
0062                 anchors.fill: tempRemoveIcon
0063                 active: taskItem.abilities.myView.itemShadow.isEnabled
0064                         && taskItem.abilities.environment.isGraphicsSystemAccelerated
0065 
0066                 sourceComponent: DropShadow{
0067                     anchors.fill: parent
0068                     color: "#ff080808"
0069                     fast: true
0070                     samples: 2 * radius
0071                     source: tempRemoveIcon
0072                     radius: taskItem.abilities.myView.itemShadow.size
0073                     verticalOffset: 2
0074                 }
0075             }
0076 
0077             Kirigami.Icon{
0078                 id: tempRemoveIcon
0079                 anchors.rightMargin: root.location === PlasmaCore.Types.LeftEdge ? taskItem.abilities.metrics.margin.thickness : 0
0080                 anchors.leftMargin: root.location === PlasmaCore.Types.RightEdge ? taskItem.abilities.metrics.margin.thickness : 0
0081                 anchors.topMargin: root.location === PlasmaCore.Types.BottomEdge ? taskItem.abilities.metrics.margin.thickness : 0
0082                 anchors.bottomMargin: root.location === PlasmaCore.Types.TopEdge ? taskItem.abilities.metrics.margin.thickness : 0
0083 
0084                 anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined;
0085                 anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined;
0086                 anchors.right: root.location === PlasmaCore.Types.LeftEdge ? parent.right : undefined;
0087                 anchors.left: root.location === PlasmaCore.Types.RightEdge ? parent.left : undefined;
0088                 anchors.top: root.location === PlasmaCore.Types.BottomEdge ? parent.top : undefined;
0089                 anchors.bottom: root.location === PlasmaCore.Types.TopEdge ? parent.bottom : undefined;
0090 
0091                 width: taskIconItem.width
0092                 height: width
0093 
0094                 source: taskIconItem.source
0095             }
0096 
0097 
0098 
0099             Colorize{
0100                 source: tempRemoveIcon
0101                 anchors.fill: tempRemoveIcon
0102 
0103                 hue: 0
0104                 saturation: 0
0105                 lightness: 0
0106             }
0107 
0108             ParallelAnimation{
0109                 id: componentRemoveAnimation
0110 
0111                 property int speed: 2 * taskItem.abilities.animations.speedFactor.normal * taskItem.abilities.animations.duration.large
0112                 property Item removingItem: parent
0113                 property int toPoint: 0
0114 
0115                 PropertyAnimation {
0116                     target: removeTask
0117                     property: "opacity"
0118                     to: 0
0119                     duration: componentRemoveAnimation.speed
0120                     easing.type: Easing.InQuad
0121                 }
0122 
0123                 PropertyAnimation {
0124                     target: removeTask
0125                     property: (icList.orientation == Qt.Horizontal) ? "y" : "x"
0126                     to: componentRemoveAnimation.toPoint
0127                     duration: componentRemoveAnimation.speed
0128                     easing.type: Easing.InQuad
0129                 }
0130 
0131                 onStopped: {
0132                     removeTask.destroy();
0133                 }
0134             }
0135 
0136             function start(){
0137                 var tempPoint = 0;
0138 
0139                 if(icList.orientation == Qt.Horizontal)
0140                     tempPoint = y;
0141                 else
0142                     tempPoint = x;
0143 
0144                 if( (root.location === PlasmaCore.Types.BottomEdge) ||
0145                         (root.location === PlasmaCore.Types.RightEdge) ){
0146                     componentRemoveAnimation.toPoint = tempPoint + taskItem.abilities.metrics.iconSize;
0147                 }
0148                 else{
0149                     componentRemoveAnimation.toPoint = tempPoint - taskItem.abilities.metrics.iconSize;
0150                 }
0151 
0152                 visible = true;
0153                 componentRemoveAnimation.start();
0154             }
0155 
0156         }
0157     }
0158 }