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
d51fd822
Commit
d51fd822
authored
Feb 16, 2021
by
Christoph Cullmann
🐮
Committed by
Waqar Ahmed
Feb 16, 2021
Browse files
ignore esc the same way for projects plugin toolviews
parent
bdbd90a0
Changes
5
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectinfoview.cpp
View file @
d51fd822
...
...
@@ -65,3 +65,14 @@ void KateProjectInfoView::showEvent(QShowEvent *)
{
setFocusProxy
(
currentWidget
());
}
bool
KateProjectInfoView
::
ignoreEsc
()
const
{
// we want to ignore stuff for some kinds of running shell processes like vim
if
(
const
auto
terminal
=
qobject_cast
<
const
KateProjectInfoViewTerminal
*>
(
currentWidget
()))
{
return
terminal
->
ignoreEsc
();
}
// else: always hide toolview, nothing to ignore
return
false
;
}
addons/project/kateprojectinfoview.h
View file @
d51fd822
...
...
@@ -46,6 +46,13 @@ public:
void
showEvent
(
QShowEvent
*
)
override
;
/**
* Shall the ESC key press be ignored?
* If not, the toolview will be hidden.
* @return ignore ESC shortcut?
*/
bool
ignoreEsc
()
const
;
private:
/**
* our plugin view
...
...
addons/project/kateprojectinfoviewterminal.cpp
View file @
d51fd822
...
...
@@ -8,8 +8,10 @@
#include "kateprojectinfoviewterminal.h"
#include "kateprojectpluginview.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginLoader>
#include <KSharedConfig>
#include <kde_terminal_interface.h>
KPluginFactory
*
KateProjectInfoViewTerminal
::
s_pluginFactory
=
nullptr
;
...
...
@@ -108,3 +110,17 @@ void KateProjectInfoViewTerminal::overrideShortcut(QKeyEvent *, bool &override)
*/
override
=
true
;
}
// share with konsole plugin
static
const
QStringList
s_escapeExceptions
{
QStringLiteral
(
"vi"
),
QStringLiteral
(
"vim"
),
QStringLiteral
(
"nvim"
)};
bool
KateProjectInfoViewTerminal
::
ignoreEsc
()
const
{
if
(
!
m_konsolePart
||
!
KConfigGroup
(
KSharedConfig
::
openConfig
(),
"Konsole"
).
readEntry
(
"KonsoleEscKeyBehaviour"
,
true
))
{
return
false
;
}
const
QStringList
exceptList
=
KConfigGroup
(
KSharedConfig
::
openConfig
(),
"Konsole"
).
readEntry
(
"KonsoleEscKeyExceptions"
,
s_escapeExceptions
);
const
auto
app
=
qobject_cast
<
TerminalInterface
*>
(
m_konsolePart
)
->
foregroundProcessName
();
return
exceptList
.
contains
(
app
);
}
addons/project/kateprojectinfoviewterminal.h
View file @
d51fd822
...
...
@@ -46,6 +46,13 @@ public:
*/
static
KPluginFactory
*
pluginFactory
();
/**
* Shall the ESC key press be ignored?
* If not, the toolview will be hidden.
* @return ignore ESC shortcut?
*/
bool
ignoreEsc
()
const
;
private
Q_SLOTS
:
/**
* Construct a new terminal for this view
...
...
addons/project/kateprojectpluginview.cpp
View file @
d51fd822
...
...
@@ -561,7 +561,8 @@ void KateProjectPluginView::handleEsc(QEvent *e)
QKeyEvent
*
k
=
static_cast
<
QKeyEvent
*>
(
e
);
if
(
k
->
key
()
==
Qt
::
Key_Escape
&&
k
->
modifiers
()
==
Qt
::
NoModifier
)
{
if
(
m_toolInfoView
->
isVisible
())
{
const
auto
infoView
=
qobject_cast
<
const
KateProjectInfoView
*>
(
m_stackedProjectInfoViews
->
currentWidget
());
if
(
m_toolInfoView
->
isVisible
()
&&
(
!
infoView
||
!
infoView
->
ignoreEsc
()))
{
m_mainWindow
->
hideToolView
(
m_toolInfoView
);
}
}
...
...
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