1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-09 00:58:15 +03:00

plasmoid:provide ToBeRemoved Launchers

--in order to provide valid removal launchers
animations through TasksExtendedManager
This commit is contained in:
Michail Vourlakos 2021-01-09 20:53:12 +02:00
parent 3085e6aa3d
commit 4c5c96084c
4 changed files with 71 additions and 28 deletions

View File

@ -49,14 +49,19 @@ Item {
property variant launchersToBeMoved: []
//! Launchers that are added from user actions. They can be used in order
//! to be provide adding animations
//! to provide addition animations properly
property variant launchersToBeAdded: []
//! Launchers that are added from user actions. They can be used in order
//! to provide removal animations properly
property variant launchersToBeRemoved: []
//! 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: []
property int launchersToBeRemovedCount: 0 //is used to update instantly relevant bindings
signal waitingLauncherRemoved(string launch);
@ -146,6 +151,41 @@ Item {
console.log("TO BE ADDED LAUNCHERS ::: " + launchersToBeAdded);
}
//! LAUNCHERSTOBEREMOVED
function addToBeRemovedLauncher(launcher){
arraysGarbageCollectorTimer.restart();
if (isLauncherToBeRemoved(launcher)) {
return;
}
launchersToBeRemoved.push(launcher);
launchersToBeRemovedCount++;
}
function removeToBeRemovedLauncher(launcher){
if (!isLauncherToBeRemoved(launcher)) {
return;
}
for(var i=0; i<launchersToBeRemoved.length; ++i){
if (launchersToBeRemoved[i] === launcher) {
launchersToBeRemoved.splice(i,1);
launchersToBeRemovedCount--;
return;
}
}
}
function isLauncherToBeRemoved(launcher) {
return launchersToBeRemoved.indexOf(launcher)>=0;
}
function printToBeRemovedLaunchers() {
console.log("TO BE REMOVED LAUNCHERS ::: " + launchersToBeRemoved);
}
//! IMMEDIATELAUNCHERS
function addImmediateLauncher(launch){
arraysGarbageCollectorTimer.restart();
@ -338,12 +378,14 @@ Item {
tasksExtManager.printImmediateLaunchers();
tasksExtManager.printToBeAddedLaunchers();
tasksExtManager.printToBeMovedLaunchers();
tasksExtManager.printToBeRemovedLaunchers();
tasksExtManager.printWaitingLaunchers();
tasksExtManager.printFrozenTasks();
immediateLaunchers.splice(0, immediateLaunchers.length);
launchersToBeAdded.splice(0, launchersToBeAdded.length);
launchersToBeMoved.splice(0, launchersToBeMoved.length);
launchersToBeRemoved.splice(0, launchersToBeRemoved.length);
waitingLaunchers.splice(0, waitingLaunchers.length);
frozenTasks.splice(0, frozenTasks.length);
}

View File

@ -39,6 +39,8 @@ Item {
readonly property LaunchersPart.Syncer syncer: LaunchersPart.Syncer{}
readonly property LaunchersPart.Validator validator: LaunchersPart.Validator{}
readonly property string NULLACTIVITYID: "00000000-0000-0000-0000-000000000000"
function inUniqueGroup() {
return group === LatteCore.Types.UniqueLaunchers;
}
@ -102,7 +104,7 @@ Item {
launchers.group,
launcherUrl);
} else {
root.launcherForRemoval = launcherUrl;
tasksExtendedManager.addToBeRemovedLauncher(launcherUrl);
_launchers.tasksModel.requestRemoveLauncher(launcherUrl);
_launchers.launcherChanged(launcherUrl);
}
@ -116,7 +118,7 @@ Item {
activityId);
} else {
if (activityId !== activityInfo.currentActivity && isOnAllActivities(launcherUrl)) {
root.launcherForRemoval = url;
tasksExtendedManager.addToBeRemovedLauncher(launcherUrl);
}
_launchers.tasksModel.requestAddLauncherToActivity(launcherUrl, activityId);
@ -132,7 +134,7 @@ Item {
activityId);
} else {
if (activityId === activityInfo.currentActivity) {
root.launcherForRemoval = launcherUrl;
tasksExtendedManager.addToBeRemovedLauncher(launcherUrl);
}
_launchers.tasksModel.requestRemoveLauncherFromActivity(launcherUrl, activityId);
_launchers.launcherChanged(launcherUrl);
@ -142,9 +144,7 @@ Item {
function inCurrentActivity(launcherUrl) {
var activities = _launchers.tasksModel.launcherActivities(launcherUrl);
var NULL_UUID = "00000000-0000-0000-0000-000000000000";
if (activities.length === 0 || activities.indexOf(NULL_UUID) !== -1 || activities.indexOf(activityInfo.currentActivity) !== -1) {
if (activities.length === 0 || activities.indexOf(NULLACTIVITYID) !== -1 || activities.indexOf(activityInfo.currentActivity) !== -1) {
return true;
}
@ -153,8 +153,7 @@ Item {
function isOnAllActivities(launcherUrl) {
var activities = _launchers.tasksModel.launcherActivities(url);
var NULL_UUID = "00000000-0000-0000-0000-000000000000";
return (activities.indexOf(NULL_UUID) >= 0)
return (activities.indexOf(NULLACTIVITYID) >= 0)
}
function childAtLayoutIndex(position) {

View File

@ -140,9 +140,6 @@ Item {
|| !latteView.dragInfo.isPlasmoid)
: true
//! it is used to play the animation correct when the user removes a launcher
property string launcherForRemoval: ""
//BEGIN Latte Dock properties
property bool badges3DStyle: latteView ? latteView.badges3DStyle : true
property bool dockIsShownCompletely: latteView ? latteView.dockIsShownCompletely : true
@ -1443,7 +1440,7 @@ Item {
function extSignalRemoveLauncher(group, launcher) {
if (group === launchers.group) {
root.launcherForRemoval = launcher;
tasksExtendedManager.addToBeRemovedLauncher(launcher);
tasksModel.requestRemoveLauncher(launcher);
launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
@ -1455,7 +1452,7 @@ Item {
var launcherActivities = tasksModel.launcherActivities(launcher);
if (activity !== tasksModel.activity && (launcherActivities[0] === "00000000-0000-0000-0000-000000000000")) {
root.launcherForRemoval = launcher;
tasksExtendedManager.addToBeRemovedLauncher(launcher);
}
tasksModel.requestAddLauncherToActivity(launcher, activity);
@ -1467,7 +1464,7 @@ Item {
function extSignalRemoveLauncherFromActivity(group, launcher, activity) {
if (group === launchers.group) {
if (activity === tasksModel.activity) {
root.launcherForRemoval = launcher;
tasksExtendedManager.addToBeRemovedLauncher(launcher);
}
tasksModel.requestRemoveLauncherFromActivity(launcher, activity);
@ -1560,7 +1557,7 @@ Item {
tasksExtendedManager.addToBeAddedLauncher(filename);
tasksModel.requestAddLauncher(url);
launchers.launcherChanged(launcher);
launchers.launcherChanged(url);
tasksModel.syncLaunchers();
}

View File

@ -38,16 +38,20 @@ SequentialAnimation {
&& tasksModel.launcherPosition(taskItem.launcherUrlWithIcon) === -1)
|| ((!taskItem.launchers.inCurrentActivity(taskItem.launcherUrl)/*no-launcher-in-current-activity*/
&& !taskItem.launchers.inCurrentActivity(taskItem.launcherUrlWithIcon)))
&& !taskItem.isStartup && LatteCore.WindowSystem.compositingActive)
&& !taskItem.isStartup
&& LatteCore.WindowSystem.compositingActive)
property bool animation4: ((taskItem.launcherUrl===root.launcherForRemoval
|| taskItem.launcherUrlWithIcon===root.launcherForRemoval )
&& !taskItem.isStartup && LatteCore.WindowSystem.compositingActive)
property bool animation4: (tasksExtendedManager.launchersToBeRemovedCount /*update trigger*/
&& (tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrl)
|| tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrlWithIcon))
&& !taskItem.isStartup
&& LatteCore.WindowSystem.compositingActive)
property bool enabledAnimation: (animation1 || animation4) && (taskItem.animations.newWindowSlidingEnabled)
property bool enabledAnimation: (animation1 || animation4)
&& (taskItem.animations.newWindowSlidingEnabled)
&& !taskItem.inBouncingAnimation
&& !taskItem.isSeparator
&& taskItem.visible;
&& taskItem.visible
readonly property string needLengthEvent: taskRealRemovalAnimation + "_realremoval"
@ -107,7 +111,7 @@ SequentialAnimation {
//console.log("1." + taskItem.launcherUrl + " - " + taskItem.launchers.inCurrentActivity(taskItem.launcherUrl) + "__" +
// animation1 + ":" + animation4 + "=>" + taskRealRemovalAnimation.enabledAnimation);
//console.log("2." + root.launcherForRemoval + " - " + taskItem.isLauncher);
//console.log("2." + taskItem.isLauncher);
taskItem.animations.needLength.addEvent(needLengthEvent);
@ -138,7 +142,7 @@ SequentialAnimation {
target: wrapper
property: "mScale"
to: 1
duration: taskRealRemovalAnimation.enabledAnimation ? showWindowAnimation.speed : 0
duration: taskRealRemovalAnimation.enabledAnimation ? showWindowAnimation.speed : 0
easing.type: Easing.InQuad
}
@ -161,7 +165,7 @@ SequentialAnimation {
target: wrapper
property: (icList.orientation === Qt.Vertical) ? "tempScaleWidth" : "tempScaleHeight"
to: 0
duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
easing.type: Easing.InQuad
}
}
@ -171,7 +175,7 @@ SequentialAnimation {
target: wrapper
property: (icList.orientation === Qt.Vertical) ? "tempScaleHeight" : "tempScaleWidth"
to: 0
duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
duration: taskRealRemovalAnimation.enabledAnimation ? 1.35*showWindowAnimation.speed : 0
easing.type: Easing.InQuad
}
@ -185,8 +189,9 @@ SequentialAnimation {
taskItem.animations.needLength.removeEvent(needLengthEvent);
if(taskItem.launcherUrl===root.launcherForRemoval && taskItem.isLauncher)
root.launcherForRemoval="";
if(tasksExtendedManager.isLauncherToBeRemoved(taskItem.launcherUrl) && taskItem.isLauncher) {
tasksExtendedManager.removeToBeRemovedLauncher(taskItem.launcherUrl);
}
if (windowsPreviewDlg.visible && windowsPreviewDlg.mainItem.parentTask === taskItem
&& isWindow && !isGroupParent){