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

ignore esc the same way for projects plugin toolviews

parent bdbd90a0
......@@ -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;
}
......@@ -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
......
......@@ -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);
}
......@@ -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
......
......@@ -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);
}
}
......
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