KCMUtils
kpluginwidget.cpp
82 [this](const QModelIndex &topLeft, const QModelIndex & /*bottomRight*/, const QList<int> &roles) {
84 Q_EMIT pluginEnabledChanged(topLeft.data(KPluginModel::IdRole).toString(), topLeft.data(KPluginModel::EnabledRole).toBool());
104 connect(pluginDelegate, &PluginDelegate::configCommitted, this, &KPluginWidget::pluginConfigSaved);
121void KPluginWidget::addPlugins(const QList<KPluginMetaData> &plugins, const QString &categoryLabel)
156 if (d->pluginModel->data(index, Qt::CheckStateRole).toBool() != d->pluginModel->data(index, KPluginModel::EnabledByDefaultRole).toBool()) {
207void KPluginWidget::setAdditionalButtonHandler(const std::function<QPushButton *(const KPluginMetaData &)> &handler)
229void PluginDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
245 QRect(pluginSelector_d->dependantLayoutValue(s_margin + option.rect.left() + xOffset, iconSize, option.rect.width()),
250 QRect contentsRect(pluginSelector_d->dependantLayoutValue(s_margin * 2 + iconSize + option.rect.left() + xOffset,
289 fmTitle.elidedText(index.model()->data(index, Qt::DisplayRole).toString(), Qt::ElideRight, contentsRect.width()));
295 option.fontMetrics.elidedText(index.model()->data(index, KPluginModel::DescriptionRole).toString(), Qt::ElideRight, contentsRect.width()));
301QSize PluginDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
318 const int maxTextWidth = qMax(fmTitle.boundingRect(text).width(), option.fontMetrics.boundingRect(comment).width());
320 const auto iconSize = pluginSelector_d->listView->style()->pixelMetric(QStyle::PM_IconViewIconSize);
341 connect(configurePushButton, &QAbstractButton::clicked, this, &PluginDelegate::slotConfigureClicked);
358 QPushButton *btn = handler(pluginSelector_d->pluginModel->data(index, KPluginModel::MetaDataRole).value<KPluginMetaData>());
367void PluginDelegate::updateItemWidgets(const QList<QWidget *> &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const
377 checkBox->move(pluginSelector_d->dependantLayoutValue(s_margin, checkBox->sizeHint().width(), option.rect.width()),
383 aboutPushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - s_margin - aboutPushButtonSizeHint.width() - extraButtonWidth,
391 configurePushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - s_margin * 2 - configurePushButtonSizeHint.width()
400 extraButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - extraButtonWidth, extraPushButtonSizeHint.width(), option.rect.width()),
412 const bool enabledByDefault = index.model()->data(index, KPluginModel::EnabledByDefaultRole).toBool();
414 checkBox->setProperty("_kde_highlight_neutral", pluginSelector_d->showDefaultIndicator && enabledByDefault != enabled);
417 configurePushButton->setVisible(index.model()->data(index, KPluginModel::ConfigRole).value<KPluginMetaData>().isValid());
466 buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
469 KGuiItem::assign(buttonBox->button(QDialogButtonBox::RestoreDefaults), KStandardGuiItem::defaults());
480 connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, [kcmInstance] {
static void assign(QPushButton *button, const KGuiItem &item)
bool isValid() const
A model that provides a list of available plugins and allows to disable/enable them.
Definition kpluginmodel.h:36
Q_SIGNAL void defaulted(bool isDefaulted)
Emitted when the enabled state matches the default changes.
QVariantList configurationArguments() const
Returns the configuration arguments that will be used.
Definition kpluginwidget.cpp:174
void load()
Loads the enabled state of the plugins from the config set by setConfig() and clears any changes by t...
Definition kpluginwidget.cpp:142
void setConfig(const KConfigGroup &config)
Set the config object that will be used to store the enabled state of the plugins.
Definition kpluginwidget.cpp:127
void setConfigurationArguments(const QVariantList &arguments)
Sets the arguments with which the configuration modules will be initialized.
Definition kpluginwidget.cpp:169
void setAdditionalButtonHandler(const std::function< QPushButton *(const KPluginMetaData &)> &handler)
Add additional widgets to each row of the plugin selector.
Definition kpluginwidget.cpp:207
void addPlugins(const QList< KPluginMetaData > &plugins, const QString &categoryLabel)
Adds the plugins with the given label to the widget.
Definition kpluginwidget.cpp:121
bool isSaveNeeded() const
Returns true if the plugin selector has any changes that are not yet saved to configuration.
Definition kpluginwidget.cpp:164
void pluginConfigSaved(const QString &pluginId)
Emitted after the config of an embedded KCM has been saved.
void showConfiguration(const QString &pluginId)
Shows the configuration dialog for the plugin pluginId if it's available.
Definition kpluginwidget.cpp:179
void setDefaultsIndicatorsVisible(bool isVisible)
Shows an indicator when a plugin status is different from default.
Definition kpluginwidget.cpp:199
void defaults()
Resets the enabled state of the plugins to their defaults.
Definition kpluginwidget.cpp:147
bool isDefault() const
Returns true if the enabled state of each plugin is the same as that plugin's default state.
Definition kpluginwidget.cpp:152
void pluginEnabledChanged(const QString &pluginId, bool enabled)
Emitted when any of the plugins are changed.
Definition PluginDelegate.qml:14
QString i18n(const char *text, const TYPE &arg...)
KCMUTILS_EXPORT KCModule * loadModule(const KPluginMetaData &metaData, QWidget *parent=nullptr, const QVariantList &args={}, const std::shared_ptr< QQmlEngine > &engine={})
Loads a KCModule.
Definition kcmoduleloader.cpp:76
bool isValid(QStringView ifopt)
KGuiItem configure()
KGuiItem cancel()
KGuiItem defaults()
KGuiItem ok()
void clicked(bool checked)
void setIcon(const QIcon &icon)
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
virtual QVariant data(const QModelIndex &index, int role) const const=0
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
ScrollPerPixel
QStyle * style()
virtual void accept()
void accepted()
virtual void reject()
void rejected()
void accepted()
void rejected()
MouseButtonPress
QIcon fromTheme(const QString &name)
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const const
void textChanged(const QString &text)
qsizetype count() const const
QVariant data(int role) const const
bool isValid() const const
const QAbstractItemModel * model() const const
void drawText(const QPoint &position, const QString &text)
void restore()
void save()
void setFont(const QFont &font)
void setPen(Qt::PenStyle style)
Disabled
bool isValid() const const
const QAbstractItemModel * model() const const
virtual QSize sizeHint() const const override
int height() const const
int width() const const
QChar * data()
PM_LayoutLeftMargin
PE_PanelItemViewItem
State_Selected
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
AlignLeft
TopEdge
CheckStateRole
LeftToRight
ElideRight
WA_Hover
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QVariant fromValue(T &&value)
bool toBool() const const
QString toString() const const
T value() const const
void move(const QPoint &)
void resize(const QSize &)
bool isVisible() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.