mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-21 01:11:21 +00:00
Add action for focusing Terminal Panel
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
This commit is contained in:
parent
8b0c12a59c
commit
69838a1cdd
|
@ -1554,6 +1554,12 @@ void DolphinMainWindow::setupActions()
|
|||
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
|
||||
|
||||
|
@ -2305,6 +2311,22 @@ bool DolphinMainWindow::eventFilter(QObject* obj, QEvent* event)
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -365,6 +365,9 @@ private slots:
|
|||
/** Opens a terminal window for the current location. */
|
||||
void openTerminal();
|
||||
|
||||
/** Focus a Terminal Panel. */
|
||||
void focusTerminalPanel();
|
||||
|
||||
/** Opens the settings dialog for Dolphin. */
|
||||
void editSettings();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!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"/>
|
||||
|
@ -39,6 +39,7 @@
|
|||
</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" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="dolphin" version="28">
|
||||
<kpartgui name="dolphin" version="29">
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Action name="new_menu" />
|
||||
|
@ -56,6 +56,7 @@
|
|||
<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>
|
||||
|
|
|
@ -147,6 +147,7 @@ void TerminalPanel::showEvent(QShowEvent* event)
|
|||
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);
|
||||
|
@ -263,3 +264,8 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir)
|
|||
const QUrl url(QUrl::fromLocalFile(dir));
|
||||
emit changeUrl(url);
|
||||
}
|
||||
|
||||
bool TerminalPanel::terminalHasFocus() const
|
||||
{
|
||||
return m_terminalWidget->hasFocus();
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
void goHome();
|
||||
QString currentWorkingDirectory();
|
||||
bool isHiddenInVisibleWindow() const;
|
||||
bool terminalHasFocus() const;
|
||||
bool hasProgramRunning() const;
|
||||
QString runningProgramName() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue