/* * Copyright 2019 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 import org.kde.latte 0.2 as Latte //! Trying to WORKAROUND all the Plasma LibTaskManager limitations //! concerning Tasks AND Launchers. //! //! Plasma LibTaskManager constantly creates ADDITIONS/REMOVALS when //! a Task is changing its type from Launcher<->Startup<->Window. //! This libtaskmanager behavior limits a lot the animations that //! can be created in order to provide a moder user experience //! //! All the logic that is trying to improve the mentioned limits is provided //! from this class Item { id: tasksExtManager /// Launchers that are playing an ADD or REMOVAL animation /// and their Starups/Windows should be aware of property variant waitingLaunchers: [] //! Launchers that must be shown IMMEDIATELY after a window removal //! because they are already present from a present libtaskmanager state property variant immediateLaunchers: [] //! New launchers in order to be moved in correct place: //! launcher, pos) property variant launchersToBeMoved: [] //! Launchers that are added from user actions. They can be used in order //! to be provide adding animations property variant launchersToBeAdded: [] //! Tasks that change state (launcher,startup,window) and //! at the next state must look the same concerning the parabolic effect: //! (id, mScale) property variant frozenTasks: [] signal waitingLauncherRemoved(string launch); /////////// FUNCTIONALITY //////////////////// /// WAITING LAUNCHERS function addWaitingLauncher(launch){ arraysGarbageCollectorTimer.restart(); if (waitingLauncherExists(launch)) { return; } waitingLaunchers.push(launch); } function removeWaitingLauncher(launch){ for(var i=0; i= 0 || waitingLauncher.indexOf(launcher) >= 0)); return equals; } function waitingLaunchersLength() { return waitingLaunchers.length; } function printWaitingLaunchers() { console.log("WAITING LAUNCHERS ::: " + waitingLaunchers); } //! LAUNCHERSTOBEADDED function addToBeAddedLauncher(launcher){ arraysGarbageCollectorTimer.restart(); if (toBeAddedLauncherExists(launcher)) { return; } launchersToBeAdded.push(launcher); } function removeToBeAddedLauncher(launcher){ for(var i=0; i -1) { frozenTasks.splice(taskIndex, 1); } } function setFrozenTask(identifier, scale) { arraysGarbageCollectorTimer.restart(); var frozenTaskExists = false; console.log("SET FROZEN :: "+identifier+" - "+scale); var frozenTask = getFrozenTask(identifier); if (frozenTask) { frozenTask.mScale = scale; } else { frozenTasks.push({id: identifier, mScale: scale}); } } function printFrozenTasks() { var fzTasks= ""; for(var i=0; i=launchersToBeMoved.length) return -1; if (launchersToBeMoved[i].launcher === launcherUrl) { index = i; break; } } if (index > -1) { // console.log("removing launcher to be moved:: "+launcherUrl); launchersToBeMoved.splice(index, 1); } } } function posOfLauncherToBeMoved(launcherUrl) { var sLength = launchersToBeMoved.length; for (var i=0; i=launchersToBeMoved.length) return -1; if (launchersToBeMoved[i].launcher === launcherUrl) return launchersToBeMoved[i].pos; } return -1; } function isLauncherToBeMoved(launcher) { return (posOfLauncherToBeMoved(launcher) >= 0); } function printToBeMovedLaunchers() { var tbmLaunchers= ""; for(var i=0; i