KCMUtils
kpluginwidget.cpp
72 [this](const QModelIndex &topLeft, const QModelIndex & /*bottomRight*/, const QVector<int> &roles) {
74 Q_EMIT pluginEnabledChanged(topLeft.data(KPluginModel::IdRole).toString(), topLeft.data(KPluginModel::EnabledRole).toBool());
94 connect(pluginDelegate, &PluginDelegate::configCommitted, this, &KPluginWidget::pluginConfigSaved);
111 void KPluginWidget::addPlugins(const QVector<KPluginMetaData> &plugins, const QString &categoryLabel)
146 if (d->pluginModel->data(index, Qt::CheckStateRole).toBool() != d->pluginModel->data(index, KPluginModel::EnabledByDefaultRole).toBool()) {
197 void KPluginWidget::setAdditionalButtonHandler(const std::function<QPushButton *(const KPluginMetaData &)> &handler)
219 void PluginDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
235 QRect(pluginSelector_d->dependantLayoutValue(s_margin + option.rect.left() + xOffset, iconSize, option.rect.width()),
240 QRect contentsRect(pluginSelector_d->dependantLayoutValue(s_margin * 2 + iconSize + option.rect.left() + xOffset,
279 fmTitle.elidedText(index.model()->data(index, Qt::DisplayRole).toString(), Qt::ElideRight, contentsRect.width()));
285 option.fontMetrics.elidedText(index.model()->data(index, KPluginModel::DescriptionRole).toString(), Qt::ElideRight, contentsRect.width()));
291 QSize PluginDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
308 const int maxTextWidth = qMax(fmTitle.boundingRect(text).width(), option.fontMetrics.boundingRect(comment).width());
310 const auto iconSize = pluginSelector_d->listView->style()->pixelMetric(QStyle::PM_IconViewIconSize);
331 connect(configurePushButton, &QAbstractButton::clicked, this, &PluginDelegate::slotConfigureClicked);
348 QPushButton *btn = handler(pluginSelector_d->pluginModel->data(index, KPluginModel::MetaDataRole).value<KPluginMetaData>());
357 void PluginDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const
367 checkBox->move(pluginSelector_d->dependantLayoutValue(s_margin, checkBox->sizeHint().width(), option.rect.width()),
373 aboutPushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - s_margin - aboutPushButtonSizeHint.width() - extraButtonWidth,
381 configurePushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - s_margin * 2 - configurePushButtonSizeHint.width()
390 extraButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - extraButtonWidth, extraPushButtonSizeHint.width(), option.rect.width()),
402 const bool enabledByDefault = index.model()->data(index, KPluginModel::EnabledByDefaultRole).toBool();
404 checkBox->setProperty("_kde_highlight_neutral", pluginSelector_d->showDefaultIndicator && enabledByDefault != enabled);
407 configurePushButton->setVisible(index.model()->data(index, KPluginModel::ConfigRole).value<KPluginMetaData>().isValid());
460 buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
463 KGuiItem::assign(buttonBox->button(QDialogButtonBox::RestoreDefaults), KStandardGuiItem::defaults());
474 connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, [moduleProxy] {
void showConfiguration(const QString &pluginId)
Shows the configuration dialog for the plugin pluginId if it's available.
Definition: kpluginwidget.cpp:169
AlignLeft
virtual QSize sizeHint() const const override
void setPen(const QColor &color)
CheckStateRole
MouseButtonPress
const QAbstractItemModel * model() const const
virtual void reject()
KGuiItem configure()
void setConfigurationArguments(const QStringList &arguments)
Sets the arguments with which the configuration modules will be initialized.
Definition: kpluginwidget.cpp:159
bool isSaveNeeded() const
Returns true if the plugin selector has any changes that are not yet saved to configuration.
Definition: kpluginwidget.cpp:154
virtual QVariant data(const QModelIndex &index, int role) const const=0
int count(const T &value) const const
T value() const const
QLayout * layout() const const
void setConfig(const KConfigGroup &config)
Set the config object that will be used to store the enabled state of the plugins.
Definition: kpluginwidget.cpp:117
void clicked(bool checked)
QIcon fromTheme(const QString &name)
bool isValid() const
int width() const const
bool isValid() const const
void pluginConfigSaved(const QString &pluginId)
Emitted after the config of an embedded KCM has been saved.
Definition: dialog.h:19
void drawText(const QPointF &position, const QString &text)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
State_Selected
KGuiItem cancel()
void load()
Loads the enabled state of the plugins from the config set by setConfig() and clears any changes by t...
Definition: kpluginwidget.cpp:132
void defaults()
Resets the enabled state of the plugins to their defaults.
Definition: kpluginwidget.cpp:137
bool isVisible() const const
void setAdditionalButtonHandler(const std::function< QPushButton *(const KPluginMetaData &)> &handler)
Add additional widgets to each row of the plugin selector.
Definition: kpluginwidget.cpp:197
QVariant data(int role) const const
static void assign(QPushButton *button, const KGuiItem &item)
void rejected()
QString i18n(const char *text, const TYPE &arg...)
int height() const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void textChanged(const QString &text)
ScrollPerPixel
void setDefaultsIndicatorsVisible(bool isVisible)
Shows an indicator when a plugin status is different from default.
Definition: kpluginwidget.cpp:189
void accepted()
virtual void accept()
KSharedConfigPtr config()
bool isValid() const const
PM_IconViewIconSize
bool toBool() const const
void setIcon(const QIcon &icon)
ElideRight
void resize(int w, int h)
void pluginEnabledChanged(const QString &pluginId, bool enabled)
Emitted when any of the plugins are changed.
QStringList configurationArguments() const
Returns the configuration arguments that will be used.
Definition: kpluginwidget.cpp:164
void rejected()
void addPlugins(const QVector< KPluginMetaData > &plugins, const QString &categoryLabel)
Adds the plugins with the given label to the widget.
Definition: kpluginwidget.cpp:111
virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
bool isValid(QStringView ifopt)
KGuiItem defaults()
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
LeftToRight
void setContentsMargins(int left, int top, int right, int bottom)
void restore()
void move(int x, int y)
bool isDefault() const
Returns true if the enabled state of each plugin is the same as that plugin's default state.
Definition: kpluginwidget.cpp:142
void save()
QChar * data()
Disabled
KGuiItem ok()
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, QIcon::Mode mode, QIcon::State state) const const
void setFont(const QFont &font)
const QAbstractItemModel * model() const const
WA_Hover
QStyle * style()
PE_PanelItemViewItem
QString toString() const const
void accepted()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 03:53:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 03:53:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.