KCMUtils
kpluginselector.cpp
78 if ((pe->pluginInfo.pluginName() != pluginEntry->pluginInfo.pluginName()) && dependencyList.contains(pe->pluginInfo.pluginName()) && !pe->checked) {
90 && pe->pluginInfo.dependencies().contains(pluginEntry->pluginInfo.pluginName()) && pe->checked) {
124 label->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(style()->pixelMetric(QStyle::PM_MessageBoxIconSize)));
136 link->setText(i18n("Automatic changes have been performed due to plugin dependencies. Click here for further information"));
141 QObject::connect(link, &KUrlLabel::leftClickedUrl, this, &KPluginSelector::Private::DependenciesWidget::showDependencyDetails);
148 void KPluginSelector::Private::DependenciesWidget::addDependency(const QString &dependency, const QString &pluginCausant, bool added)
158 if (dependencyMap.contains(dependency)) { // The dependency moved from added to removed or vice-versa
179 void KPluginSelector::Private::DependenciesWidget::userOverrideDependency(const QString &dependency)
204 QString message = i18n("Automatic changes have been performed in order to satisfy plugin dependencies:\n");
210 message += i18n("\n %1 plugin has been automatically checked because of the dependency of %2 plugin", dependency, info.pluginCausant);
212 message += i18n("\n %1 plugin has been automatically unchecked because of its dependency on %2 plugin", dependency, info.pluginCausant);
234 i18np("%1 plugin automatically added due to plugin dependencies", "%1 plugins automatically added due to plugin dependencies", addedByDependencies);
285 connect(d->lineEdit, &QLineEdit::textChanged, d->proxyModel, &QSortFilterProxyModel::invalidate);
287 connect(pluginDelegate, &Private::PluginDelegate::configCommitted, this, &KPluginSelector::configCommitted);
288 connect(this, &KPluginSelector::defaultsIndicatorsVisible, pluginDelegate, &Private::PluginDelegate::slotResetModel);
310 void KPluginSelector::addPlugins(const QString &componentName, const QString &categoryName, const QString &categoryKey, KSharedConfig::Ptr config)
314 QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, componentName + QStringLiteral("/kpartplugins"), QStandardPaths::LocateDirectory);
316 QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories);
353 d->pluginModel->addPlugins(pluginInfoList, categoryName, categoryKey, cfgGroup, pluginLoadMethod, true /* manually added */);
371 static_cast<KPluginSelector::Private::PluginDelegate *>(d->listView->itemDelegate())->clearChangedEntries();
385 static_cast<KPluginSelector::Private::PluginDelegate *>(d->listView->itemDelegate())->clearChangedEntries();
394 if (d->pluginModel->data(index, Qt::CheckStateRole).toBool() != pluginEntry->pluginInfo.isPluginEnabled()) {
405 auto delegate = static_cast<KPluginSelector::Private::PluginDelegate *>(d->listView->itemDelegate());
410 bool entryChanged = pluginEntry->pluginInfo.isPluginEnabled() != pluginEntry->pluginInfo.isPluginEnabledByDefault();
412 d->pluginModel->setData(index, pluginEntry->pluginInfo.isPluginEnabledByDefault(), Qt::CheckStateRole);
426 if (d->pluginModel->data(index, Qt::CheckStateRole).toBool() != pluginEntry->pluginInfo.isPluginEnabledByDefault()) {
436 static_cast<KPluginSelector::Private::PluginDelegate *>(d->listView->itemDelegate())->clearChangedEntries();
461 const auto entry = currentIndex.data(KPluginSelector::Private::PluginEntryRole).value<PluginEntry *>();
469 auto delegate = static_cast<KPluginSelector::Private::PluginDelegate *>(d->listView->itemDelegate());
476 void KPluginSelector::setAdditionalButtonHandler(std::function<QPushButton *(const KPluginInfo &)> handler)
489 KPluginSelector::Private::PluginModel::PluginModel(KPluginSelector::Private *pluginSelector_d, QObject *parent)
533 pluginEntry.isCheckable = !pluginInfo.isValid() || !pluginEntry.cfgGroup.isEntryImmutable(pluginInfo.pluginName() + QLatin1String("Enabled"));
536 && (categoryKey.isEmpty() || !pluginInfo.category().compare(categoryKey, Qt::CaseInsensitive)) && (!hasServiceNoDisplaySet(pluginInfo))) {
546 beginInsertRows(QModelIndex(), pluginEntryList.count(), pluginEntryList.count() + listToAdd.count() - 1);
559 QModelIndex KPluginSelector::Private::PluginModel::index(int row, int column, const QModelIndex &parent) const
563 return createIndex(row, column, (row < pluginEntryList.count()) ? (void *)&pluginEntryList.at(row) : nullptr);
582 (pluginEntry->pluginInfo.property(QStringLiteral("X-KDE-ConfigModule")).toString().isEmpty() ? 0 : 1);
613 bool KPluginSelector::Private::PluginModel::setData(const QModelIndex &index, const QVariant &value, int role)
642 KPluginSelector::Private::ProxyModel::ProxyModel(KPluginSelector::Private *pluginSelector_d, QObject *parent)
653 bool KPluginSelector::Private::ProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
667 bool KPluginSelector::Private::ProxyModel::subSortLessThan(const QModelIndex &left, const QModelIndex &right) const
671 .compare(static_cast<PluginEntry *>(right.internalPointer())->pluginInfo.name(), Qt::CaseInsensitive)
675 KPluginSelector::Private::PluginDelegate::PluginDelegate(KPluginSelector::Private *pluginSelector_d, QObject *parent)
681 pushButton->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); // only for getting size matters
690 void KPluginSelector::Private::PluginDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
707 QRect(pluginSelector_d->dependantLayoutValue(MARGIN + option.rect.left() + xOffset, iconSize, option.rect.width()),
715 QRect contentsRect(pluginSelector_d->dependantLayoutValue(MARGIN * 2 + iconSize + option.rect.left() + xOffset,
754 fmTitle.elidedText(index.model()->data(index, Qt::DisplayRole).toString(), Qt::ElideRight, contentsRect.width()));
759 option.fontMetrics.elidedText(index.model()->data(index, CommentRole).toString(), Qt::ElideRight, contentsRect.width()));
765 QSize KPluginSelector::Private::PluginDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
786 const int maxTextWidth = qMax(fmTitle.boundingRect(text).width(), option.fontMetrics.boundingRect(comment).width());
788 const auto iconSize = pluginSelector_d->listView->style()->pixelMetric(QStyle::PM_IconViewIconSize);
789 return QSize(maxTextWidth + (pluginSelector_d->showIcons ? iconSize : 0) + MARGIN * i + pushButton->sizeHint().width() * j,
793 QList<QWidget *> KPluginSelector::Private::PluginDelegate::createItemWidgets(const QModelIndex &index) const
810 connect(configurePushButton, &QAbstractButton::clicked, this, &PluginDelegate::slotConfigureClicked);
813 QList<QEvent::Type>() << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick << QEvent::KeyPress
817 QList<QEvent::Type>() << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick << QEvent::KeyPress
821 QList<QEvent::Type>() << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick << QEvent::KeyPress
826 QPushButton *btn = handler(pluginSelector_d->pluginModel->pluginEntryList.at(index.row()).pluginInfo);
835 void KPluginSelector::Private::PluginDelegate::updateItemWidgets(const QList<QWidget *> widgets,
847 checkBox->move(pluginSelector_d->dependantLayoutValue(MARGIN, checkBox->sizeHint().width(), option.rect.width()),
853 aboutPushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - MARGIN - aboutPushButtonSizeHint.width() - extraButtonWidth,
861 configurePushButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - MARGIN * 2 - configurePushButtonSizeHint.width()
869 extraButton->move(pluginSelector_d->dependantLayoutValue(option.rect.width() - extraButtonWidth, extraPushButtonSizeHint.width(), option.rect.width()),
882 bool isDefault = pluginEntry->pluginInfo.isPluginEnabledByDefault() == index.model()->data(index, Qt::CheckStateRole).toBool();
883 checkBox->setProperty("_kde_highlight_neutral", pluginSelector_d->showDefaultIndicator && !isDefault);
962 const QString configModule = pluginInfo.property(QStringLiteral("X-KDE-ConfigModule")).toString();
970 metaDataList = {KPluginMetaData::findPluginById(pluginNamespace, pluginId)}; // Clear the list to avoid old desktop files to appear twice
980 KCModuleProxy *currentModuleProxy = new KCModuleProxy(data, moduleProxyParentWidget, pluginSelector_d->kcmArguments);
1019 buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
1022 KGuiItem::assign(buttonBox->button(QDialogButtonBox::RestoreDefaults), KStandardGuiItem::defaults());
1025 connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &PluginDelegate::slotDefaultClicked);
1033 parentComponents = moduleProxy->moduleInfo().property(QStringLiteral("X-KDE-ParentComponents")).toStringList();
1037 parentComponents = moduleProxy->metaData().rawData().value(QStringLiteral("X-KDE-ParentComponents")).toVariant().toStringList();
1075 void KPluginSelector::Private::PluginDelegate::setHandler(std::function<QPushButton *(const KPluginInfo &)> handler)
void append(const T &value)
AlignLeft
QJsonObject rawData() const
QTextStream & right(QTextStream &stream)
Subdirectories
void setParent(QWidget *parent)
virtual QSize sizeHint() const const override
void changed(bool hasChanged)
Tells you whether the configuration is changed or not.
void setPen(const QColor &color)
CheckStateRole
void invalidate()
MouseButtonPress
const QAbstractItemModel * model() const const
LocateDirectory
static KPluginInfo::List fromServices(const KService::List &services, const KConfigGroup &config=KConfigGroup())
void load()
Load the state of the plugins (selected or not) from the KPluginInfo objects.
Definition: kpluginselector.cpp:362
virtual void reject()
void load()
Calling it will cause the contained module to run its load() routine.
Definition: kcmoduleproxy.cpp:268
CaseInsensitive
QVariant fromValue(const T &value)
void * internalPointer() const const
Link
A widget to select what plugins to load and configure the plugins.
Definition: kpluginselector.h:49
fileName
KGuiItem configure()
Q_EMITQ_EMIT
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
QString icon() const
QTextStream & left(QTextStream &stream)
bool hasNext() const const
KPluginSelector(QWidget *parent=nullptr)
Create a new KPluginSelector.
Definition: kpluginselector.cpp:255
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void setConfigurationArguments(const QStringList &arguments)
Sets the arguments with which the configuration modules will be initialized.
Definition: kpluginselector.cpp:446
void clicked(bool checked)
QIcon fromTheme(const QString &name)
bool isValid() const
void defaultsIndicatorsVisible()
Emitted when show defaults indicators changed.
void setFocusProxy(QWidget *w)
void load(const KConfigGroup &config=KConfigGroup())
void leftClickedUrl()
static KPluginInfo::List fromFiles(const QStringList &files, const KConfigGroup &config=KConfigGroup())
NoFilter
QString next()
void setChecked(bool)
int width() const const
bool isValid() const const
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
bool contains(const T &value) const const
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 defaults()
void setStandardButtons(QDialogButtonBox::StandardButtons buttons)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
bool isVisible() const const
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
void save()
Calling it will cause the contained module to run its save() routine.
Definition: kcmoduleproxy.cpp:277
static void assign(QPushButton *button, const KGuiItem &item)
QString pluginName() const
QString i18n(const char *text, const TYPE &arg...)
int height() const const
bool isSaveNeeded() const
Returns true if the plugin selector has any changes that are not yet saved to configuration.
Definition: kpluginselector.cpp:389
void setAdditionalButtonHandler(std::function< QPushButton *(const KPluginInfo &)> handler)
Add additional widgets to each row of the plugin selector.
Definition: kpluginselector.cpp:476
void textChanged(const QString &text)
bool isEmpty() const const
void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
ScrollPerPixel
QString category() const
void configCommitted(const QByteArray &componentName)
Emitted after the config of an embedded KCM has been saved.
void accepted()
virtual void accept()
bool isEmpty() const const
QJsonValue value(const QString &key) const const
QVariant toVariant() const const
Accepted
KPluginMetaData metaData() const
Returns the KPluginMetaData used to load the KCM.
Definition: kcmoduleproxy.cpp:346
CategorySortRole
bool isValid() const const
bool isValid() const
void setEnabled(bool)
PM_MessageBoxIconSize
KGuiItem ok()
bool toBool() const const
int row() const const
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QString label(StandardShortcut id)
void setIcon(const QIcon &icon)
KConfigGroup config() const
void addPlugins(const QString &componentName, const QString &categoryName=QString(), const QString &categoryKey=QString(), KSharedConfig::Ptr config=KSharedConfig::Ptr())
Add a list of KParts plugins.
Definition: kpluginselector.cpp:310
bool setProperty(const char *name, const QVariant &value)
ElideRight
void resize(int w, int h)
GenericDataLocation
virtual QSize sizeHint() const const override
QString name() const
void rejected()
void setToolTip(const QString &)
QPushButton * button(QDialogButtonBox::StandardButton which) const const
QString & insert(int position, QChar ch)
QString left(int n) const const
virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
bool isValid(QStringView ifopt)
void addWidget(QWidget *w)
int addTab(QWidget *page, const QString &label)
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
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 setAlignment(QWidget *w, Qt::Alignment alignment)
static KPluginMetaData findPluginById(const QString &directory, const QString &pluginId)
void save()
void addLayout(QLayout *layout, int stretch)
Disabled
QString comment() const
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, QIcon::Mode mode, QIcon::State state) const const
int compare(const QString &other, Qt::CaseSensitivity cs) const const
QStringList toStringList() const const
Fixed
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
void setFont(const QFont &font)
KGuiItem cancel()
QString mid(int position, int n) const const
void defaults()
Calling it will cause the contained module to load its default values.
Definition: kcmoduleproxy.cpp:286
void setDefaultsIndicatorsVisible(bool isVisible)
Show an indicator when a plugin status is different from default.
Definition: kpluginselector.cpp:481
QString message
const QAbstractItemModel * model() const const
WA_Hover
QStyle * style()
CategoryDisplayRole
void defaulted(bool isDefault)
Emitted after configuration is changed, tell if configuration represent default or not.
void showConfiguration(const QString &pluginId)
Shows the configuration dialog for the plugin pluginId if it's available.
Definition: kpluginselector.cpp:456
PE_PanelItemViewItem
QString toString() const const
bool isPluginEnabled() const
bool isDefault() const
Returns true if the plugin selector does not have any changes to application defaults.
Definition: kpluginselector.cpp:421
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 03:50:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 03:50:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.