Commit 59e0bc31 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Use KTextEditor::MainWindow to find toolviewmanager

parent 555496c5
Pipeline #222531 passed with stage
in 9 minutes and 8 seconds
......@@ -31,7 +31,7 @@ KateProjectInfoViewTerminal::KateProjectInfoViewTerminal(KateProjectPluginView *
m_layout->setSpacing(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_showProjectInfoViewAction = Utils::toolviewShowAction(pluginView, QStringLiteral("kateprojectinfo"));
m_showProjectInfoViewAction = Utils::toolviewShowAction(m_pluginView->mainWindow(), QStringLiteral("kateprojectinfo"));
}
KateProjectInfoViewTerminal::~KateProjectInfoViewTerminal()
......
......@@ -33,37 +33,20 @@ QIcon iconForDocument(KTextEditor::Document *doc)
return icon;
}
QAction *toolviewShowAction(KXMLGUIClient *client, const QString &toolviewName)
QAction *toolviewShowAction(KTextEditor::MainWindow *mainWindow, const QString &toolviewName)
{
if (!client) {
qWarning() << Q_FUNC_INFO << "invalid null client, toolviewName: " << toolviewName;
Q_ASSERT(false);
return nullptr;
}
Q_ASSERT(mainWindow);
const auto clients = mainWindow->guiFactory()->clients();
static const QString prefix = QStringLiteral("kate_mdi_toolview_");
if (client->componentName() == QStringLiteral("toolviewmanager")) {
return client->actionCollection()->action(prefix + toolviewName);
}
KXMLGUIClient *toolviewmanager = nullptr;
if (!client->factory()) {
qWarning() << Q_FUNC_INFO << "don't have a client factory, toolviewName: " << toolviewName;
return nullptr;
}
const auto clients = client->factory()->clients();
for (auto client : clients) {
if (client->componentName() == QStringLiteral("toolviewmanager")) {
toolviewmanager = client;
break;
}
}
auto it = std::find_if(clients.begin(), clients.end(), [](const KXMLGUIClient *c) {
return c->componentName() == QStringLiteral("toolviewmanager");
});
if (!toolviewmanager) {
if (it == clients.end()) {
qWarning() << Q_FUNC_INFO << "Unexpected unable to find toolviewmanager KXMLGUIClient, toolviewName: " << toolviewName;
return nullptr;
}
return toolviewmanager->actionCollection()->action(prefix + toolviewName);
return (*it)->actionCollection()->action(prefix + toolviewName);
}
}
......@@ -90,5 +90,5 @@ inline QFont viewFont(KTextEditor::View *view)
*/
KATE_PRIVATE_EXPORT QIcon iconForDocument(KTextEditor::Document *doc);
KATE_PRIVATE_EXPORT QAction *toolviewShowAction(KXMLGUIClient *client, const QString &toolviewName);
KATE_PRIVATE_EXPORT QAction *toolviewShowAction(KTextEditor::MainWindow *, const QString &toolviewName);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment