File indexing completed on 2024-12-29 05:06:05

0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 
0008 #include <Plasma/Applet>
0009 
0010 // keeps a list of all of instances of Plasma::Applet that are loaded into the containment
0011 // allows for FolioWidgets to find their corresponding Plasma::Applet
0012 class WidgetsManager : public QObject
0013 {
0014     Q_OBJECT
0015 public:
0016     WidgetsManager(QObject *parent = nullptr);
0017 
0018     static WidgetsManager *self();
0019 
0020     Plasma::Applet *getWidget(int id);
0021 
0022     void addWidget(Plasma::Applet *applet);
0023     void removeWidget(Plasma::Applet *applet);
0024 
0025 Q_SIGNALS:
0026     void widgetAdded(Plasma::Applet *applet);
0027     void widgetRemoved(Plasma::Applet *applet);
0028 
0029 private:
0030     QList<Plasma::Applet *> m_widgets;
0031 };