Pages
API Documentation
On this page

KPluginModel Class

A model that provides a list of available plugins and allows to disable/enable them. More...

  • Header: #include <KPluginModel>
  • CMake: find_package(KF6 REQUIRED COMPONENTS KCMUtils)
    target_link_libraries(mytarget PRIVATE KCMUtilsCore)
  • Inherits: QAbstractListModel

List of all members, including inherited members

Public Types

Public Functions

Signals

Detailed Description

Plugins need to define the X-KDE-ConfigModule property for their config modules to be found. The value for this property is the namespace and file name of the KCM for the plugin.

An example value is "kf6/krunner/kcms/kcm_krunner_charrunner", "kf6/krunner/kcms" is the namespace and "kcm_krunner_charrunner" the file name. The loaded KCMs don't need any embedded JSON metadata.

See also KPluginWidget

Member Type Documentation

enum KPluginModel::Roles

Constant
KPluginModel::NameRole Qt::DisplayRole
KPluginModel::IconRole Qt::DecorationRole
KPluginModel::EnabledRole Qt::CheckStateRole
KPluginModel::DescriptionRole Qt::UserRole + 1
KPluginModel::IsChangeableRole 258
KPluginModel::MetaDataRole 259
KPluginModel::ConfigRole 260
KPluginModel::IdRole 261
KPluginModel::EnabledByDefaultRole 262
KPluginModel::SortableRole 263

Member Function Documentation

[explicit] KPluginModel::KPluginModel(QObject *parent = nullptr)

void KPluginModel::addPlugins(const QList<KPluginMetaData> &plugins, const QString &categoryLabel)

Appends plugins to the model.

This will not replace existing entries.

plugins The plugins to be added.

categoryLabel A user-visible label for the section the plugins are added to.

[since 6.0] void KPluginModel::addUnsortablePlugins(const QList<KPluginMetaData> &plugins, const QString &categoryLabel)

Adds plugins that should not be sorted automatically based on their name.

This is useful in case your app has a custom sorting mechanism or implements reordering of plugins.

plugins The plugins to be added.

categoryLabel A user-visible label for the section the plugins are added to.

This function was introduced in Qt 6.0.

void KPluginModel::clear()

Removes all plugins.

[signal] void KPluginModel::defaulted(bool isDefaulted)

Emitted when the enabled state isDefaulted, that is, it matches the default changes.

See also defaults

void KPluginModel::defaults()

Resets the enabled state of the plugins to its defaults.

KPluginMetaData KPluginModel::findConfigForPluginId(const QString &pluginId) const

Returns the KPluginMetaData object of the plugin's config module with the specified pluginId.

If no plugin is found or the plugin does not have a config, the resulting KPluginMetaData object will be invalid.

bool KPluginModel::isSaveNeeded()

Returns whether there are unsaved changes to the enabled state of the plugins.

[signal] void KPluginModel::isSaveNeededChanged()

Emitted when isSaveNeeded is changed.

void KPluginModel::load()

Loads the enabled state of the plugins from the config group set by setConfig.

[since 6.0] void KPluginModel::removePlugin(const KPluginMetaData &data)

Removes a plugin with the specified data.

This function was introduced in Qt 6.0.

void KPluginModel::save()

Saves the enabled state of the plugins to the config group set by setConfig.

void KPluginModel::setConfig(const KConfigGroup &config)

Sets the KConfigGroup config that is used to load/save the enabled state.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.