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:
parent
1e5cdae3ea
commit
71c21577d3
41
applet.cpp
41
applet.cpp
@ -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()) {
|
||||
|
26
applet.h
26
applet.h
@ -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
|
||||
**/
|
||||
|
@ -19,3 +19,6 @@ Comment[pt_BR]='Applet' do Plasma
|
||||
Comment[sv]=Plasma-miniprogram
|
||||
Comment[zh_TW]=Plasma 小程式
|
||||
|
||||
[PropertyDef::X-PlasmoidCategory]
|
||||
Type=QString
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user