KPluginInfo

Search for usage in LXR

#include <KPluginInfo>

Public Types

typedef QList< KPluginInfoList
 

Public Member Functions

 KPluginInfo (const QString &filename)
 
 KPluginInfo (const KService::Ptr service)
 
 KPluginInfo (const QVariantList &args, const QString &libraryPath=QString())
 
 KPluginInfo (const KPluginMetaData &md)
 
 KPluginInfo ()
 
 KPluginInfo (const KPluginInfo &copy)
 
QString author () const
 
QString category () const
 
QString comment () const
 
KConfigGroup config () const
 
void defaults ()
 
QString email () const
 
QString entryPath () const
 
QStringList formFactors () const
 
QString icon () const
 
bool isHidden () const
 
bool isPluginEnabled () const
 
bool isPluginEnabledByDefault () const
 
bool isValid () const
 
QList< KService::PtrkcmServices () const
 
QString libraryPath () const
 
QString license () const
 
void load (const KConfigGroup &config=KConfigGroup())
 
QString name () const
 
bool operator!= (const KPluginInfo &rhs) const
 
bool operator< (const KPluginInfo &rhs) const
 
KPluginInfooperator= (const KPluginInfo &rhs)
 
bool operator== (const KPluginInfo &rhs) const
 
bool operator> (const KPluginInfo &rhs) const
 
QString pluginName () const
 
QVariantMap properties () const
 
QVariant property (const QString &key) const
 
void save (KConfigGroup config=KConfigGroup())
 
KService::Ptr service () const
 
QStringList serviceTypes () const
 
void setConfig (const KConfigGroup &config)
 
void setPluginEnabled (bool enabled)
 
KPluginMetaData toMetaData () const
 
QString version () const
 
QString website () const
 

Static Public Member Functions

static KPluginInfo::List fromFiles (const QStringList &files, const KConfigGroup &config=KConfigGroup())
 
static KPluginInfo::List fromKPartsInstanceName (const QString &componentName, const KConfigGroup &config=KConfigGroup())
 
static KPluginInfo fromMetaData (const KPluginMetaData &meta)
 
static KPluginInfo::List fromMetaData (const QVector< KPluginMetaData > &list)
 
static KPluginInfo::List fromServices (const KService::List &services, const KConfigGroup &config=KConfigGroup())
 
static KPluginMetaData toMetaData (const KPluginInfo &info)
 
static QVector< KPluginMetaDatatoMetaData (const KPluginInfo::List &list)
 

Friends

KSERVICE_EXPORT uint qHash (const KPluginInfo &)
 

Detailed Description

Information about a plugin.

This holds all the information about a plugin there is. It's used for the user to decide whether he wants to use this plugin or not.

Author
Matthias Kretz kretz[email protected]@kde[email protected].org

Definition at line 32 of file kplugininfo.h.

Member Typedef Documentation

A list of KPluginInfo objects.

Definition at line 38 of file kplugininfo.h.

Constructor & Destructor Documentation

KPluginInfo::KPluginInfo ( const QString filename)
explicit

Read plugin info from filename.

The file should be of the following form:

[Desktop Entry]
Icon=mypluginicon
Type=Service
X-KDE-ServiceTypes=KPluginInfo

Name=User Visible Name
Comment=Description of what the plugin does

X-KDE-PluginInfo-Author=Author's Name
[email protected]
X-KDE-PluginInfo-Name=internalname
X-KDE-PluginInfo-Version=1.1
X-KDE-PluginInfo-Website=http://www.plugin.org/
X-KDE-PluginInfo-Category=playlist
X-KDE-PluginInfo-Depends=plugin1,plugin3
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

The Name and Comment fields must always be present.

The "X-KDE-PluginInfo" keys you may add further entries which will be available using property(). The Website,Category,Require keys are optional. For EnabledByDefault look at isPluginEnabledByDefault.

Parameters
filenameThe filename of the .desktop file.
resourceIf filename is relative, you need to specify a resource type (e.g. "service", "apps"... KStandardDirs). Otherwise, resource isn't used.

Definition at line 263 of file kplugininfo.cpp.

KPluginInfo::KPluginInfo ( const KService::Ptr  service)
explicit

Read plugin info from a KService object.

The .desktop file should look like this:

[Desktop Entry]
Icon=mypluginicon
Type=Service
X-KDE-ServiceTypes=KPluginInfo

X-KDE-PluginInfo-Author=Author's Name
[email protected]
X-KDE-PluginInfo-Name=internalname
X-KDE-PluginInfo-Version=1.1
X-KDE-PluginInfo-Website=http://www.plugin.org/
X-KDE-PluginInfo-Category=playlist
X-KDE-PluginInfo-Depends=plugin1,plugin3
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

Name=User Visible Name
Comment=Description of what the plugin does

In the first three entries the Icon entry is optional.

Deprecated:
since 5.0, use (Q|K)PluginLoader instead and build the metadata into the plugin using K_PLUGIN_CLASS_WITH_JSON( ..., "mypluginmetadata.json")

Definition at line 311 of file kplugininfo.cpp.

KPluginInfo::KPluginInfo ( const QVariantList &  args,
const QString libraryPath = QString() 
)
explicit

Read plugin info from arguments passed to the plugin.

These arguments should contain the plugin's metadata (as read from QPluginLoader::metaData(). This constructor uses the metadata read from the QVariantList. It reads the first QVariantMap it finds in a field called "MetaData".

Use (Q|K)PluginLoader and build the metadata into the plugin using K_PLUGIN_CLASS_WITH_JSON( ..., "mypluginmetadata.json")

You can use the "desktoptojson tool to generate a .json file from your .desktop file. The .json file should look like this:

 {
     "Comment": "Date and time by timezone",
     "Icon": "preferences-system-time",
     "Name": "Date and Time",
     "Type": "Service",
     "X-KDE-Library": "plasma_engine_time",
     "X-KDE-PluginInfo-Author": "Aaron Seigo",
     "X-KDE-PluginInfo-Category": "Date and Time",
     "X-KDE-PluginInfo-Depends": [
     ],
     "X-KDE-PluginInfo-Email": "[email protected]",
     "X-KDE-PluginInfo-EnabledByDefault": true,
     "X-KDE-PluginInfo-License": "LGPL",
     "X-KDE-PluginInfo-Name": "time",
     "X-KDE-PluginInfo-Version": "1.0",
     "X-KDE-PluginInfo-Website": "http://plasma.kde.org/",
     "X-KDE-ServiceTypes": [
         "Plasma/DataEngine"
     ],
     "X-KDE-FormFactors": [
         "tablet",
         "handset"
     ]
 }
Parameters
argsQVariantList with arguments, should contain a QVariantMap, keyed "MetaData" as provided by QPluginLoader::metaData()
libraryPathThe path to the plugin file on disk
See also
K_PLUGIN_CLASS_WITH_JSON()
KPluginFactory::factory()
Since
5.0

Definition at line 286 of file kplugininfo.cpp.

KPluginInfo::KPluginInfo ( const KPluginMetaData md)
explicit

Read plugin info from a KPluginMetaData object.

Parameters
mdThe KPluginMetaData to read the information from
See also
K_PLUGIN_CLASS_WITH_JSON()
KPluginLoader
Since
5.5

Definition at line 254 of file kplugininfo.cpp.

KPluginInfo::KPluginInfo ( )

Creates an invalid plugin.

See also
isValid

Definition at line 368 of file kplugininfo.cpp.

KPluginInfo::KPluginInfo ( const KPluginInfo copy)

Creates a KPluginInfo object that shares the data with copy.

Definition at line 378 of file kplugininfo.cpp.

Member Function Documentation

QString KPluginInfo::author ( ) const
Returns
The author of this plugin.

Definition at line 518 of file kplugininfo.cpp.

QString KPluginInfo::category ( ) const
Returns
The category of this plugin (e.g. playlist/skin).

Definition at line 532 of file kplugininfo.cpp.

QString KPluginInfo::comment ( ) const
Returns
A comment describing the plugin.

Definition at line 500 of file kplugininfo.cpp.

KConfigGroup KPluginInfo::config ( ) const
Returns
If the KPluginInfo object has a KConfig object set return it, else returns an invalid KConfigGroup.

Definition at line 621 of file kplugininfo.cpp.

void KPluginInfo::defaults ( )

Restore defaults (enabled or not).

Definition at line 737 of file kplugininfo.cpp.

QString KPluginInfo::email ( ) const
Returns
The email address of the author.

Definition at line 525 of file kplugininfo.cpp.

QString KPluginInfo::entryPath ( ) const
Returns
The file containing the information about the plugin.

Definition at line 512 of file kplugininfo.cpp.

QStringList KPluginInfo::formFactors ( ) const
Returns
A list of FormFactors this plugin offers, corresponds to the "X-KDE-FormFactors" value in a .desktop service file, or to the "FormFactors" value in the "KPlugin" block of the json metadata. Formfactor values are freestyle, common values are "desktop", "handset", "tablet", "mediacenter". Values are comma-separated.
Since
5.14

Definition at line 538 of file kplugininfo.cpp.

QList< KPluginInfo > KPluginInfo::fromFiles ( const QStringList files,
const KConfigGroup config = KConfigGroup() 
)
static
Returns
A list of KPluginInfo objects constructed from a list of filenames. If you make a lookup using, for example, KStandardDirs::findAllResources() you pass the list of files to this function.
Parameters
filesThe list of files to construct the list of KPluginInfo objects from
configThe config group where to save/load whether the plugin is enabled/disabled

Definition at line 440 of file kplugininfo.cpp.

QList< KPluginInfo > KPluginInfo::fromKPartsInstanceName ( const QString componentName,
const KConfigGroup config = KConfigGroup() 
)
static
Returns
A list of KPluginInfo objects for the KParts plugins of a component.
Parameters
componentNameUse the component name to look up all KParts plugins for it.
configThe config group where to save/load whether the plugin is enabled/disabled
Deprecated:
since 5.81, removed for lack of usage, KParts loads the plugins all by itself

Definition at line 452 of file kplugininfo.cpp.

KPluginInfo KPluginInfo::fromMetaData ( const KPluginMetaData meta)
static
Parameters
metathe KPluginMetaData to convert
Returns
a KPluginInfo object with equivalent meta data.
Since
5.3

Definition at line 748 of file kplugininfo.cpp.

KPluginInfo::List KPluginInfo::fromMetaData ( const QVector< KPluginMetaData > &  list)
static
Parameters
listthe list of KPluginMetaData objects to convert
Returns
a list of KPluginInfo objects with equivalent meta data.
Since
5.3

Definition at line 764 of file kplugininfo.cpp.

QList< KPluginInfo > KPluginInfo::fromServices ( const KService::List services,
const KConfigGroup config = KConfigGroup() 
)
static
Returns
A list of KPluginInfo objects constructed from a list of KService objects. If you get a trader offer of the plugins you want to use you can just pass them to this function.
Parameters
servicesThe list of services to construct the list of KPluginInfo objects from
configThe config group where to save/load whether the plugin is enabled/disabled
Deprecated:
since 5.0, use (Q|K)PluginLoader instead and build the metadata into the plugins using K_PLUGIN_CLASS_WITH_JSON( ..., "mypluginmetadata.json")

Definition at line 426 of file kplugininfo.cpp.

QString KPluginInfo::icon ( ) const
Returns
The iconname for this plugin

Definition at line 506 of file kplugininfo.cpp.

bool KPluginInfo::isHidden ( ) const
Returns
Whether the plugin should be hidden.

Definition at line 467 of file kplugininfo.cpp.

bool KPluginInfo::isPluginEnabled ( ) const
Returns
Whether the plugin is currently loaded.
See also
setPluginEnabled()
load()

Definition at line 480 of file kplugininfo.cpp.

bool KPluginInfo::isPluginEnabledByDefault ( ) const
Returns
The default value whether the plugin is enabled or not. Defaults to the value set in the desktop file, or if that isn't set to false.

Definition at line 487 of file kplugininfo.cpp.

bool KPluginInfo::isValid ( ) const

Returns whether the object is valid.

Treat invalid KPluginInfo objects like you would treat a null pointer.

Definition at line 373 of file kplugininfo.cpp.

QList< KService::Ptr > KPluginInfo::kcmServices ( ) const
Returns
A list of Service pointers if the plugin installs one or more KCModule

Definition at line 601 of file kplugininfo.cpp.

QString KPluginInfo::libraryPath ( ) const
Returns
The absolute path of the plugin on disk. This can be used to load the plugin from, using KPluginLoader or QPluginLoader
Since
5.0

Definition at line 550 of file kplugininfo.cpp.

QString KPluginInfo::license ( ) const
Returns
The license keyword of this plugin.

Definition at line 568 of file kplugininfo.cpp.

void KPluginInfo::load ( const KConfigGroup config = KConfigGroup())

Load the state of the plugin - enabled or not.

Parameters
configThe KConfigGroup holding the information whether plugin is enabled.

Definition at line 722 of file kplugininfo.cpp.

QString KPluginInfo::name ( ) const
Returns
The user visible name of the plugin.

Definition at line 494 of file kplugininfo.cpp.

bool KPluginInfo::operator!= ( const KPluginInfo rhs) const

Compares two objects whether they don't share the same data.

Definition at line 394 of file kplugininfo.cpp.

bool KPluginInfo::operator< ( const KPluginInfo rhs) const

Less than relation comparing the categories and if they are the same using the names.

Definition at line 399 of file kplugininfo.cpp.

KPluginInfo & KPluginInfo::operator= ( const KPluginInfo rhs)

Copies the KPluginInfo object to share the data with copy.

Definition at line 383 of file kplugininfo.cpp.

bool KPluginInfo::operator== ( const KPluginInfo rhs) const

Compares two objects whether they share the same data.

Definition at line 389 of file kplugininfo.cpp.

bool KPluginInfo::operator> ( const KPluginInfo rhs) const

Greater than relation comparing the categories and if they are the same using the names.

Definition at line 410 of file kplugininfo.cpp.

QString KPluginInfo::pluginName ( ) const
Returns
The internal name of the plugin (for KParts Plugins this is the same name as set in the .rc file).

Definition at line 544 of file kplugininfo.cpp.

QVariantMap KPluginInfo::properties ( ) const
Returns
All properties of this object. This can be used to read custom values.
Since
5.3
See also
KPluginInfo::property()

Definition at line 702 of file kplugininfo.cpp.

QVariant KPluginInfo::property ( const QString key) const
Returns
The value associated to the key. You can use it if you want to read custom values. To do this you need to define your own servicetype and add it to the ServiceTypes keys.

Definition at line 627 of file kplugininfo.cpp.

void KPluginInfo::save ( KConfigGroup  config = KConfigGroup())

Save state of the plugin - enabled or not.

Parameters
configThe KConfigGroup holding the information whether plugin is enabled.

Definition at line 707 of file kplugininfo.cpp.

KService::Ptr KPluginInfo::service ( ) const
Returns
The KService object for this plugin. You might need it if you want to read custom values. To do this you need to define your own servicetype and add it to the ServiceTypes keys. Then you can use the KService::property() method to read your keys.
See also
property()
Deprecated:
since 5.70, use KPluginMetaData and KPluginLoader(info.libraryPath())

Definition at line 594 of file kplugininfo.cpp.

QStringList KPluginInfo::serviceTypes ( ) const
Returns
A list of ServiceTypes this plugin offers
Since
5.0

Definition at line 586 of file kplugininfo.cpp.

void KPluginInfo::setConfig ( const KConfigGroup config)

Set the KConfigGroup to use for load()ing and save()ing the configuration.

This will be overridden by the KConfigGroup passed to save() or load() (if one is passed).

Definition at line 615 of file kplugininfo.cpp.

void KPluginInfo::setPluginEnabled ( bool  enabled)

Set whether the plugin is currently loaded.

See also
isPluginEnabled()
save()

Definition at line 473 of file kplugininfo.cpp.

KPluginMetaData KPluginInfo::toMetaData ( ) const
Returns
a KPluginMetaData object with equivalent meta data.
Since
5.3

Definition at line 753 of file kplugininfo.cpp.

KPluginMetaData KPluginInfo::toMetaData ( const KPluginInfo info)
static
Parameters
infothe KPluginInfo object to convert
Returns
a KPluginMetaData object with equivalent meta data.
Since
5.3

Definition at line 759 of file kplugininfo.cpp.

QVector< KPluginMetaData > KPluginInfo::toMetaData ( const KPluginInfo::List list)
static
Parameters
listthe list of KPluginInfo objects to convert
Returns
a list of KPluginMetaData objects with equivalent meta data.
Since
5.3

Definition at line 774 of file kplugininfo.cpp.

QString KPluginInfo::version ( ) const
Returns
The version of the plugin.

Definition at line 556 of file kplugininfo.cpp.

QString KPluginInfo::website ( ) const
Returns
The website of the plugin/author.

Definition at line 562 of file kplugininfo.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed May 12 2021 22:47:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.