Plasma-framework

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

KDE's Doxygen guidelines are available online.