Warning, /plasma/latte-dock/plasmoid/package/contents/ui/abilities/launchers/Syncer.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.0
0007 
0008 import org.kde.plasma.plasmoid 2.0
0009 
0010 import org.kde.latte.core 0.2 as LatteCore
0011 
0012 Item {
0013     id:_syncer
0014     property bool isBlocked: false
0015     readonly property bool isActive: bridge !== null && bridge.launchers.host !==null
0016     readonly property int clientId: plasmoid.id
0017     // used to identify launchers that need to be synced event though their launchers group type
0018     // does not support it e.g. taskmanagers synced in different screens
0019     readonly property string syncedGroupId: _launchers.groupId
0020 
0021     //! Connections
0022     Component.onCompleted: {
0023         if (isActive) {
0024             bridge.launchers.host.addAbilityClient(_syncer);
0025         }
0026     }
0027 
0028     Component.onDestruction: {
0029         if (bridge) {
0030             bridge.launchers.host.removeAbilityClient(_syncer);
0031         }
0032     }
0033 
0034     onIsActiveChanged: {
0035         if (isActive) {
0036             bridge.launchers.host.addAbilityClient(_syncer);
0037         } else if (bridge) {
0038             bridge.launchers.host.removeAbilityClient(_syncer);
0039         }
0040     }
0041 
0042     Connections {
0043         target: isActive ? bridge.launchers.host : null
0044         onIsReadyChanged: {
0045             if (bridge.launchers.host.isReady && _syncer.isActive) {
0046                 bridge.launchers.host.addAbilityClient(_syncer);
0047             }
0048         }
0049     }
0050 
0051     //! All following actions are triggerred from Main SyncedLaunchers handler
0052     function addSyncedLauncher(group, launcher) {
0053         if (group === _launchers.group) {
0054             tasksModel.requestAddLauncher(launcher);
0055             _launchers.launcherChanged(launcher);
0056             tasksModel.syncLaunchers();
0057         }
0058     }
0059 
0060     function removeSyncedLauncher(group, launcher) {
0061         if (group === _launchers.group) {
0062             _launchers.launcherInRemoving(launcher)
0063             tasksModel.requestRemoveLauncher(launcher);
0064             _launchers.launcherChanged(launcher);
0065             tasksModel.syncLaunchers();
0066         }
0067     }
0068 
0069     function addSyncedLauncherToActivity(group, launcher, activity) {
0070         if (group === _launchers.group) {
0071             if (activity !== activityInfo.currentActivity && _launchers.isOnAllActivities(launcher)) {
0072                 _launchers.launcherInRemoving(launcher);
0073             }
0074 
0075             tasksModel.requestAddLauncherToActivity(launcher, activity);
0076             _launchers.launcherChanged(launcher);
0077             tasksModel.syncLaunchers();
0078         }
0079     }
0080 
0081     function removeSyncedLauncherFromActivity(group, launcher, activity) {
0082         if (group === _launchers.group) {
0083             if (activity === activityInfo.currentActivity) {
0084                 _launchers.launcherInRemoving(launcher)
0085             }
0086 
0087             tasksModel.requestRemoveLauncherFromActivity(launcher, activity);
0088             _launchers.launcherChanged(launcher);
0089             tasksModel.syncLaunchers();
0090         }
0091     }
0092 
0093     function dropSyncedUrls(group, urls) {
0094         if (group === _launchers.group) {
0095             urls.forEach(function (item) {
0096                 _launchers.addDroppedLauncher(item);
0097             });
0098         }
0099     }
0100 
0101     function validateSyncedLaunchersOrder(group, orderedLaunchers) {
0102         if (group === _launchers.group && !isBlocked) {
0103             validator.stop();
0104             validator.launchers = orderedLaunchers;
0105             validator.start();
0106         }
0107     }
0108 
0109 }