From 5b3c00ff8c380950c0921cb5d6a1b98138325c76 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 19 Feb 2018 10:45:56 +0200 Subject: [PATCH] improve code for enable/disable checkRestoreZoom --- .../package/contents/ui/applet/AppletItem.qml | 6 ++- containment/package/contents/ui/main.qml | 46 ++++++------------- plasmoid/package/contents/ui/main.qml | 16 ++++++- .../package/contents/ui/task/TaskDelegate.qml | 14 +++--- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 8c3e53e6a..19e87bb52 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -564,6 +564,10 @@ Item { onEntered: { //AppletIndetifier.reconsiderAppletIconItem(); + if (containsMouse && !container.lockZoom && container.canBeHovered){ + root.stopCheckRestoreZoomTimer(); + } + if (restoreAnimation.running) { restoreAnimation.stop(); } @@ -613,7 +617,7 @@ Item { root.hideTooltipLabel(); if (root.zoomFactor>1){ - checkRestoreZoom.start(); + root.startCheckRestoreZoomTimer(); } } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 68de97efa..7854349b4 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1112,6 +1112,10 @@ DragDrop.DropArea { checkRestoreZoom.start(); } + function stopCheckRestoreZoomTimer(){ + checkRestoreZoom.stop(); + } + function setGlobalDirectRender(value) { if (latteApplet && latteApplet.waitingLaunchers.length > 0) return; @@ -1308,11 +1312,10 @@ DragDrop.DropArea { ignoreUnknownSignals : true onContainsMouseChanged: { - if (dock.visibility.containsMouse) { - if (checkRestoreZoom.running) - checkRestoreZoom.stop(); + if (mouseInHoverableArea()) { + stopCheckRestoreZoomTimer(); } else { - checkRestoreZoom.start(); + startCheckRestoreZoomTimer(); } } } @@ -1465,11 +1468,14 @@ DragDrop.DropArea { id: rootMouseArea anchors.fill: parent hoverEnabled: true - onEntered: { - initializeHoveredIndexes(); - if(!root.editMode) - checkRestoreZoom.start(); + onContainsMouseChanged: { + if (mouseInHoverableArea()) { + stopCheckRestoreZoomTimer(); + } else { + initializeHoveredIndexes(); + startCheckRestoreZoomTimer() + } } } @@ -1580,9 +1586,6 @@ DragDrop.DropArea { return; if (!mouseInHoverableArea()) { - if (enableDirectRenderTimer.running) - enableDirectRenderTimer.stop(); - setGlobalDirectRender(false); root.initializeHoveredIndexes(); root.clearZoom(); @@ -1594,27 +1597,6 @@ DragDrop.DropArea { } } - //this timer adds a delay into enabling direct rendering... - //it gives the time to neighbour tasks to complete their animation - //during first hovering phase - Timer { - id: enableDirectRenderTimer - interval: 0 //checkRestoreZoom.interval + 20 //4 * root.durationTime * units.shortDuration - onTriggered: { - /* if (latteApplet && latteApplet.waitingLaunchers.length > 0) - return; - - if (dock.visibility.containsMouse && !rootMouseArea.containsMouse && mouseInCanBeHoveredApplet()){ - setGlobalDirectRender(true); - } - - if (root.debugModeTimers) { - console.log("containment timer: enableDirectRenderTimer called..."); - }*/ - } - } - - //this is a delayer to update mask area, it is used in cases //that animations can not catch up with animations signals //e.g. the automaicIconSize case diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index f2923d7a2..fa5b92ad7 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -1621,11 +1621,23 @@ Item { } } - function startCheckRestoreZoomTimer() { + function startCheckRestoreZoomTimer(duration) { if (latteDock) { latteDock.startCheckRestoreZoomTimer(); } else { - checkListHovered.startNormal(); + if (duration > 0) { + checkListHovered.startDuration(duration); + } else { + checkListHovered.startNormal(); + } + } + } + + function stopCheckRestoreZoomTimer() { + if (latteDock) { + latteDock.stopCheckRestoreZoomTimer(); + } else { + checkListHovered.stop(); } } diff --git a/plasmoid/package/contents/ui/task/TaskDelegate.qml b/plasmoid/package/contents/ui/task/TaskDelegate.qml index 16d26a8fd..e81292394 100644 --- a/plasmoid/package/contents/ui/task/TaskDelegate.qml +++ b/plasmoid/package/contents/ui/task/TaskDelegate.qml @@ -504,6 +504,8 @@ MouseArea{ if (root.editMode) return; + root.stopCheckRestoreZoomTimer(); + if (restoreAnimation.running) { restoreAnimation.stop(); } @@ -525,9 +527,6 @@ MouseArea{ icList.hoveredIndex = index; } - if(!root.latteDock) - checkListHovered.stop(); - if (root.latteDock && (!root.showPreviews || (root.showPreviews && isLauncher))){ root.latteDock.showTooltipLabel(mainItemContainer, model.AppName); } @@ -588,8 +587,7 @@ MouseArea{ if (root.editMode || (inBlockingAnimation && !(inAttentionAnimation||inFastRestoreAnimation||inMimicParabolicAnimation))) return; - if(!root.latteDock) - checkListHovered.stop(); + root.stopCheckRestoreZoomTimer(); if (root.latteDock && root.latteDock.isHalfShown) { return; @@ -784,8 +782,9 @@ MouseArea{ pressed = false; - if(!inAnimation && !root.latteDock) - checkListHovered.startDuration(3*units.longDuration); + if(!inAnimation) { + startCheckRestoreZoomTimer(3*units.longDuration); + } } onWheel: { @@ -845,7 +844,6 @@ MouseArea{ function animationEnded(){ // console.log("Animation ended: " + index); inAnimation = false; - // checkListHovered.startDuration(3*units.longDuration); } function clearZoom(){