File indexing completed on 2024-04-28 16:49:22

0001 /*
0002 *  Copyright 2017  Smith AR <audoban@openmailbox.org>
0003 *                  Michail Vourlakos <mvourlakos@gmail.com>
0004 *
0005 *  This file is part of Latte-Dock
0006 *
0007 *  Latte-Dock is free software; you can redistribute it and/or
0008 *  modify it under the terms of the GNU General Public License as
0009 *  published by the Free Software Foundation; either version 2 of
0010 *  the License, or (at your option) any later version.
0011 *
0012 *  Latte-Dock is distributed in the hope that it will be useful,
0013 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 *  GNU General Public License for more details.
0016 *
0017 *  You should have received a copy of the GNU General Public License
0018 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #ifndef LAUNCHERSSIGNALS_H
0022 #define LAUNCHERSSIGNALS_H
0023 
0024 // local
0025 #include "../liblatte2/types.h"
0026 
0027 // Qt
0028 #include <QObject>
0029 
0030 namespace Plasma {
0031 class Applet;
0032 }
0033 
0034 namespace Latte {
0035 namespace Layouts {
0036 class Manager;
0037 }
0038 }
0039 
0040 namespace Latte {
0041 namespace Layouts {
0042 
0043 //! in order to support property the launcher groups Layout and Global
0044 //! the latte plasmoids must communicate between them with signals when
0045 //! there are changes in their models. This way we are trying to avoid
0046 //! crashes that occur by setting the launcherList of the tasksModel so
0047 //! often. The plasma devs of libtaskmanager have designed the launchers
0048 //! model to be initialized only once during startup
0049 class LaunchersSignals : public QObject
0050 {
0051     Q_OBJECT
0052 
0053 public:
0054     LaunchersSignals(QObject *parent);
0055     ~LaunchersSignals() override;
0056 
0057 public slots:
0058     Q_INVOKABLE void addLauncher(QString layoutName, int launcherGroup, QString launcher);
0059     Q_INVOKABLE void removeLauncher(QString layoutName, int launcherGroup, QString launcher);
0060     Q_INVOKABLE void addLauncherToActivity(QString layoutName, int launcherGroup, QString launcher, QString activity);
0061     Q_INVOKABLE void removeLauncherFromActivity(QString layoutName, int launcherGroup, QString launcher, QString activity);
0062     Q_INVOKABLE void urlsDropped(QString layoutName, int launcherGroup, QStringList urls);
0063     //!Deprecated because it could create crashes, validateLaunchersOrder provides a better approach
0064     Q_INVOKABLE void moveTask(QString layoutName, int senderId, int launcherGroup, int from, int to);
0065     Q_INVOKABLE void validateLaunchersOrder(QString layoutName, int senderId, int launcherGroup, QStringList launchers);
0066 
0067 private:
0068     QList<Plasma::Applet *> lattePlasmoids(QString layoutName);
0069 
0070 private:
0071     Layouts::Manager *m_manager{nullptr};
0072 };
0073 
0074 }
0075 }
0076 
0077 #endif