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

Method IPlugin

kdevplatform/interfaces/iplugin.cpp:72–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70};
71
72IPlugin::IPlugin(const QString& componentName, QObject* parent, const KPluginMetaData& metaData)
73 : QObject(parent)
74 , KXMLGUIClient()
75 , d_ptr(new IPluginPrivate(this))
76{
77 Q_D(IPlugin);
78
79 // The following cast is safe, there's no component in KDevPlatform that
80 // creates plugins except the plugincontroller. The controller passes
81 // Core::self() as parent to KServiceTypeTrader::createInstanceFromQuery
82 // so we know the parent is always a Core* pointer.
83 // This is the only way to pass the Core pointer to the plugin during its
84 // creation so plugins have access to ICore during their creation.
85 Q_ASSERT(qobject_cast<KDevelop::ICore*>(parent));
86 d->core = static_cast<KDevelop::ICore*>(parent);
87
88 setComponentName(componentName, metaData.name());
89
90 auto clientAdded = [this] (KXMLGUIClient* client) {
91 Q_D(IPlugin);
92 d->guiClientAdded(client);
93 };
94 const auto mainWindows = KMainWindow::memberList();
95 for (KMainWindow* mw : mainWindows) {
96 auto* guiWindow = qobject_cast<KXmlGuiWindow*>(mw);
97 if (! guiWindow)
98 continue;
99
100 connect(guiWindow->guiFactory(), &KXMLGUIFactory::clientAdded,
101 this, clientAdded);
102 }
103
104 auto updateState = [this] {
105 Q_D(IPlugin);
106 d->updateState();
107 };
108 connect(ICore::self()->projectController(), &IProjectController::projectOpened,
109 this, updateState);
110 connect(ICore::self()->projectController(), &IProjectController::projectClosed,
111 this, updateState);
112}
113
114IPlugin::~IPlugin() = default;
115

Callers

nothing calls this directly

Calls 5

guiClientAddedMethod · 0.80
guiFactoryMethod · 0.80
projectControllerMethod · 0.80
nameMethod · 0.45
updateStateMethod · 0.45

Tested by

no test coverage detected