KDE 4.9 PyKDE API Reference

- KDE's Python API

# KPluginInfo Class Reference

`from PyKDE4.kdecore import *`

## 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@kde.org>

## Methods

| __init__ (self, QString filename, QString resource=0)
| __init__ (self, KSharedPtr<KService> service)
| __init__ (self)
| __init__ (self, KPluginInfo copy)
QString | author (self)
QString | category (self)
QString | comment (self)
KConfigGroup | config (self)
| defaults (self)
QStringList | dependencies (self)
QString | email (self)
QString | entryPath (self)
KAboutLicense | fullLicense (self)
QString | icon (self)
bool | isHidden (self)
bool | isPluginEnabled (self)
bool | isPluginEnabledByDefault (self)
bool | isValid (self)
[KSharedPtr<KService>] | kcmServices (self)
QString | license (self)
| load (self, KConfigGroup config=KConfigGroup())
QString | name (self)
bool | operator != (self, KPluginInfo rhs)
bool | operator < (self, KPluginInfo rhs)
bool | operator == (self, KPluginInfo rhs)
bool | operator > (self, KPluginInfo rhs)
QString | pluginName (self)
QVariant | property (self, QString key)
| save (self, KConfigGroup config=KConfigGroup())
KSharedPtr<KService> | service (self)
| setConfig (self, KConfigGroup config)
| setPluginEnabled (self, bool enabled)
QString | version (self)
QString | website (self)

## Static Methods

[KPluginInfo] | fromFiles (QStringList files, KConfigGroup config=KConfigGroup())
[KPluginInfo] | fromKPartsInstanceName (QString componentName, KConfigGroup config=KConfigGroup())
[KPluginInfo] | fromServices ([KSharedPtr<KService>] services, KConfigGroup config=KConfigGroup())

## Method Documentation

__init__ | ( | self, |
|  | QString | filename,
|  | QString | resource=0
| ) |  |  |

Read plugin info from filename.

The file should be of the following form: <pre> [Desktop Entry] Encoding=UTF-8 Icon=mypluginicon Type=Service ServiceTypes=KPluginInfo

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

X-KDE-PluginInfo-Author=Author's Name X-KDE-PluginInfo-Email=author@foo.bar 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 </pre> 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:

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

__init__ | ( | self, |
|  | KSharedPtr<KService> | service
| ) |  |  |

Read plugin info from a KService object.

The .desktop file should look like this: <pre> [Desktop Entry] Encoding=UTF-8 Icon=mypluginicon Type=Service ServiceTypes=KPluginInfo

X-KDE-PluginInfo-Author=Author's Name X-KDE-PluginInfo-Email=author@foo.bar 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 </pre> In the first three entries the Icon entry is optional.

__init__ | ( |  | self ) |

Creates an invalid plugin.

See also:
  isValid

__init__ | ( | self, |
|  | KPluginInfo | copy
| ) |  |  |

Creates a KPluginInfo object that shares the data with copy.

QString author | ( |  | self ) |

Returns:
  The author of this plugin.

QString category | ( |  | self ) |

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

QString comment | ( |  | self ) |

Returns:
  A comment describing the plugin.

KConfigGroup config | ( |  | self ) |

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

defaults | ( |  | self ) |

Restore defaults (enabled or not).

QStringList dependencies | ( |  | self ) |

Returns:
  A list of plugins required for this plugin to be enabled. Use the pluginName in this list.

QString email | ( |  | self ) |

Returns:
  The email address of the author.

QString entryPath | ( |  | self ) |

Returns:
  The file containing the information about the plugin.

KAboutLicense fullLicense | ( |  | self ) |

Returns:
  The full license object, according to the license keyword. It can be used to present friendlier and more detailed license info to the user, when the license is one of the widespread within KDE. For other licenses, the license object will state not very useful, "custom license" info (this can be identified by KAboutLicense.key() returning KAboutData.License_Custom).

See also:
  KAboutLicense.byKeyword()

Since:
  4.1

QString icon | ( |  | self ) |

Returns:
  The iconname for this plugin

bool isHidden | ( |  | self ) |

Returns:
  Whether the plugin should be hidden.

bool isPluginEnabled | ( |  | self ) |

Returns:
  Whether the plugin is currently loaded.

See also:
  setPluginEnabled()

See also:
  load()

bool isPluginEnabledByDefault | ( |  | self ) |

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.

bool isValid | ( |  | self ) |

Returns whether the object is valid. Treat invalid KPluginInfo objects like you would treat a null pointer.

[KSharedPtr<KService>] kcmServices | ( |  | self ) |

Returns:
  A list of Service pointers if the plugin installs one or more KCModule

QString license | ( |  | self ) |

Returns:
  The license keyword of this plugin.

load | ( | self, |
|  | KConfigGroup | config=KConfigGroup()
| ) |  |  |

Load the state of the plugin - enabled or not.

Parameters:

  | config | The KConfigGroup holding the information whether plugin is enabled.

QString name | ( |  | self ) |

Returns:
  The user visible name of the plugin.

bool operator != | ( | self, |
|  | KPluginInfo | rhs
| ) |  |  |

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

bool operator < | ( | self, |
|  | KPluginInfo | rhs
| ) |  |  |

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

bool operator == | ( | self, |
|  | KPluginInfo | rhs
| ) |  |  |

Compares two objects whether they share the same data.

bool operator > | ( | self, |
|  | KPluginInfo | rhs
| ) |  |  |

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

QString pluginName | ( |  | self ) |

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

QVariant property | ( | self, |
|  | QString | key
| ) |  |  |

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.

save | ( | self, |
|  | KConfigGroup | config=KConfigGroup()
| ) |  |  |

Save state of the plugin - enabled or not.

Parameters:

  | config | The KConfigGroup holding the information whether plugin is enabled.

KSharedPtr<KService> service | ( |  | self ) |

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()

setConfig | ( | self, |
|  | 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).

setPluginEnabled | ( | self, |
|  | bool | enabled
| ) |  |  |

Set whether the plugin is currently loaded.

See also:
  isPluginEnabled()

See also:
  save()

QString version | ( |  | self ) |

Returns:
  The version of the plugin.

QString website | ( |  | self ) |

Returns:
  The website of the plugin/author.

## Static Method Documentation

[KPluginInfo] fromFiles | ( | QStringList | files,
|  | KConfigGroup | config=KConfigGroup()
| ) |  |  |

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:

  | files | The list of files to construct the list of KPluginInfo objects from
  | config | The config group where to save/load whether the plugin is enabled/disabled

[KPluginInfo] fromKPartsInstanceName | ( | QString | componentName,
|  | KConfigGroup | config=KConfigGroup()
| ) |  |  |

Returns:
  A list of KPluginInfo objects for the KParts plugins of a component. You only need the name of the component not a pointer to the KComponentData object.

Parameters:

  | componentName | Use the component name to look up all KParts plugins for it.
  | config | The config group where to save/load whether the plugin is enabled/disabled

[KPluginInfo] fromServices | ( | [KSharedPtr<KService>] | services,
|  | KConfigGroup | config=KConfigGroup()
| ) |  |  |

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:

  | services | The list of services to construct the list of KPluginInfo objects from
  | config | The config group where to save/load whether the plugin is enabled/disabled