Changeset View
Changeset View
Standalone View
Standalone View
src/ksettings/dialog.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 89 | for (KPluginInfo::List::ConstIterator it = plugininfos.begin(); | |||
---|---|---|---|---|---|
91 | d->registeredComponents.append(it->pluginName()); | 91 | d->registeredComponents.append(it->pluginName()); | ||
92 | if (it->kcmServices().isEmpty()) { | 92 | if (it->kcmServices().isEmpty()) { | ||
93 | // this plugin has no kcm services, still we want to show the disable/enable stuff | 93 | // this plugin has no kcm services, still we want to show the disable/enable stuff | ||
94 | // so add a dummy kcm | 94 | // so add a dummy kcm | ||
95 | KService::Ptr service = it->service(); | 95 | KService::Ptr service = it->service(); | ||
96 | d->kcmInfos << KCModuleInfo(service); | 96 | d->kcmInfos << KCModuleInfo(service); | ||
97 | continue; | 97 | continue; | ||
98 | } | 98 | } | ||
99 | foreach (const KService::Ptr &service, it->kcmServices()) { | 99 | const auto lst = it->kcmServices(); | ||
100 | for (const KService::Ptr &service : lst) { | ||||
100 | d->kcmInfos << KCModuleInfo(service); | 101 | d->kcmInfos << KCModuleInfo(service); | ||
101 | } | 102 | } | ||
102 | } | 103 | } | ||
103 | 104 | | |||
104 | // The plugin, when disabled, disables all the KCMs described by kcmServices(). | 105 | // The plugin, when disabled, disables all the KCMs described by kcmServices(). | ||
105 | // - Normally they are grouped using a .setdlg file so that the group parent can get a | 106 | // - Normally they are grouped using a .setdlg file so that the group parent can get a | ||
106 | // checkbox to enable/disable the plugin. | 107 | // checkbox to enable/disable the plugin. | ||
107 | // - If the plugin does not belong to a group and has only one KCM the checkbox can be | 108 | // - If the plugin does not belong to a group and has only one KCM the checkbox can be | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 172 | { | |||
172 | registeredComponents += kcdparents; | 173 | registeredComponents += kcdparents; | ||
173 | QString constraint = kcdparents.join(QStringLiteral("' in [X-KDE-ParentComponents]) or ('")); | 174 | QString constraint = kcdparents.join(QStringLiteral("' in [X-KDE-ParentComponents]) or ('")); | ||
174 | constraint = QStringLiteral("('") + constraint + QStringLiteral("' in [X-KDE-ParentComponents])"); | 175 | constraint = QStringLiteral("('") + constraint + QStringLiteral("' in [X-KDE-ParentComponents])"); | ||
175 | 176 | | |||
176 | //qDebug() << "constraint = " << constraint; | 177 | //qDebug() << "constraint = " << constraint; | ||
177 | const QList<KService::Ptr> services = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), constraint); | 178 | const QList<KService::Ptr> services = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), constraint); | ||
178 | QSet<KCModuleInfo> ret; | 179 | QSet<KCModuleInfo> ret; | ||
179 | ret.reserve(services.count()); | 180 | ret.reserve(services.count()); | ||
180 | foreach (const KService::Ptr &service, services) { | 181 | for (const KService::Ptr &service : services) { | ||
181 | ret << KCModuleInfo(service); | 182 | ret << KCModuleInfo(service); | ||
182 | } | 183 | } | ||
183 | return ret; | 184 | return ret; | ||
184 | } | 185 | } | ||
185 | 186 | | |||
186 | bool DialogPrivate::isPluginForKCMEnabled(const KCModuleInfo *moduleinfo, KPluginInfo &pinfo) const | 187 | bool DialogPrivate::isPluginForKCMEnabled(const KCModuleInfo *moduleinfo, KPluginInfo &pinfo) const | ||
187 | { | 188 | { | ||
188 | // if the user of this class requested to hide disabled modules | 189 | // if the user of this class requested to hide disabled modules | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 307 | { | |||
316 | for (const QString &dir : dirs) { | 317 | for (const QString &dir : dirs) { | ||
317 | const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.setdlg")); | 318 | const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.setdlg")); | ||
318 | for (const QString &file : fileNames) { | 319 | for (const QString &file : fileNames) { | ||
319 | parseGroupFile(dir + QLatin1Char('/') + file); | 320 | parseGroupFile(dir + QLatin1Char('/') + file); | ||
320 | } | 321 | } | ||
321 | } | 322 | } | ||
322 | 323 | | |||
323 | //qDebug() << kcmInfos.count(); | 324 | //qDebug() << kcmInfos.count(); | ||
324 | foreach (const KCModuleInfo &info, kcmInfos) { | 325 | for (const KCModuleInfo &info : qAsConst(kcmInfos)) { | ||
325 | const QStringList parentComponents = info.service()->property(QStringLiteral("X-KDE-ParentComponents")).toStringList(); | 326 | const QStringList parentComponents = info.service()->property(QStringLiteral("X-KDE-ParentComponents")).toStringList(); | ||
326 | bool blacklisted = false; | 327 | bool blacklisted = false; | ||
327 | foreach (const QString &parentComponent, parentComponents) { | 328 | for (const QString &parentComponent : parentComponents) { | ||
328 | if (componentBlacklist.contains(parentComponent)) { | 329 | if (componentBlacklist.contains(parentComponent)) { | ||
329 | blacklisted = true; | 330 | blacklisted = true; | ||
330 | break; | 331 | break; | ||
331 | } | 332 | } | ||
332 | } | 333 | } | ||
333 | if (blacklisted) { | 334 | if (blacklisted) { | ||
334 | continue; | 335 | continue; | ||
335 | } | 336 | } | ||
336 | const QString parentId = info.service()->property(QStringLiteral("X-KDE-CfgDlgHierarchy"), QVariant::String).toString(); | 337 | const QString parentId = info.service()->property(QStringLiteral("X-KDE-CfgDlgHierarchy"), QVariant::String).toString(); | ||
337 | KPageWidgetItem *parent = pageItemForGroupId.value(parentId); | 338 | KPageWidgetItem *parent = pageItemForGroupId.value(parentId); | ||
338 | if (!parent) { | 339 | if (!parent) { | ||
339 | // dummy kcm | 340 | // dummy kcm | ||
340 | bool foundPlugin = false; | 341 | bool foundPlugin = false; | ||
341 | foreach (const KPluginInfo &pinfo, plugininfos) { | 342 | for (KPluginInfo pinfo : qAsConst(plugininfos)) { | ||
342 | if (pinfo.service() == info.service()) { | 343 | if (pinfo.service() == info.service()) { | ||
343 | if (pinfo.kcmServices().isEmpty()) { | 344 | if (pinfo.kcmServices().isEmpty()) { | ||
344 | const KService::Ptr service = info.service(); | 345 | const KService::Ptr service = info.service(); | ||
345 | // FIXME get weight from service or plugin info | 346 | // FIXME get weight from service or plugin info | ||
346 | const int weight = 1000; | 347 | const int weight = 1000; | ||
347 | KPageWidgetItem *item = createPageItem(nullptr, service->name(), service->comment(), service->icon(), weight); | 348 | KPageWidgetItem *item = createPageItem(nullptr, service->name(), service->comment(), service->icon(), weight); | ||
348 | connectItemCheckBox(item, pinfo, pinfo.isPluginEnabled()); | 349 | connectItemCheckBox(item, pinfo, pinfo.isPluginEnabled()); | ||
349 | foundPlugin = true; | 350 | foundPlugin = true; | ||
350 | break; | 351 | break; | ||
351 | } | 352 | } | ||
352 | } | 353 | } | ||
353 | } | 354 | } | ||
354 | if (foundPlugin) { | 355 | if (foundPlugin) { | ||
355 | continue; | 356 | continue; | ||
356 | } | 357 | } | ||
357 | } | 358 | } | ||
358 | KPageWidgetItem *item = q->addModule(info, parent, arguments); | 359 | KPageWidgetItem *item = q->addModule(info, parent, arguments); | ||
359 | // qDebug() << "added KCM '" << info.moduleName() << "'"; | 360 | // qDebug() << "added KCM '" << info.moduleName() << "'"; | ||
360 | foreach (KPluginInfo pinfo, plugininfos) { | 361 | for (KPluginInfo pinfo : qAsConst(plugininfos)) { | ||
361 | // qDebug() << pinfo.pluginName(); | 362 | // qDebug() << pinfo.pluginName(); | ||
362 | if (pinfo.kcmServices().contains(info.service())) { | 363 | if (pinfo.kcmServices().contains(info.service())) { | ||
363 | const bool isEnabled = isPluginForKCMEnabled(&info, pinfo); | 364 | const bool isEnabled = isPluginForKCMEnabled(&info, pinfo); | ||
364 | // qDebug() << "correct KPluginInfo for this KCM"; | 365 | // qDebug() << "correct KPluginInfo for this KCM"; | ||
365 | // this KCM belongs to a plugin | 366 | // this KCM belongs to a plugin | ||
366 | if (parent && pinfo.kcmServices().count() >= 1) { | 367 | if (parent && pinfo.kcmServices().count() >= 1) { | ||
367 | item->setEnabled(isEnabled); | 368 | item->setEnabled(isEnabled); | ||
368 | const KPluginInfo &plugin = pluginForItem.value(parent); | 369 | const KPluginInfo &plugin = pluginForItem.value(parent); | ||
Show All 23 Lines | |||||
392 | // now that the KCMs are in, check for empty groups and remove them again | 393 | // now that the KCMs are in, check for empty groups and remove them again | ||
393 | { | 394 | { | ||
394 | const KPageWidgetModel *model = qobject_cast<const KPageWidgetModel *>(q->pageWidget()->model()); | 395 | const KPageWidgetModel *model = qobject_cast<const KPageWidgetModel *>(q->pageWidget()->model()); | ||
395 | const QHash<QString, KPageWidgetItem *>::ConstIterator end = pageItemForGroupId.constEnd(); | 396 | const QHash<QString, KPageWidgetItem *>::ConstIterator end = pageItemForGroupId.constEnd(); | ||
396 | QHash<QString, KPageWidgetItem *>::ConstIterator it = pageItemForGroupId.constBegin(); | 397 | QHash<QString, KPageWidgetItem *>::ConstIterator it = pageItemForGroupId.constBegin(); | ||
397 | for (; it != end; ++it) { | 398 | for (; it != end; ++it) { | ||
398 | const QModelIndex index = model->index(it.value()); | 399 | const QModelIndex index = model->index(it.value()); | ||
399 | KPluginInfo pinfo; | 400 | KPluginInfo pinfo; | ||
400 | foreach (const KPluginInfo &p, plugininfos) { | 401 | for (const KPluginInfo &p : qAsConst(plugininfos)) { | ||
401 | if (p.name() == it.key()) { | 402 | if (p.name() == it.key()) { | ||
402 | pinfo = p; | 403 | pinfo = p; | ||
403 | break; | 404 | break; | ||
404 | } | 405 | } | ||
405 | } | 406 | } | ||
406 | bool allowEmpty = false; | 407 | bool allowEmpty = false; | ||
407 | if (pinfo.isValid()) { | 408 | if (pinfo.isValid()) { | ||
408 | allowEmpty = pinfo.property(QStringLiteral("X-KDE-PluginInfo-AllowEmptySettings")).toBool(); | 409 | allowEmpty = pinfo.property(QStringLiteral("X-KDE-PluginInfo-AllowEmptySettings")).toBool(); | ||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |