Libplasma

pluginloader.h
1/*
2 SPDX-FileCopyrightText: 2010 Ryan Rix <ry@n.rix.si>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef PLUGIN_LOADER_H
8#define PLUGIN_LOADER_H
9
10#include <plasma/plasma_export.h>
11
12#include <QVariant>
13
14class KPluginMetaData;
15namespace Plasma
16{
17class Applet;
18class Containment;
20
21// TODO:
22// * add loadWallpaper
23// * add KPluginInfo listing support for Containments (already loaded via the applet loading code)
24
25/**
26 * @class PluginLoader plasma/pluginloader.h <Plasma/PluginLoader>
27 *
28 * This is an abstract base class which defines an interface to which Plasma's
29 * Applet Loading logic can communicate with a parent application. The plugin loader
30 * must be set before any plugins are loaded, otherwise (for safety reasons), the
31 * default PluginLoader implementation will be used. The reimplemented version should
32 * not do more than simply returning a loaded plugin. It should not init() it, and it should not
33 * hang on to it. The associated methods will be called only when a component of Plasma
34 * needs to load a _new_ plugin.
35 *
36 * @author Ryan Rix <ry@n.rix.si>
37 * @since 4.6
38 **/
39class PLASMA_EXPORT PluginLoader
40{
41public:
42 /**
43 * Load an Applet plugin.
44 *
45 * @param name the plugin name, as returned by KPluginInfo::pluginName()
46 * @param appletId unique ID to assign the applet, or zero to have one
47 * assigned automatically.
48 * @param args to send the applet extra arguments
49 * @return a pointer to the loaded applet, or 0 on load failure
50 **/
51 Applet *loadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList());
52
53 /**
54 * Load a ContainmentActions plugin.
55 *
56 * Returns a pointer to the containmentactions if successful.
57 * The caller takes responsibility for the containmentactions, including
58 * deleting it when no longer needed.
59 *
60 * @param parent the parent containment. @since 4.6 null is allowed.
61 * @param name the plugin name, as returned by KPluginInfo::pluginName()
62 * @param args to send the containmentactions extra arguments
63 * @return a ContainmentActions object
64 **/
65 ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args = QVariantList());
66
67 /**
68 * Returns a list of all known applets.
69 * This may skip applets based on security settings and ExcludeCategories in the application's config.
70 *
71 * @param category Only applets matching this category will be returned.
72 * If "Misc" is passed in, then applets without a
73 * Categories= entry are also returned.
74 * If an empty string is passed in, all applets are
75 * returned.
76 * @return list of applets
77 *
78 * @since 5.28
79 **/
81
82 /**
83 * Returns a list of all known applets associated with a certain mimetype.
84 *
85 * @return list of applets
86 * @since 5.36
87 **/
89
90 /**
91 * Returns a list of all known applets associated with a certain URL.
92 *
93 * @return list of applets
94 * @since 5.36
95 **/
97
98 /**
99 * Returns a list of all known containments.
100 *
101 * @param filter An optional predicate that can be used for filtering.
102 *
103 * @return list of containments
104 */
105 static QList<KPluginMetaData> listContainmentsMetaData(std::function<bool(const KPluginMetaData &)> filter = {});
106
107 /**
108 * Returns a list of containments of the specified type.
109 *
110 * @param type The target containment type
111 *
112 * @return list of containments
113 */
115
116 /**
117 * Returns a list of all known ContainmentActions.
118 *
119 * @param parentApp the application to filter ContainmentActions on. Uses the
120 * X-KDE-ParentApp entry (if any) in the plugin metadata.
121 * The default value of QString() will result in a
122 * list of all ContainmentActions.
123 * @return list of ContainmentActions
124 * @since 5.77
125 **/
127
128 /**
129 * Return the active plugin loader
130 **/
131 static PluginLoader *self();
132
133 PluginLoader() = default;
134 virtual ~PluginLoader() = default;
135
136private:
137 void *d;
138};
139
140}
141
142Q_DECLARE_METATYPE(Plasma::PluginLoader *)
143
144#endif
The base Applet class.
Definition applet.h:64
The base ContainmentActions class.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
This is an abstract base class which defines an interface to which Plasma's Applet Loading logic can ...
QList< KPluginMetaData > listAppletMetaDataForUrl(const QUrl &url)
Returns a list of all known applets associated with a certain URL.
static QList< KPluginMetaData > listContainmentsMetaDataOfType(const QString &type)
Returns a list of containments of the specified type.
static QList< KPluginMetaData > listContainmentsMetaData(std::function< bool(const KPluginMetaData &)> filter={})
Returns a list of all known containments.
ContainmentActions * loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args=QVariantList())
Load a ContainmentActions plugin.
Applet * loadApplet(const QString &name, uint appletId=0, const QVariantList &args=QVariantList())
Load an Applet plugin.
QList< KPluginMetaData > listContainmentActionsMetaData(const QString &parentApp)
Returns a list of all known ContainmentActions.
QList< KPluginMetaData > listAppletMetaData(const QString &category)
Returns a list of all known applets.
QList< KPluginMetaData > listAppletMetaDataForMimeType(const QString &mimetype)
Returns a list of all known applets associated with a certain mimetype.
static PluginLoader * self()
Return the active plugin loader.
Namespace for everything in libplasma.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:23 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.