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

Method CraftPlugin

plugins/craft/craftplugin.cpp:48–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48CraftPlugin::CraftPlugin(QObject* parent, const KPluginMetaData& metaData, const QVariantList& /*args*/)
49 : IPlugin(QStringLiteral("kdevcraft"), parent, metaData)
50{
51 const QString pythonExecutable = CraftRuntime::findPython();
52 if (pythonExecutable.isEmpty())
53 return;
54
55 // If KDevelop itself runs under Craft env, this plugin has nothing to do
56 if (qEnvironmentVariableIsSet("KDEROOT"))
57 return;
58
59 connect(ICore::self()->projectController(), &IProjectController::projectAboutToBeOpened, this,
60 [pythonExecutable](KDevelop::IProject* project) {
61 const QString craftRoot = CraftRuntime::findCraftRoot(project->path());
62 auto* currentCraftRuntime =
63 qobject_cast<CraftRuntime*>(ICore::self()->runtimeController()->currentRuntime());
64
65 if (craftRoot.isEmpty()) {
66 if (currentCraftRuntime)
67 qCDebug(CRAFT) << "Loading a non-Craft project while Craft runtime is enabled. This will cause "
68 "the project to build and run under a Craft env!";
69 return;
70 }
71
72 qCDebug(CRAFT) << "Found Craft root at" << craftRoot;
73 if (currentCraftRuntime) {
74 qCDebug(CRAFT) << "A Craft runtime rooted at" << currentCraftRuntime->craftRoot()
75 << "is already active. Will not create another one";
76 return;
77 }
78
79 auto* runtime = new CraftRuntime(craftRoot, pythonExecutable);
80 ICore::self()->runtimeController()->addRuntimes(runtime);
81 if (wantAutoEnable(project, craftRoot))
82 ICore::self()->runtimeController()->setCurrentRuntime(runtime);
83 });
84}
85
86#include "craftplugin.moc"
87#include "moc_craftplugin.cpp"

Callers

nothing calls this directly

Calls 9

wantAutoEnableFunction · 0.85
projectControllerMethod · 0.80
currentRuntimeMethod · 0.80
runtimeControllerMethod · 0.80
craftRootMethod · 0.80
addRuntimesMethod · 0.80
setCurrentRuntimeMethod · 0.80
isEmptyMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected