Warning, /plasma/latte-dock/plasmoid/package/contents/ui/task/animations/NewWindowAnimation.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 
0011 import org.kde.plasma.core 2.0 as PlasmaCore
0012 
0013 ////////////////// new window and needs attention animation
0014 Item{
0015     id:newWindowAnimation
0016 
0017     property int speed: 1.2 * taskItem.abilities.animations.speedFactor.normal * taskItem.abilities.animations.duration.large
0018     property bool isDemandingAttention: taskItem.inAttention
0019     property bool containsMouse: taskItem.containsMouse
0020 
0021     property bool inDelayedStartup: false
0022 
0023     readonly property bool running: newWindowAnimationLoader.active ? newWindowAnimationLoader.item.running : false
0024     readonly property bool paused: newWindowAnimationLoader.active ? newWindowAnimationLoader.item.paused : false
0025     readonly property string needThicknessEvent: newWindowAnimation + "_newwindow"
0026 
0027     Loader {
0028         id: newWindowAnimationLoader
0029         source: "newwindow/BounceAnimation.qml"
0030     }
0031 
0032     Connections {
0033         target: newWindowAnimationLoader.item
0034 
0035         onStopped: {
0036             taskItem.abilities.animations.needThickness.removeEvent(needThicknessEvent);
0037             newWindowAnimation.clear();
0038         }
0039     }
0040 
0041     Connections{
0042         target: taskItem
0043 
0044         onInAttentionChanged:{
0045             if (!taskItem.inAttention && newWindowAnimation.running && taskItem.inAttentionBuiltinAnimation) {
0046                 clear();
0047             }
0048         }
0049     }
0050 
0051     function clear(){
0052         newWindowAnimationLoader.item.stop();
0053         taskItem.setBlockingAnimation(false);
0054         taskItem.inAttentionBuiltinAnimation = false;
0055         taskItem.inNewWindowBuiltinAnimation = false;
0056     }
0057 
0058     function stop() {
0059         if (running) {
0060             clear();
0061         }
0062     }
0063 
0064     onIsDemandingAttentionChanged: {
0065         if(isDemandingAttention){
0066             startNewWindowAnimation();
0067         }
0068     }
0069 
0070     function init(){
0071         taskItem.setBlockingAnimation(true);
0072         taskItem.inNewWindowBuiltinAnimation = true;
0073         taskItem.inAttentionBuiltinAnimation = isDemandingAttention;
0074         taskItem.abilities.animations.needThickness.addEvent(needThicknessEvent);
0075     }
0076 
0077     function startNewWindowAnimation(){
0078         if (isDemandingAttention && taskItem.abilities.indicators.info.providesInAttentionAnimation) {
0079             return;
0080         } else if (!isDemandingAttention && taskItem.abilities.indicators.info.providesGroupedWindowAddedAnimation) {
0081             return;
0082         }
0083 
0084         if (!taskItem.abilities.myView.isHidden
0085                 && ((root.windowInAttentionEnabled && isDemandingAttention)
0086                     || root.windowAddedInGroupEnabled)){
0087             if (newWindowAnimationLoader.status !== Loader.Ready) {
0088                 inDelayedStartup = true;
0089             } else {
0090                 newWindowAnimation.init();
0091                 newWindowAnimationLoader.item.start();
0092             }
0093         }
0094     }
0095 
0096     Component.onCompleted: {
0097         taskItem.taskGroupedWindowAdded.connect(startNewWindowAnimation);
0098     }
0099 
0100     Component.onDestruction: {
0101         taskItem.taskGroupedWindowAdded.disconnect(startNewWindowAnimation);
0102         taskItem.abilities.animations.needThickness.removeEvent(needThicknessEvent);
0103     }
0104 }