KPluginInfo
#include <KPluginInfo>
Public Types | |
typedef QList< KPluginInfo > | List |
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< KPluginMetaData > | toMetaData (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.
- 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
typedef QList<KPluginInfo> KPluginInfo::List |
A list of KPluginInfo objects.
Definition at line 48 of file kplugininfo.h.
Constructor & Destructor Documentation
◆ KPluginInfo() [1/6]
|
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
-
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.
- Deprecated:
- Since 5.90, see class API docs
Definition at line 267 of file kplugininfo.cpp.
◆ KPluginInfo() [2/6]
|
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]
|
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
-
args QVariantList with arguments, should contain a QVariantMap, keyed "MetaData" as provided by QPluginLoader::metaData() libraryPath The 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]
|
explicit |
Read plugin info from a KPluginMetaData object.
- Parameters
-
md The KPluginMetaData to read the information from
- Since
- 5.5
- Deprecated:
- Since 5.90, see class API docs
Definition at line 258 of file kplugininfo.cpp.
◆ KPluginInfo() [5/6]
KPluginInfo::KPluginInfo | ( | ) |
◆ 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()
|
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
-
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
Definition at line 450 of file kplugininfo.cpp.
◆ fromKPartsInstanceName()
|
static |
- Returns
- A list of KPluginInfo objects for the KParts plugins of a component.
- 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
- 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]
|
static |
- Parameters
-
meta the 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]
|
static |
- Parameters
-
list the 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()
|
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
-
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
- 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
-
config The 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()
- 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
-
config The 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]
|
static |
- Parameters
-
info the 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]
|
static |
- Parameters
-
list the 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:
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.