use Launchers Ability for syncing

--move internal synced launchers infrastructure
in order to use Launchers Ability. Things
this way will become much cleaner and
at the same reusable and maintainable
work/spdx
Michail Vourlakos 4 years ago
parent 15c3b3630a
commit 1ca43ee13f

@ -48,67 +48,55 @@ LaunchersSignals::~LaunchersSignals()
{
}
QList<Plasma::Applet *> LaunchersSignals::lattePlasmoids(QString layoutName)
void LaunchersSignals::addAbilityClient(QQuickItem *client)
{
QList<Plasma::Applet *> applets;
CentralLayout *layout = m_manager->synchronizer()->centralLayout(layoutName);
QList<Plasma::Containment *> containments;
if (layoutName.isEmpty()) {
containments = m_manager->corona()->containments();
} else if (layout) {
containments = *(layout->containments());
if (m_clients.contains(client)) {
return;
}
for(const auto containment : containments) {
for(auto *applet : containment->applets()) {
KPluginMetaData meta = applet->kPackage().metadata();
m_clients << client;
if (meta.pluginId() == "org.kde.latte.plasmoid") {
applets.append(applet);
}
}
}
return applets;
connect(client, &QObject::destroyed, this, &LaunchersSignals::removeClientObject);
}
void LaunchersSignals::addLauncher(QString layoutName, int launcherGroup, QString launcher)
void LaunchersSignals::removeAbilityClient(QQuickItem *client)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
if ((Types::LaunchersGroup)group == Types::UniqueLaunchers) {
if (!m_clients.contains(client)) {
return;
}
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
disconnect(client, &QObject::destroyed, this, &LaunchersSignals::removeClientObject);
m_clients.removeAll(client);
}
for(const auto applet : lattePlasmoids(lName)) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
void LaunchersSignals::removeClientObject(QObject *obj)
{
QQuickItem *item = qobject_cast<QQuickItem *>(obj);
if (childItems.isEmpty()) {
continue;
if (item) {
removeAbilityClient(item);
}
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalAddLauncher(QVariant,QVariant)");
if (methodIndex == -1) {
continue;
}
QList<QQuickItem *> LaunchersSignals::clients(QString layoutName)
{
QList<QQuickItem *> items;
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher));
}
if (!layoutName.isEmpty()) {
for(const auto client: m_clients) {
QString cLayoutName = client->property("layoutName").toString();
if (cLayoutName == layoutName) {
items << client;
}
}
} else {
items = m_clients;
}
return items;
}
void LaunchersSignals::removeLauncher(QString layoutName, int launcherGroup, QString launcher)
void LaunchersSignals::addLauncher(QString layoutName, int launcherGroup, QString launcher)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
@ -118,31 +106,22 @@ void LaunchersSignals::removeLauncher(QString layoutName, int launcherGroup, QSt
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalRemoveLauncher(QVariant,QVariant)");
for(const auto client : clients(lName)) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("addSyncedLauncher(QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: addSyncedLauncher(QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher));
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher));
}
}
}
void LaunchersSignals::addLauncherToActivity(QString layoutName, int launcherGroup, QString launcher, QString activity)
void LaunchersSignals::removeLauncher(QString layoutName, int launcherGroup, QString launcher)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
@ -152,31 +131,22 @@ void LaunchersSignals::addLauncherToActivity(QString layoutName, int launcherGro
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalAddLauncherToActivity(QVariant,QVariant,QVariant)");
for(const auto client : clients(lName)) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("removeSyncedLauncher(QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: removeSyncedLauncher(QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher), Q_ARG(QVariant, activity));
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher));
}
}
}
void LaunchersSignals::removeLauncherFromActivity(QString layoutName, int launcherGroup, QString launcher, QString activity)
void LaunchersSignals::addLauncherToActivity(QString layoutName, int launcherGroup, QString launcher, QString activity)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
@ -186,31 +156,22 @@ void LaunchersSignals::removeLauncherFromActivity(QString layoutName, int launch
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalRemoveLauncherFromActivity(QVariant,QVariant,QVariant)");
for(const auto client : clients(lName)) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("addSyncedLauncherToActivity(QVariant,QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: addSyncedLauncherToActivity(QVariant,QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher), Q_ARG(QVariant, activity));
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher), Q_ARG(QVariant, activity));
}
}
}
void LaunchersSignals::urlsDropped(QString layoutName, int launcherGroup, QStringList urls)
void LaunchersSignals::removeLauncherFromActivity(QString layoutName, int launcherGroup, QString launcher, QString activity)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
@ -220,31 +181,22 @@ void LaunchersSignals::urlsDropped(QString layoutName, int launcherGroup, QStrin
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalUrlsDropped(QVariant,QVariant)");
for(const auto client : clients(lName)) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("removeSyncedLauncherFromActivity(QVariant,QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: removeSyncedLauncherFromActivity(QVariant,QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, urls));
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launcher), Q_ARG(QVariant, activity));
}
}
}
void LaunchersSignals::moveTask(QString layoutName, uint senderId, int launcherGroup, int from, int to)
void LaunchersSignals::urlsDropped(QString layoutName, int launcherGroup, QStringList urls)
{
Types::LaunchersGroup group = static_cast<Types::LaunchersGroup>(launcherGroup);
@ -254,28 +206,17 @@ void LaunchersSignals::moveTask(QString layoutName, uint senderId, int launcherG
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (applet->id() != senderId) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalMoveTask(QVariant,QVariant,QVariant)");
for(const auto client : clients(lName)) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("dropSyncedUrls(QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: dropSyncedUrls(QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, from), Q_ARG(QVariant, to));
}
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, urls));
}
}
}
@ -290,27 +231,20 @@ void LaunchersSignals::validateLaunchersOrder(QString layoutName, uint senderId,
QString lName = (group == Types::LayoutLaunchers) ? layoutName : "";
for(const auto applet : lattePlasmoids(lName)) {
if (applet->id() != senderId) {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for(const auto client : clients(lName)) {
uint clientId = client->property("clientId").toUInt();
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
int methodIndex = metaObject->indexOfMethod("extSignalValidateLaunchersOrder(QVariant,QVariant)");
if (clientId != senderId) {
if (auto *metaObject = client->metaObject()) {
int methodIndex = metaObject->indexOfMethod("validateSyncedLaunchersOrder(QVariant,QVariant)");
if (methodIndex == -1) {
qDebug() << "Launchers Syncer Ability: validateSyncedLaunchersOrder(QVariant,QVariant) was NOT found...";
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(item, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launchers));
}
}
method.invoke(client, Q_ARG(QVariant, launcherGroup), Q_ARG(QVariant, launchers));
}
}
}

@ -22,7 +22,9 @@
#define LAUNCHERSSIGNALS_H
// Qt
#include <QList>
#include <QObject>
#include <QQuickItem>
namespace Plasma {
class Applet;
@ -52,20 +54,26 @@ public:
~LaunchersSignals() override;
public slots:
Q_INVOKABLE void addAbilityClient(QQuickItem *client);
Q_INVOKABLE void removeAbilityClient(QQuickItem *client);
Q_INVOKABLE void addLauncher(QString layoutName, int launcherGroup, QString launcher);
Q_INVOKABLE void removeLauncher(QString layoutName, int launcherGroup, QString launcher);
Q_INVOKABLE void addLauncherToActivity(QString layoutName, int launcherGroup, QString launcher, QString activity);
Q_INVOKABLE void removeLauncherFromActivity(QString layoutName, int launcherGroup, QString launcher, QString activity);
Q_INVOKABLE void urlsDropped(QString layoutName, int launcherGroup, QStringList urls);
//!Deprecated because it could create crashes, validateLaunchersOrder provides a better approach
Q_INVOKABLE void moveTask(QString layoutName, uint senderId, int launcherGroup, int from, int to);
Q_INVOKABLE void validateLaunchersOrder(QString layoutName, uint senderId, int launcherGroup, QStringList launchers);
private:
QList<Plasma::Applet *> lattePlasmoids(QString layoutName);
QList<QQuickItem *> clients(QString layoutName = QString());
private slots:
void removeClientObject(QObject *obj);
private:
Layouts::Manager *m_manager{nullptr};
QList<QQuickItem *> m_clients;
};
}

@ -0,0 +1,74 @@
/*
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import org.kde.plasma.plasmoid 2.0
Item {
readonly property bool isReady: root.layoutsManager !== null
property string layoutName: ""
function addAbilityClient(client) {
layoutsManager.launchersSignals.addAbilityClient(client);
}
function removeAbilityClient(client) {
layoutsManager.launchersSignals.removeAbilityClient(client);
}
function addSyncedLauncher(group, launcherUrl) {
layoutsManager.launchersSignals.addLauncher(layoutName,
group,
launcherUrl);
}
function removeSyncedLauncher(group, launcherUrl) {
layoutsManager.launchersSignals.removeLauncher(layoutName,
group,
launcherUrl);
}
function addSyncedLauncherToActivity(group, launcherUrl, activityId) {
layoutsManager.launchersSignals.addLauncherToActivity(layoutName,
group,
launcherUrl,
activityId);
}
function removeSyncedLauncherFromActivity(group, launcherUrl, activityId) {
layoutsManager.launchersSignals.removeLauncherFromActivity(layoutName,
group,
launcherUrl,
activityId);
}
function addDroppedLaunchers(group, urls) {
layoutsManager.launchersSignals.urlsDropped(layoutName,
group,
urls);
}
function validateSyncedLaunchersOrder(senderId, group, orderedlaunchers) {
layoutsManager.launchersSignals.validateLaunchersOrder(layoutName,
senderId,
group,
orderedlaunchers);
}
}

@ -325,6 +325,7 @@ Item {
property Item animations: null
property Item debug: null
property Item indexer: null
property Item launchers: null
property Item layouter: null
property Item layouts: null
property Item metrics: null

@ -142,6 +142,7 @@ Item{
readonly property Item actions: Actions{}
readonly property Item applet: mainCommunicator.requires
readonly property Item debug: appletItem.debug.publicApi
readonly property Item launchers: appletItem.launchers
readonly property Item metrics: appletItem.metrics.publicApi
readonly property Item userRequests: appletItem.userRequests

@ -1163,6 +1163,7 @@ Item {
animations: _animations
debug: _debug
indexer: _indexer
launchers: _launchers
layouter: _layouter
layouts: layoutsContainer
metrics: _metrics
@ -1389,6 +1390,11 @@ Item {
layouts: layoutsContainer
}
Ability.Launchers {
id: _launchers
layoutName: viewLayout ? viewLayout.name : ""
}
Ability.Layouter {
id: _layouter
animations: _animations

@ -833,8 +833,7 @@ PlasmaComponents.ContextMenu {
onClicked: {
var pos=visualParent.itemIndex;
root.addInternalSeparatorAtPos(pos);
launchers.addInternalSeparatorAtPos(pos);
}
}

@ -344,9 +344,9 @@ Item {
//! Connections
Connections {
target: launchers
onLauncherInRemoving: {
addToBeRemovedLauncher(launcherUrl);
}
onLauncherInRemoving: tasksExtManager.addToBeRemovedLauncher(launcherUrl);
onLauncherInAdding: tasksExtManager.addToBeAddedLauncher(launcherUrl);
onLauncherInMoving: tasksExtManager.addLauncherToBeMoved(launcherUrl, pos);
}

@ -29,12 +29,15 @@ Item {
id: _launchers
signal launcherChanged(string launcherUrl);
signal launcherRemoved(string launcherUrl);
//! triggered just before action happens. They are used mostly for animation purposes
signal launcherInAdding(string launcherUrl);
signal launcherInRemoving(string launcherUrl);
signal launcherInMoving(string launcherUrl, int pos);
property int group: LatteCore.Types.UniqueLaunchers
property Item bridge: null
property Item layout: null
property QtObject tasksModel: null
readonly property LaunchersPart.Actions actions: LaunchersPart.Actions{}
@ -90,9 +93,8 @@ Item {
}
function addLauncher(launcherUrl) {
if (latteView && !inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(root.viewLayoutName,
launchers.group,
if (bridge && !inUniqueGroup()) {
bridge.launchers.addSyncedLauncher(launchers.group,
launcherUrl);
} else {
_launchers.tasksModel.requestAddLauncher(launcherUrl);
@ -100,10 +102,47 @@ Item {
}
}
function addDroppedLauncher(launcherUrl) {
//workaround to protect in case the launcher contains the iconData
var pos = launcherUrl.indexOf("?iconData=");
if (pos>0) {
launcherUrl = launcherUrl.substring( 0, launcherUrl.indexOf("?iconData=" ) );
}
var path = launcherUrl;
var filename = path.split("/").pop();
_launchers.launcherInAdding(filename);
tasksModel.requestAddLauncher(launcherUrl);
launchers.launcherChanged(launcherUrl);
tasksModel.syncLaunchers();
}
function addDroppedLaunchers(urls) {
//! inform synced docks for new dropped launchers
if (bridge && !launchers.inUniqueGroup()) {
bridge.launchers.addDroppedLaunchers(launchers.group,
urls);
} else {
urls.forEach(function (item) {
addDroppedLauncher(item);
});
}
}
function addInternalSeparatorAtPos(pos) {
var separatorName = freeAvailableSeparatorName();
if (separatorName !== "") {
_launchers.launcherInMoving(separatorName, Math.max(0,pos));
addLauncher(separatorName);
}
}
function removeLauncher(launcherUrl) {
if (latteView && !inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncher(root.viewLayoutName,
launchers.group,
if (bridge && !inUniqueGroup()) {
bridge.launchers.removeSyncedLauncher(launchers.group,
launcherUrl);
} else {
_launchers.launcherInRemoving(launcherUrl);
@ -113,9 +152,8 @@ Item {
}
function addLauncherToActivity(launcherUrl, activityId) {
if (latteView && !inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncherToActivity(root.viewLayoutName,
launchers.group,
if (bridge && !inUniqueGroup()) {
bridge.launchers.addSyncedLauncherToActivity(launchers.group,
launcherUrl,
activityId);
} else {
@ -129,9 +167,8 @@ Item {
}
function removeLauncherFromActivity(launcherUrl, activityId) {
if (latteView && !inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncherFromActivity(root.viewLayoutName,
launchers.group,
if (bridge && !inUniqueGroup()) {
bridge.launchers.removeSyncedLauncherFromActivity(launchers.group,
launcherUrl,
activityId);
} else {
@ -143,6 +180,12 @@ Item {
}
}
function validateLaunchersOrder(orderedLaunchers) {
validator.stop();
validator.launchers = orderedLaunchers;
validator.start();
}
function inCurrentActivity(launcherUrl) {
var activities = _launchers.tasksModel.launcherActivities(launcherUrl);
@ -246,15 +289,7 @@ Item {
return launch;
}
function validateOrder(orderedLaunchers) {
validator.stop();
validator.launchers = orderedLaunchers;
validator.start();
}
//! Connections
onGroupChanged:{
if(latteView) {
_launchers.tasksModel.updateLaunchersList();
@ -287,9 +322,8 @@ Item {
}
if (inDraggingPhase) {
if (latteView && !_launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.validateLaunchersOrder(root.viewLayoutName,
plasmoid.id,
if (_launchers.bridge && !_launchers.inUniqueGroup()) {
_launchers.bridge.launchers.validateSyncedLaunchersOrder(_launchers.syncer.clientId,
_launchers.group,
_launchers.currentShownLauncherList());
}

@ -24,6 +24,97 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.latte.core 0.2 as LatteCore
Item {
id:_syncer
property bool isBlocked: false
readonly property bool isActive: bridge !== null && group !== LatteCore.Types.UniqueLaunchers
readonly property int clientId: plasmoid.id
property string layoutName: ""
//! Connections
Component.onCompleted: {
if (isActive) {
bridge.launchers.addAbilityClient(_syncer);
}
}
Component.onDestruction: {
if (bridge) {
bridge.launchers.removeAbilityClient(_syncer);
}
}
onIsActiveChanged: {
if (isActive) {
bridge.launchers.addAbilityClient(_syncer);
} else if (bridge) {
bridge.launchers.removeAbilityClient(_syncer);
}
}
Connections {
target: isActive ? bridge.launchers : null
onIsReadyChanged: {
if (isReady && _syncer.isActive) {
bridge.launchers.addAbilityClient(_syncer);
}
}
}
//! All following actions are triggerred from Main SyncedLaunchers handler
function addSyncedLauncher(group, launcher) {
if (group === _launchers.group) {
tasksModel.requestAddLauncher(launcher);
_launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function removeSyncedLauncher(group, launcher) {
if (group === _launchers.group) {
_launchers.launcherInRemoving(launcher)
tasksModel.requestRemoveLauncher(launcher);
_launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function addSyncedLauncherToActivity(group, launcher, activity) {
if (group === _launchers.group) {
if (activity !== activityInfo.currentActivity && _launchers.isOnAllActivities(launcher)) {
_launchers.launcherInRemoving(launcher);
}
tasksModel.requestAddLauncherToActivity(launcher, activity);
_launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function removeSyncedLauncherFromActivity(group, launcher, activity) {
if (group === _launchers.group) {
if (activity === activityInfo.currentActivity) {
_launchers.launcherInRemoving(launcher)
}
tasksModel.requestRemoveLauncherFromActivity(launcher, activity);
_launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function dropSyncedUrls(group, urls) {
if (group === _launchers.group) {
urls.forEach(function (item) {
_launchers.addDroppedLauncher(item);
});
}
}
function validateSyncedLaunchersOrder(group, orderedLaunchers) {
if (group === _launchers.group && !isBlocked) {
_launchers.validateLaunchersOrder(orderedLaunchers);
}
}
}

@ -835,6 +835,8 @@ Item {
group: plasmoid.configuration.launchersGroup
layout: icList.contentItem
tasksModel: tasksModel
syncer.isBlocked: inDraggingPhase
syncer.layoutName: viewLayoutName
}
Ability.Metrics {
@ -1040,15 +1042,16 @@ Item {
});
}
function urlsDroppedOnArea(urls){
// If all dropped URLs point to application desktop files, we'll add a launcher for each of them.
onUrlsDropped: {
//! inform synced docks for new dropped launchers
if (onlyLaunchersInDroppedList(urls)) {
urls.forEach(function (item) {
addLauncher(item);
});
launchers.addDroppedLaunchers(urls);
return;
}
//! if the list does not contain only launchers then just open the corresponding
//! urls with the relevant app
if (!hoveredItem) {
return;
}
@ -1060,20 +1063,6 @@ Item {
// as you probably don't expect some of your files to open in the app and others to spawn launchers.
tasksModel.requestOpenUrls(hoveredItem.modelIndex(), urlsList);
}
onUrlsDropped: {
//! inform synced docks for new dropped launchers
if (latteView && !launchers.inUniqueGroup() && onlyLaunchersInDroppedList(urls)) {
latteView.layoutsManager.launchersSignals.urlsDropped(root.viewLayoutName,
launchers.group,
urls);
return;
}
//! if the list does not contain only launchers then just open the corresponding
//! urls with the relevant app
urlsDroppedOnArea(urls);
}
}
/* Rectangle {
@ -1368,22 +1357,6 @@ Item {
/////////
//// functions
function addInternalSeparatorAtPos(pos) {
var separatorName = launchers.freeAvailableSeparatorName();
if (separatorName !== "") {
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(root.viewLayoutName,
launchers.group,
separatorName);
} else {
tasksModel.requestAddLauncher(separatorName);
}
}
}
function activateTaskAtIndex(index) {
// This is called with Meta+number shortcuts by plasmashell when Tasks are in a plasma panel.
shortcuts.sglActivateEntryAtIndex(index);
@ -1430,86 +1403,6 @@ Item {
return plasmoid.configuration.launchers59;
}
//! BEGIN ::: external launchers signals in order to update the tasks model
function extSignalAddLauncher(group, launcher) {
if (group === launchers.group) {
tasksModel.requestAddLauncher(launcher);
launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function extSignalRemoveLauncher(group, launcher) {
if (group === launchers.group) {
launchers.launcherInRemoving(launcher)
tasksModel.requestRemoveLauncher(launcher);
launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function extSignalAddLauncherToActivity(group, launcher, activity) {
if (group === launchers.group) {
if (activity !== activityInfo.currentActivity && _launchers.isOnAllActivities(launcher)) {
launchers.launcherInRemoving(launcher);
}
tasksModel.requestAddLauncherToActivity(launcher, activity);
launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function extSignalRemoveLauncherFromActivity(group, launcher, activity) {
if (group === launchers.group) {
if ( activity === activityInfo.currentActivity) {
launchers.launcherInRemoving(launcher)
}
tasksModel.requestRemoveLauncherFromActivity(launcher, activity);
launchers.launcherChanged(launcher);
tasksModel.syncLaunchers();
}
}
function extSignalUrlsDropped(group, urls) {
if (group === launchers.group) {
mouseHandler.urlsDroppedOnArea(urls);
}
}
function extSignalMoveTask(group, from, to) {
if (group === launchers.group && !root.dragSource) {
tasksModel.move(from, to);
tasksModel.syncLaunchers();
}
}
function extSignalValidateLaunchersOrder(group, orderedLaunchers) {
if (group === launchers.group && !root.dragSource) {
launchers.validateOrder(orderedLaunchers);
}
}
//! END ::: external launchers signals in order to update the tasks model
//! it is used to add the fake desktop file which represents
//! the separator (fake launcher)
function addSeparator(pos){
var separatorName = launchers.freeAvailableSeparatorName();
if (separatorName !== "") {
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(launchers.group, separatorName);
} else {
tasksModel.requestAddLauncher(separatorName);
}
}
}
function previewContainsMouse() {
return windowsPreviewDlg.containsMouse;
}
@ -1543,23 +1436,6 @@ Item {
return false;
}
function addLauncher(url) {
//workaround to protect in case the launcher contains the iconData
var pos = url.indexOf("?iconData=");
if (pos>0) {
url = url.substring( 0, url.indexOf("?iconData=" ) );
}
var path = url;
var filename = path.split("/").pop();
tasksExtendedManager.addToBeAddedLauncher(filename);
tasksModel.requestAddLauncher(url);
launchers.launcherChanged(url);
tasksModel.syncLaunchers();
}
function resetDragSource() {
dragSource.z = 0;
dragSource = null;

@ -210,9 +210,9 @@ Item {
if (droppingSeparator) {
droppingSeparator = false;
if (hoveredItem && hoveredItem.itemIndex >=0){
root.addInternalSeparatorAtPos(hoveredItem.itemIndex);
launchers.addInternalSeparatorAtPos(hoveredItem.itemIndex);
} else {
root.addInternalSeparatorAtPos(0);
launchers.addInternalSeparatorAtPos(0);
}
return;
}

Loading…
Cancel
Save