Commit c9eaa0d9 authored by Méven Car's avatar Méven Car
Browse files

[KCM/Component] Clean deprecated code, modernize code

Test Plan: No changes

Reviewers: ervin, #plasma

Reviewed By: ervin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26181
parent 18ecd046
......@@ -80,10 +80,10 @@ void CfgComponent::load(KConfig *cfg) {
const KService::List offers = KServiceTypeTrader::self()->query(serviceTypeToConfigure);
for (KService::List::const_iterator tit = offers.begin(); tit != offers.end(); ++tit) {
ComponentSelector->addItem((*tit)->name());
m_lookupDict.insert((*tit)->name(), (*tit)->desktopEntryName());
m_revLookupDict.insert((*tit)->desktopEntryName(), (*tit)->name());
for (const auto &service: offers) {
ComponentSelector->addItem(service->name());
m_lookupDict.insert(service->name(), service->desktopEntryName());
m_revLookupDict.insert(service->desktopEntryName(), service->name());
}
KConfig store(mainGroup.readPathEntry("storeInFile",QStringLiteral("null")));
......@@ -122,18 +122,25 @@ ComponentChooser::ComponentChooser(QWidget *parent):
setupUi(this);
static_cast<QGridLayout*>(layout())->setRowStretch(1, 1);
const QStringList services=KGlobal::dirs()->findAllResources( "data",QStringLiteral("kcm_componentchooser/*.desktop"),
KStandardDirs::NoDuplicates);
for (QStringList::const_iterator it=services.constBegin(); it!=services.constEnd(); ++it)
const QStringList directories = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kcm_componentchooser"), QStandardPaths::LocateDirectory);
QStringList services;
for(const QString &directory : directories) {
const QDir dir(directory);
for(const QString &f: dir.entryList(QStringList("*.desktop"))) {
services += dir.absoluteFilePath(f);
}
}
for (const QString &service : qAsConst(services))
{
KConfig cfg(*it, KConfig::SimpleConfig);
KConfig cfg(service, KConfig::SimpleConfig);
KConfigGroup cg = cfg.group(QByteArray());
QListWidgetItem *item = new QListWidgetItem(
QIcon::fromTheme(cg.readEntry("Icon",QStringLiteral("preferences-desktop-default-applications"))),
cg.readEntry("Name",i18n("Unknown")));
item->setData(Qt::UserRole, (*it));
item->setData(Qt::UserRole, service);
ServiceChooser->addItem(item);
loadConfigWidget((*it), cfg.group(QByteArray()).readEntry("configurationType"), item->text());
loadConfigWidget(service, cfg.group(QByteArray()).readEntry("configurationType"), item->text());
}
ServiceChooser->setFixedWidth(ServiceChooser->sizeHintForColumn(0) + 20);
ServiceChooser->sortItems();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment