From f95bd6119aee15e459d1ceadd96604f76b777860 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 23 Mar 2023 16:37:58 +0100 Subject: [PATCH] Terminal: Register the command to open/close the Terminal pane This way Alt+5 (Ctrl+5) would open / close the Terminal pane. Change-Id: I91003987c1b8109abc302a79a895fab1557fefea Reviewed-by: Marcus Tillmanns --- src/plugins/terminal/terminalcommands.cpp | 9 +++++++++ src/plugins/terminal/terminalcommands.h | 2 ++ src/plugins/terminal/terminalpane.cpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/plugins/terminal/terminalcommands.cpp b/src/plugins/terminal/terminalcommands.cpp index 2bfb9ce5199..2bd14090286 100644 --- a/src/plugins/terminal/terminalcommands.cpp +++ b/src/plugins/terminal/terminalcommands.cpp @@ -153,4 +153,13 @@ QAction *TerminalCommands::openSettingsAction() return ActionManager::command("Preferences.Terminal.General")->action(); } +void TerminalCommands::registerOpenCloseTerminalPaneCommand() +{ + Command* terminalCmd = ActionManager::command("QtCreator.Pane.Terminal"); + QTC_ASSERT(terminalCmd, return); + + if (!m_commands.contains(terminalCmd)) + m_commands.append(terminalCmd); +} + } // namespace Terminal diff --git a/src/plugins/terminal/terminalcommands.h b/src/plugins/terminal/terminalcommands.h index 613d0d98229..59f9add643e 100644 --- a/src/plugins/terminal/terminalcommands.h +++ b/src/plugins/terminal/terminalcommands.h @@ -51,6 +51,8 @@ public: static QAction *openSettingsAction(); + void registerOpenCloseTerminalPaneCommand(); + protected: void initWidgetActions(const Core::Context &context); void initPaneActions(const Core::Context &context); diff --git a/src/plugins/terminal/terminalpane.cpp b/src/plugins/terminal/terminalpane.cpp index e796bb98229..94a93ed84e4 100644 --- a/src/plugins/terminal/terminalpane.cpp +++ b/src/plugins/terminal/terminalpane.cpp @@ -295,6 +295,8 @@ void TerminalPane::setFocus() { if (const auto t = currentTerminal()) t->setFocus(); + + TerminalCommands::instance().registerOpenCloseTerminalPaneCommand(); } bool TerminalPane::hasFocus() const