From 4d4f9e01401ccdc93499c343904da7cf2289a14c Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 24 May 2007 20:51:59 +0000 Subject: [PATCH] convenience method for loading applets via a KPluginInfo svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=668033 --- applet.cpp | 9 +++++++++ applet.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/applet.cpp b/applet.cpp index 7ba38b820..d6fbd603e 100644 --- a/applet.cpp +++ b/applet.cpp @@ -230,6 +230,15 @@ Applet* Applet::loadApplet(const QString& appletName, uint appletId) return applet; } +Applet* Applet::loadApplet(const KPluginInfo* info, uint appletId) +{ + if (!info) { + return 0; + } + + loadApplet(info->pluginName(), appletId); +} + } // Plasma namespace #include "applet.moc" diff --git a/applet.h b/applet.h index e48465f65..75886576a 100644 --- a/applet.h +++ b/applet.h @@ -122,6 +122,18 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItemGroup **/ static Applet* loadApplet(const QString &name, uint appletId = 0); + /** + * Attempts to load an applet, returning a pointer to the applet if + * successful. The caller takes responsibility for the applet, including + * deleting it when no longer needed. + * + * @param info KPluginInfo object for the desired applet + * @param applet unique ID to assign the applet, or zero to have one + * assigned automatically. + * @return a pointer to the loaded applet, or 0 on load failure + **/ + static Applet* loadApplet(const KPluginInfo* info, uint appletId = 0); + Q_SIGNALS: void requestFocus( bool focus );