diff --git a/applet.cpp b/applet.cpp index da5cc36b5..a6692b87f 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1584,7 +1584,7 @@ QSet AppletPrivate::knownCategories() { // this is to trick the tranlsation tools into making the correct // strings for translation - QSet categories; + QSet categories = s_customCategories; categories << QString(I18N_NOOP("Accessibility")).toLower() << QString(I18N_NOOP("Application Launchers")).toLower() << QString(I18N_NOOP("Astronomy")).toLower() @@ -1829,6 +1829,16 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly) return categories; } +void Applet::setCustomCategories(const QStringList &categories) +{ + AppletPrivate::s_customCategories = QSet::fromList(categories); +} + +QStringList Applet::customCategories() +{ + return AppletPrivate::s_customCategories.toList(); +} + Applet::Applet(const QString &packagePath, uint appletId, const QVariantList &args) : QGraphicsWidget(0), d(new AppletPrivate(KService::Ptr(new KService(packagePath + "/metadata.desktop")), appletId, this)) @@ -2421,6 +2431,7 @@ uint AppletPrivate::s_maxAppletId = 0; int AppletPrivate::s_maxZValue = 0; int AppletPrivate::s_minZValue = 0; PackageStructure::Ptr AppletPrivate::packageStructure(0); +QSet AppletPrivate::s_customCategories; AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent) : QGraphicsWidget(parent), diff --git a/applet.h b/applet.h index bb209ad0a..cbe2ae662 100644 --- a/applet.h +++ b/applet.h @@ -296,8 +296,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget static KPluginInfo::List listAppletInfoForMimetype(const QString &mimetype); /** - * Returns a list of all the categories used by - * installed applets. + * Returns a list of all the categories used by installed applets. * * @param parentApp the application to filter applets on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. @@ -310,6 +309,20 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget static QStringList listCategories(const QString &parentApp = QString(), bool visibleOnly = true); + /** + * Sets the list of custom categories that are used in addition to the default + * set of categories known to libplasma for Applets. + * @arg categories a list of categories + * @since 4.3 + */ + void setCustomCategories(const QStringList &categories); + + /** + * @return the list of custom categories known to libplasma + * @since 4.3 + */ + QStringList customCategories(); + /** * Attempts to load an apppet from a package * diff --git a/private/applet_p.h b/private/applet_p.h index 457c10b00..11a20a0a1 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -104,6 +104,7 @@ public: static int s_maxZValue; static int s_minZValue; static PackageStructure::Ptr packageStructure; + static QSet s_customCategories; //TODO: examine the usage of memory here; there's a pretty large // number of members at this point.