KPluginInfo

Search for usage in LXR

#include <KPluginInfo>

Public Types

typedef QList< KPluginInfoList
 

Public Member Functions

 KPluginInfo ()
 
 KPluginInfo (const KPluginInfo &copy)
 
 KPluginInfo (const KPluginMetaData &md)
 
 KPluginInfo (const KService::Ptr service)
 
 KPluginInfo (const QString &filename)
 
 KPluginInfo (const QVariantList &args, const QString &libraryPath=QString())
 
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)
 

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.nosp@m.@kde.nosp@m..org
Deprecated:
since 5.88, use QPluginLoader or the KPluginFactory::loadFactory/KPluginFactory::instantiatePlugins methods instead to create objects from the plugins. For accessing the metadata, use KPluginMetaData instead. To embed json metadata in your plugin, use K_PLUGIN_CLASS_WITH_JSON(MyClass, "mypluginmetadata.json")

The reading of the enabled state can be done using the KPluginMetaData::isEnabled method. Writing the config should be done manually. Consider using KPluginWidget for the configuration of plugins in the UI.

Definition at line 42 of file kplugininfo.h.

Member Typedef Documentation

◆ List

A list of KPluginInfo objects.

Definition at line 48 of file kplugininfo.h.

Constructor & Destructor Documentation

◆ KPluginInfo() [1/6]

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.
Deprecated:
Since 5.90, see class API docs

Definition at line 267 of file kplugininfo.cpp.

◆ KPluginInfo() [2/6]

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.90, see class API docs

Definition at line 319 of file kplugininfo.cpp.

◆ KPluginInfo() [3/6]

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
Deprecated:
Since 5.90, see class API docs

Definition at line 294 of file kplugininfo.cpp.

◆ KPluginInfo() [4/6]

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
Deprecated:
Since 5.90, see class API docs

Definition at line 258 of file kplugininfo.cpp.

◆ KPluginInfo() [5/6]

KPluginInfo::KPluginInfo ( )

Creates an invalid plugin.

See also
isValid

Definition at line 378 of file kplugininfo.cpp.

◆ KPluginInfo() [6/6]

KPluginInfo::KPluginInfo ( const KPluginInfo copy)

Creates a KPluginInfo object that shares the data with copy.

Definition at line 388 of file kplugininfo.cpp.

Member Function Documentation

◆ author()

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

Definition at line 531 of file kplugininfo.cpp.

◆ category()

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

Definition at line 545 of file kplugininfo.cpp.

◆ comment()

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

Definition at line 513 of file kplugininfo.cpp.

◆ config()

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

Definition at line 630 of file kplugininfo.cpp.

◆ defaults()

void KPluginInfo::defaults ( )

Restore defaults (enabled or not).

Definition at line 747 of file kplugininfo.cpp.

◆ email()

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

Definition at line 538 of file kplugininfo.cpp.

◆ entryPath()

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

Definition at line 525 of file kplugininfo.cpp.

◆ formFactors()

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 551 of file kplugininfo.cpp.

◆ fromFiles()

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 450 of file kplugininfo.cpp.

◆ fromKPartsInstanceName()

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 465 of file kplugininfo.cpp.

◆ fromMetaData() [1/2]

KPluginInfo KPluginInfo::fromMetaData ( const KPluginMetaData meta)
static
Parameters
metathe KPluginMetaData to convert
Returns
a KPluginInfo object with equivalent meta data.
Since
5.3
Deprecated:
Since 5.90, see class API docs

Definition at line 758 of file kplugininfo.cpp.

◆ fromMetaData() [2/2]

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
Deprecated:
Since 5.90, see class API docs

Definition at line 774 of file kplugininfo.cpp.

◆ fromServices()

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.90, see class API docs

Definition at line 436 of file kplugininfo.cpp.

◆ icon()

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

Definition at line 519 of file kplugininfo.cpp.

◆ isHidden()

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

Definition at line 480 of file kplugininfo.cpp.

◆ isPluginEnabled()

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

Definition at line 493 of file kplugininfo.cpp.

◆ isPluginEnabledByDefault()

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 500 of file kplugininfo.cpp.

◆ isValid()

bool KPluginInfo::isValid ( ) const

Returns whether the object is valid.

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

Definition at line 383 of file kplugininfo.cpp.

◆ kcmServices()

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

Definition at line 610 of file kplugininfo.cpp.

◆ libraryPath()

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 563 of file kplugininfo.cpp.

◆ license()

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

Definition at line 581 of file kplugininfo.cpp.

◆ load()

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 732 of file kplugininfo.cpp.

◆ name()

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

Definition at line 507 of file kplugininfo.cpp.

◆ operator!=()

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

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

Definition at line 404 of file kplugininfo.cpp.

◆ operator<()

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 409 of file kplugininfo.cpp.

◆ operator=()

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

Copies the KPluginInfo object to share the data with copy.

Definition at line 393 of file kplugininfo.cpp.

◆ operator==()

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

Compares two objects whether they share the same data.

Definition at line 399 of file kplugininfo.cpp.

◆ operator>()

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 420 of file kplugininfo.cpp.

◆ pluginName()

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 557 of file kplugininfo.cpp.

◆ properties()

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 712 of file kplugininfo.cpp.

◆ property()

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 636 of file kplugininfo.cpp.

◆ save()

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 717 of file kplugininfo.cpp.

◆ service()

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 603 of file kplugininfo.cpp.

◆ serviceTypes()

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

Definition at line 595 of file kplugininfo.cpp.

◆ setConfig()

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 624 of file kplugininfo.cpp.

◆ setPluginEnabled()

void KPluginInfo::setPluginEnabled ( bool  enabled)

Set whether the plugin is currently loaded.

See also
isPluginEnabled()
save()

Definition at line 486 of file kplugininfo.cpp.

◆ toMetaData() [1/3]

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

Definition at line 763 of file kplugininfo.cpp.

◆ toMetaData() [2/3]

KPluginMetaData KPluginInfo::toMetaData ( const KPluginInfo info)
static
Parameters
infothe KPluginInfo object to convert
Returns
a KPluginMetaData object with equivalent meta data.
Since
5.3
Deprecated:
Since 5.90, see class API docs

Definition at line 769 of file kplugininfo.cpp.

◆ toMetaData() [3/3]

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
Deprecated:
Since 5.90, see class API docs

Definition at line 784 of file kplugininfo.cpp.

◆ version()

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

Definition at line 569 of file kplugininfo.cpp.

◆ website()

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

Definition at line 575 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-2023 The KDE developers.
Generated on Fri Dec 1 2023 03:52:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.