From b30862a5beffee87beb517e5e54edbfe2b3ddea1 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 21 May 2017 19:13:02 +0300 Subject: [PATCH] protect the attention animation from mouse hovering --when the attention animation is played for a task and the user hovers that task, the animation is ended smoothly and if the mouse is still hovering the task, the tasks are restored correctly --- .../package/contents/ui/task/TaskDelegate.qml | 30 +++---- .../package/contents/ui/task/TaskIconItem.qml | 5 +- .../animations/TaskFastRestoreAnimation.qml | 78 +++++++++++++++++++ .../animations/TaskNewWindowAnimation.qml | 6 +- 4 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 plasmoid/package/contents/ui/task/animations/TaskFastRestoreAnimation.qml diff --git a/plasmoid/package/contents/ui/task/TaskDelegate.qml b/plasmoid/package/contents/ui/task/TaskDelegate.qml index 571b20656..2a6f97565 100644 --- a/plasmoid/package/contents/ui/task/TaskDelegate.qml +++ b/plasmoid/package/contents/ui/task/TaskDelegate.qml @@ -449,19 +449,21 @@ MouseArea{ if((!inAnimation)&&(root.dragSource == null)&&(!root.taskInAnimation) && hoverEnabled){ icList.hoveredIndex = index; - mouseEntered = true; - root.mouseWasEntered(index-2, false); - root.mouseWasEntered(index+2, false); - root.mouseWasEntered(index-1, true); - root.mouseWasEntered(index+1, true); - - if (icList.orientation == Qt.Horizontal){ - icList.currentSpot = mouseX; - wrapper.calculateScales(mouseX); - } - else{ - icList.currentSpot = mouseY; - wrapper.calculateScales(mouseY); + if (!inBlockingAnimation) { + mouseEntered = true; + root.mouseWasEntered(index-2, false); + root.mouseWasEntered(index+2, false); + root.mouseWasEntered(index-1, true); + root.mouseWasEntered(index+1, true); + + if (icList.orientation == Qt.Horizontal){ + icList.currentSpot = mouseX; + wrapper.calculateScales(mouseX); + } + else{ + icList.currentSpot = mouseY; + wrapper.calculateScales(mouseY); + } } } } @@ -486,7 +488,7 @@ MouseArea{ } onPositionChanged: { - if (root.editMode) + if (root.editMode || inBlockingAnimation) return; if(!root.latteDock) diff --git a/plasmoid/package/contents/ui/task/TaskIconItem.qml b/plasmoid/package/contents/ui/task/TaskIconItem.qml index 34bba401c..532d78008 100644 --- a/plasmoid/package/contents/ui/task/TaskIconItem.qml +++ b/plasmoid/package/contents/ui/task/TaskIconItem.qml @@ -540,7 +540,8 @@ Item{ target: mainItemContainer onContainsMouseChanged: { if (mainItemContainer.containsMouse && newWindowAnimation.running) { - newWindowAnimation.stop(); + newWindowAnimation.pause(); + fastRestoreAnimation.start(); } } } @@ -555,6 +556,8 @@ Item{ TaskAnimations.TaskRemoveWindowFromGroupAnimation { id: removingAnimation } + TaskAnimations.TaskFastRestoreAnimation { id: fastRestoreAnimation } + //////////// States //////////////////// states: [ State{ diff --git a/plasmoid/package/contents/ui/task/animations/TaskFastRestoreAnimation.qml b/plasmoid/package/contents/ui/task/animations/TaskFastRestoreAnimation.qml new file mode 100644 index 000000000..0d775c3d6 --- /dev/null +++ b/plasmoid/package/contents/ui/task/animations/TaskFastRestoreAnimation.qml @@ -0,0 +1,78 @@ +/* +* Copyright 2016 Smith AR +* 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.0 + +import org.kde.plasma.plasmoid 2.0 + +///////Restore Zoom Animation///// +ParallelAnimation{ + id: fastRestoreAnimation + + property int speed: mainItemContainer.animationTime + + PropertyAnimation { + target: wrapper + property: "mScale" + to: 1 + duration: fastRestoreAnimation.speed + easing.type: Easing.Linear + } + + PropertyAnimation { + target: wrapper + property: "tempScaleWidth" + to: 1 + duration: fastRestoreAnimation.speed + easing.type: Easing.Linear + } + + PropertyAnimation { + target: wrapper + property: "tempScaleHeight" + to: 1 + duration: fastRestoreAnimation.speed + easing.type: Easing.Linear + } + + PropertyAnimation { + target: hiddenSpacerLeft + property: "nScale" + to: 0 + duration: fastRestoreAnimation.speed + easing.type: Easing.Linear + } + + PropertyAnimation { + target: hiddenSpacerRight + property: "nScale" + to: 0 + duration: fastRestoreAnimation.speed + easing.type: Easing.Linear + } + + onStopped: { + if (newWindowAnimation.paused){ + newWindowAnimation.stop(); + wrapper.calculateScales((root.iconSize+root.iconMargin)/2); + } + } + +} diff --git a/plasmoid/package/contents/ui/task/animations/TaskNewWindowAnimation.qml b/plasmoid/package/contents/ui/task/animations/TaskNewWindowAnimation.qml index ea459376f..d4c7e1355 100644 --- a/plasmoid/package/contents/ui/task/animations/TaskNewWindowAnimation.qml +++ b/plasmoid/package/contents/ui/task/animations/TaskNewWindowAnimation.qml @@ -30,7 +30,7 @@ SequentialAnimation{ property int speed: root.durationTime*units.longDuration property bool isDemandingAttention: (IsDemandingAttention === true) - property bool entered: mainItemContainer.mouseEntered + property bool containsMouse: mainItemContainer.containsMouse property bool needsThicknessSent: false //flag to check if the signal for thickness was sent SequentialAnimation{ @@ -80,6 +80,8 @@ SequentialAnimation{ wrapper.tempScaleWidth = 1; wrapper.tempScaleHeight = 1; + + mainItemContainer.setBlockingAnimation(false); } onStopped: { @@ -101,6 +103,8 @@ SequentialAnimation{ } function init(){ + mainItemContainer.setBlockingAnimation(true); + wrapper.tempScaleWidth = wrapper.mScale; wrapper.tempScaleHeight = wrapper.mScale;