| 70 | }; |
| 71 | |
| 72 | IPlugin::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 | |
| 114 | IPlugin::~IPlugin() = default; |
| 115 |
nothing calls this directly
no test coverage detected