Commit dc919642 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Make Ctrl+W shortcut work in Ctrl+Tab tabswitcher

BUG: 410685
parent dcc2a409
......@@ -66,7 +66,6 @@ TabSwitcherPluginView::TabSwitcherPluginView(TabSwitcherPlugin *plugin, KTextEdi
// track existing documents
connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentCreated, this, &TabSwitcherPluginView::registerDocument);
connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentWillBeDeleted, this, &TabSwitcherPluginView::unregisterDocument);
// track lru activation of views to raise the respective documents in the model
connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, &TabSwitcherPluginView::raiseView);
......@@ -102,9 +101,17 @@ void TabSwitcherPluginView::setupActions()
aPrev->setStatusTip(i18n("Walk through the list of last used views"));
connect(aPrev, &QAction::triggered, this, &TabSwitcherPluginView::walkBackward);
auto aClose = actionCollection()->addAction(QStringLiteral("view_lru_document_close"));
aClose->setText(i18n("Close View"));
actionCollection()->setDefaultShortcut(aClose, Qt::CTRL | Qt::Key_W);
aClose->setWhatsThis(i18n("Closes the selected view in the list of last used views."));
aClose->setStatusTip(i18n("Closes the selected view in the list of last used views."));
connect(aClose, &QAction::triggered, this, &TabSwitcherPluginView::closeView);
// make sure action work when the popup has focus
void TabSwitcherPluginView::setupModel()
......@@ -250,5 +257,18 @@ void TabSwitcherPluginView::activateView(const QModelIndex &index)
void TabSwitcherPluginView::closeView()
if (m_treeView->selectionModel()->selectedRows().isEmpty()) {
const int row = m_treeView->selectionModel()->selectedRows().first().row();
KTextEditor::Document* doc = m_model->item(row);
if (doc) {
// required for TabSwitcherPluginFactory vtable
#include "tabswitcher.moc"
......@@ -113,6 +113,11 @@ public Q_SLOTS:
void activateView(const QModelIndex &index);
* Closes the current view
void closeView();
* Move through the list.
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