Commit 4fec9bf8 authored by Nate Graham's avatar Nate Graham

Open/close and focus/defocus terminal using the same shortcuts as Dolphin

Summary:
Users have complained that Kate's terminal doesn't use the same shortcut as Dolphin to
open and close. This patch makes it do so, using the same shortcuts that dolphin uses
to both open/close and also focus/de-focus:

F4: Open/close
Ctrl+Shift+F4: Focus/de-focus (also open if currently closed)

BUG: 414587
FIXED-IN: 20.04.0
Closes T12318

Test Plan:
Hit F4 twice -> terminal opens and closes
Hit Ctrl+Shift+F4 twice -> terminal focuses and de-focuses

Reviewers: #kate, cullmann

Reviewed By: #kate, cullmann

Subscribers: cullmann, kwrite-devel

Tags: #kate

Maniphest Tasks: T12318

Differential Revision: https://phabricator.kde.org/D25805
parent b771a195
......@@ -146,10 +146,16 @@ KateConsole::KateConsole(KateKonsolePlugin *plugin, KTextEditor::MainWindow *mw,
a->setText(i18nc("@action", "Run Current Document"));
connect(a, &QAction::triggered, this, &KateConsole::slotRun);
a = actionCollection()->addAction(QStringLiteral("katekonsole_tools_toggle_focus"));
a = actionCollection()->addAction(QStringLiteral("katekonsole_tools_toggle_visibility"));
a->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
a->setText(i18nc("@action", "&Focus Terminal"));
a->setText(i18nc("@action", "S&how Terminal"));
actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::Key_F4));
connect(a, &QAction::triggered, this, &KateConsole::slotToggleVisibility);
a = actionCollection()->addAction(QStringLiteral("katekonsole_tools_toggle_focus"));
a->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
a->setText(i18nc("@action", "&Focus Terminal"));
actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F4));
connect(a, &QAction::triggered, this, &KateConsole::slotToggleFocus);
m_mw->guiFactory()->addClient(this);
......@@ -363,6 +369,18 @@ void KateConsole::slotRun()
}
}
void KateConsole::slotToggleVisibility()
{
QAction *action = actionCollection()->action(QStringLiteral("katekonsole_tools_toggle_visibility"));
if (!m_part || !m_part->widget()->isVisible()) {
m_mw->showToolView(parentWidget());
action->setText(i18nc("@action", "&Hide Terminal"));
} else {
m_mw->hideToolView(m_toolView);
action->setText(i18nc("@action", "S&how Terminal"));
}
}
void KateConsole::slotToggleFocus()
{
QAction *action = actionCollection()->action(QStringLiteral("katekonsole_tools_toggle_focus"));
......
......@@ -167,6 +167,11 @@ private Q_SLOTS:
*/
void loadConsoleIfNeeded();
/**
* Show or hide the konsole view as appropriate.
*/
void slotToggleVisibility();
/**
* set or clear focus as appropriate.
*/
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui>
<gui name="katekonsole" library="katekonsoleplugin" version="4" translationDomain="katekonsoleplugin">
<gui name="katekonsole" library="katekonsoleplugin" version="5" translationDomain="katekonsoleplugin">
<MenuBar>
<Menu name="tools">
<text>&amp;Tools</text>
<Action name="katekonsole_tools_toggle_visibility" group="tools_operations"/>
<Action name="katekonsole_tools_toggle_focus" group="tools_operations"/>
<Action name="katekonsole_tools_pipe_to_terminal" group="tools_operations"/>
<Action name="katekonsole_tools_sync" group="tools_operations"/>
<Action name="katekonsole_tools_run" group="tools_operations"/>
<Action name="katekonsole_tools_toggle_focus" group="tools_operations"/>
</Menu>
</MenuBar>
</gui>
......
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