Summary:
Add an action for focusing and de-focusing the Terminal Panel.
FEATURE: 185096
FIXED-IN 20.04.0
Test Plan:
- Hit {key Ctrl Shift F4} or click {nav Tools > Focus Terminal Panel} or {nav Control > Tools > Focus Terminal Panel}
- If the Terminal Panel was closed, it opens and gains focus
- If the Terminal Panel was open but unfocused, it gains focus
- If the Terminal Panel was open and focused, focus returns to the view
{
F6630289, size=full}
Reviewers: #dolphin, elvisangelaccio, rominf
Reviewed By: #dolphin, elvisangelaccio, rominf
Subscribers: kfm-devel, elvisangelaccio, rkflx, ngraham, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D10959
openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
+
+ QAction* focusTerminalPanel = actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
+ focusTerminalPanel->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
+ focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
+ actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL + Qt::SHIFT + Qt::Key_F4);
+ connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::focusTerminalPanel);
}
#endif
return false;
}
+void DolphinMainWindow::focusTerminalPanel()
+{
+ if (m_terminalPanel->isVisible()) {
+ if (m_terminalPanel->terminalHasFocus()) {
+ m_activeViewContainer->view()->setFocus(Qt::FocusReason::ShortcutFocusReason);
+ actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
+ } else {
+ m_terminalPanel->setFocus(Qt::FocusReason::ShortcutFocusReason);
+ actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
+ }
+ } else {
+ actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
+ actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
+ }
+}
+
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
KIO::FileUndoManager::UiInterface()
{
/** Opens a terminal window for the current location. */
void openTerminal();
+ /** Focus a Terminal Panel. */
+ void focusTerminalPanel();
+
/** Opens the settings dialog for Dolphin. */
void editSettings();
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphinpart" version="14" translationDomain="dolphin">
+<kpartgui name="dolphinpart" version="15" translationDomain="dolphin">
<MenuBar>
<Menu name="edit"><text>&Edit</text>
<Action name="new_menu"/>
</Menu>
<Menu name="tools"><text context="@title:menu">Tools</text>
<Action name="open_terminal"/>
+ <Action name="focus_terminal_panel"/>
<Action name="find_file" />
<Action name="show_filter_bar" />
<Action name="compare_files" />
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphin" version="28">
+<kpartgui name="dolphin" version="29">
<MenuBar>
<Menu name="file">
<Action name="new_menu" />
<Action name="show_filter_bar" />
<Action name="open_preferred_search_tool" />
<Action name="open_terminal" />
+ <Action name="focus_terminal_panel"/>
<Action name="compare_files" />
<Action name="change_remote_encoding" />
</Menu>
if (m_konsolePart) {
connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
m_terminalWidget = m_konsolePart->widget();
+ setFocusProxy(m_terminalWidget);
m_layout->addWidget(m_terminalWidget);
if (m_konsolePartMissingMessage) {
m_layout->removeWidget(m_konsolePartMissingMessage);
const QUrl url(QUrl::fromLocalFile(dir));
emit changeUrl(url);
}
+
+bool TerminalPanel::terminalHasFocus() const
+{
+ return m_terminalWidget->hasFocus();
+}
void goHome();
QString currentWorkingDirectory();
bool isHiddenInVisibleWindow() const;
+ bool terminalHasFocus() const;
bool hasProgramRunning() const;
QString runningProgramName() const;