Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
dc919642
Commit
dc919642
authored
Dec 14, 2020
by
Waqar Ahmed
Committed by
Christoph Cullmann
Dec 14, 2020
Browse files
Make Ctrl+W shortcut work in Ctrl+Tab tabswitcher
BUG: 410685
parent
dcc2a409
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/tabswitcher/tabswitcher.cpp
View file @
dc919642
...
...
@@ -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
m_treeView
->
addAction
(
aNext
);
m_treeView
->
addAction
(
aPrev
);
m_treeView
->
addAction
(
aClose
);
}
void
TabSwitcherPluginView
::
setupModel
()
...
...
@@ -250,5 +257,18 @@ void TabSwitcherPluginView::activateView(const QModelIndex &index)
m_treeView
->
hide
();
}
void
TabSwitcherPluginView
::
closeView
()
{
if
(
m_treeView
->
selectionModel
()
->
selectedRows
().
isEmpty
())
{
return
;
}
const
int
row
=
m_treeView
->
selectionModel
()
->
selectedRows
().
first
().
row
();
KTextEditor
::
Document
*
doc
=
m_model
->
item
(
row
);
if
(
doc
)
{
KTextEditor
::
Editor
::
instance
()
->
application
()
->
closeDocument
(
doc
);
}
}
// required for TabSwitcherPluginFactory vtable
#include "tabswitcher.moc"
addons/tabswitcher/tabswitcher.h
View file @
dc919642
...
...
@@ -113,6 +113,11 @@ public Q_SLOTS:
*/
void
activateView
(
const
QModelIndex
&
index
);
/**
* Closes the current view
*/
void
closeView
();
protected:
/**
* Move through the list.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment