Commit a483a872 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

lspclient: add actions to switch to diagnostics tab and close other tabs

parent 343a9498
......@@ -229,6 +229,8 @@ class LSPClientActionView : public QObject
QPointer<QAction> m_diagnostics;
QPointer<QAction> m_diagnosticsHighlight;
QPointer<QAction> m_diagnosticsMark;
QPointer<QAction> m_diagnosticsSwitch;
QPointer<QAction> m_diagnosticsCloseNon;
QPointer<QAction> m_restartServer;
QPointer<QAction> m_restartAll;
......@@ -335,6 +337,10 @@ public:
m_diagnosticsMark = actionCollection()->addAction(QStringLiteral("lspclient_diagnostics_mark"), this, &self_type::displayOptionChanged);
m_diagnosticsMark->setText(i18n("Show diagnostics marks"));
m_diagnosticsMark->setCheckable(true);
m_diagnosticsSwitch = actionCollection()->addAction(QStringLiteral("lspclient_diagnostic_switch"), this, &self_type::switchToDiagnostics);
m_diagnosticsSwitch->setText(i18n("Switch to diagnostics tab"));
m_diagnosticsCloseNon = actionCollection()->addAction(QStringLiteral("lspclient_diagnostic_close_non"), this, &self_type::closeNonDiagnostics);
m_diagnosticsCloseNon->setText(i18n("Close all non-diagnostics tabs"));
// server control
m_restartServer = actionCollection()->addAction(QStringLiteral("lspclient_restart_server"), this, &self_type::restartCurrent);
......@@ -361,6 +367,8 @@ public:
menu->addAction(m_diagnostics);
menu->addAction(m_diagnosticsHighlight);
menu->addAction(m_diagnosticsMark);
menu->addAction(m_diagnosticsSwitch);
menu->addAction(m_diagnosticsCloseNon);
menu->addSeparator();
menu->addAction(m_restartServer);
menu->addAction(m_restartAll);
......@@ -437,6 +445,7 @@ public:
m_diagnosticsTreeOwn.reset(m_diagnosticsTree);
m_tabWidget->removeTab(index);
}
m_diagnosticsSwitch->setEnabled(m_diagnostics->isChecked());
m_serverManager->setIncrementalSync(m_incrementalSync->isChecked());
updateState();
}
......@@ -796,6 +805,23 @@ public:
}
}
void switchToDiagnostics()
{
m_tabWidget->setCurrentWidget(m_diagnosticsTree);
m_mainWindow->showToolView(m_toolView.data());
}
void closeNonDiagnostics()
{
for (int i = 0; i < m_tabWidget->count(); ) {
if (m_tabWidget->widget(i) != m_diagnosticsTree) {
tabCloseRequested(i);
} else {
++i;
}
}
}
// local helper to overcome some differences in LSP types
struct RangeItem
{
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui>
<gui name="lspclient" library="lspclient" version="2" translationDomain="lspclient">
<gui name="lspclient" library="lspclient" version="3" translationDomain="lspclient">
<MenuBar>
<Menu name="LSPClient Menubar">
<text>LSP Client</text>
......@@ -20,6 +20,8 @@
<Action name="lspclient_diagnostics"/>
<Action name="lspclient_diagnostics_highlight"/>
<Action name="lspclient_diagnostics_mark"/>
<Action name="lspclient_diagnostic_switch"/>
<Action name="lspclient_diagnostic_close_non"/>
<Separator/>
<Action name="lspclient_restart_server"/>
<Action name="lspclient_restart_all"/>
......
Markdown is supported
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