Add categories to plasmoids. The actual category names are subject

to change at some point - a definitive list on techbase will probably
be assembled.


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=686945
This commit is contained in:
Alex Merry 2007-07-12 13:24:35 +00:00
parent 1e5cdae3ea
commit 71c21577d3
3 changed files with 70 additions and 0 deletions

View File

@ -161,6 +161,32 @@ QString Applet::name() const
return d->appletDescription->name();
}
QString Applet::category() const
{
return d->appletDescription->property("X-PlasmoidCategory").toString();
}
QString Applet::category(const KPluginInfo* applet)
{
return applet->property("X-PlasmoidCategory").toString();
}
QString Applet::category(const QString& appletName)
{
if (appletName.isEmpty()) {
return QString();
}
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
if (offers.isEmpty()) {
return QString();
}
return offers.first()->property("X-PlasmoidCategory").toString();
}
bool Applet::immutable() const
{
return d->immutable;
@ -306,6 +332,21 @@ KPluginInfo::List Applet::knownApplets()
return KPluginInfo::fromServices(offers);
}
QStringList Applet::knownCategories()
{
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", "exist [X-PlasmoidCategory]");
QStringList categories;
foreach (KService::Ptr applet, offers) {
QString appletCategory = applet->property("X-PlasmoidCategory").toString();
if (!appletCategory.isEmpty()) {
if (!categories.contains(appletCategory)) {
categories << appletCategory;
}
}
}
return categories;
}
Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QStringList& args)
{
if (appletName.isEmpty()) {

View File

@ -151,6 +151,12 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem
**/
static KPluginInfo::List knownApplets();
/**
* Returns a list of all the categories used by
* installed applets.
*/
static QStringList knownCategories();
/**
* @return true if this plasmoid provides a GUI configuration
**/
@ -213,6 +219,26 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem
**/
QString name() const;
/**
* Returns the category the applet is in, as specified in the
* .desktop file.
*/
QString category() const;
/**
* Get the category of the given applet
*
* @param a KPluginInfo object for the applet
*/
static QString category(const KPluginInfo* applet);
/**
* Get the category of the given applet
*
* @param the name of the applet
*/
static QString category(const QString& appletName);
/**
* @return true if this applet is immutable
**/

View File

@ -19,3 +19,6 @@ Comment[pt_BR]='Applet' do Plasma
Comment[sv]=Plasma-miniprogram
Comment[zh_TW]=Plasma
[PropertyDef::X-PlasmoidCategory]
Type=QString