File indexing completed on 2024-04-21 05:30:51

0001 /*
0002     SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef SYNCEDLAUNCHERS_H
0007 #define SYNCEDLAUNCHERS_H
0008 
0009 // local
0010 #include <coretypes.h>
0011 
0012 // Qt
0013 #include <QList>
0014 #include <QObject>
0015 #include <QQuickItem>
0016 
0017 namespace Plasma {
0018 class Applet;
0019 }
0020 
0021 namespace Latte {
0022 namespace Layouts {
0023 class Manager;
0024 }
0025 }
0026 
0027 namespace Latte {
0028 namespace Layouts {
0029 
0030 //! in order to support property the launcher groups Layout and Global
0031 //! the latte plasmoids must communicate between them with signals when
0032 //! there are changes in their models. This way we are trying to avoid
0033 //! crashes that occur by setting the launcherList of the tasksModel so
0034 //! often. The plasma devs of libtaskmanager have designed the launchers
0035 //! model to be initialized only once during startup
0036 class SyncedLaunchers : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     SyncedLaunchers(QObject *parent);
0042     ~SyncedLaunchers() override;
0043 
0044 public slots:
0045     Q_INVOKABLE void addAbilityClient(QQuickItem *client);
0046     Q_INVOKABLE void removeAbilityClient(QQuickItem *client);
0047 
0048     Q_INVOKABLE void addLauncher(QString layoutName, uint senderId, int launcherGroup, QString launcherGroupId, QString launcher);
0049     Q_INVOKABLE void removeLauncher(QString layoutName, uint senderId, int launcherGroup, QString launcherGroupId, QString launcher);
0050     Q_INVOKABLE void addLauncherToActivity(QString layoutName, uint senderId, int launcherGroup,QString launcherGroupId, QString launcher, QString activity);
0051     Q_INVOKABLE void removeLauncherFromActivity(QString layoutName, uint senderId, int launcherGroup, QString launcherGroupId, QString launcher, QString activity);
0052     Q_INVOKABLE void urlsDropped(QString layoutName, uint senderId, int launcherGroup, QString launcherGroupId, QStringList urls);
0053     Q_INVOKABLE void validateLaunchersOrder(QString layoutName, uint senderId, int launcherGroup, QString launcherGroupId, QStringList launchers);
0054 
0055 private:
0056     QList<QQuickItem *> clients(QString layoutName, QString groupId);
0057     QList<QQuickItem *> clients(QString layoutName, uint senderId, Latte::Types::LaunchersGroup launcherGroup, QString launcherGroupId);
0058     QQuickItem *client(const int &id);
0059 
0060 private slots:
0061     void removeClientObject(QObject *obj);
0062 
0063 private:
0064     Layouts::Manager *m_manager{nullptr};
0065 
0066     QList<QQuickItem *> m_clients;
0067 };
0068 
0069 }
0070 }
0071 
0072 #endif