MCPcopy Create free account
hub / github.com/KDE/kdevelop / initialize

Method initialize

kdevplatform/shell/plugincontroller.cpp:425–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423}
424
425void PluginController::initialize()
426{
427 Q_D(PluginController);
428
429 QElapsedTimer timer;
430 timer.start();
431
432 QMap<QString, bool> pluginMap;
433 if( ShellExtension::getInstance()->defaultPlugins().isEmpty() )
434 {
435 for (const KPluginMetaData& pi : std::as_const(d->plugins)) {
436 QJsonValue enabledByDefaultValue = pi.rawData()[KEY_KPlugin()].toObject()[KEY_EnabledByDefault()];
437 // plugins enabled until explicitly specified otherwise
438 const bool enabledByDefault = (enabledByDefaultValue.isNull() || enabledByDefaultValue.toBool());
439 pluginMap.insert(pi.pluginId(), enabledByDefault);
440 }
441 } else
442 {
443 // Get the default from the ShellExtension
444 const auto defaultPlugins = ShellExtension::getInstance()->defaultPlugins();
445 for (const QString& s : defaultPlugins) {
446 pluginMap.insert( s, true );
447 }
448 }
449
450 KConfigGroup grp = Core::self()->activeSession()->config()->group( KEY_Plugins() );
451 QMap<QString, QString> entries = grp.entryMap();
452
453 QMap<QString, QString>::Iterator it;
454 for ( it = entries.begin(); it != entries.end(); ++it )
455 {
456 const QString key = it.key();
457 if (key.endsWith(KEY_Suffix_Enabled())) {
458 const QString pluginid = key.left(key.length() - 7);
459 const bool defValue = pluginMap.value( pluginid, false );
460 const bool enabled = grp.readEntry(key, defValue);
461 pluginMap.insert( pluginid, enabled );
462 }
463 }
464
465 // store current known set of enabled plugins
466 for (const KPluginMetaData& pi : std::as_const(d->plugins)) {
467 if (isUserSelectable(pi)) {
468 auto it = pluginMap.constFind(pi.pluginId());
469 if (it != pluginMap.constEnd() && (it.value())) {
470 grp.writeEntry(pi.pluginId() + KEY_Suffix_Enabled(), true);
471 }
472 } else {
473 // Backward compat: Remove any now-obsolete entries
474 grp.deleteEntry(pi.pluginId() + QLatin1String("Disabled"));
475 }
476 }
477 // Synchronize so we're writing out to the file.
478 grp.sync();
479
480 // load global plugins
481 for (const KPluginMetaData& pi : std::as_const(d->plugins)) {
482 if (isGlobalPlugin(pi)) {

Callers

nothing calls this directly

Calls 15

KEY_KPluginFunction · 0.85
KEY_EnabledByDefaultFunction · 0.85
KEY_PluginsFunction · 0.85
KEY_Suffix_EnabledFunction · 0.85
isUserSelectableFunction · 0.85
isGlobalPluginFunction · 0.85
defaultPluginsMethod · 0.80
isNullMethod · 0.80
pluginIdMethod · 0.80
endsWithMethod · 0.80
readEntryMethod · 0.80
constEndMethod · 0.80

Tested by

no test coverage detected