]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Set the focus to the active view, after leaving the terminal panel
authorAdrián Chaves Fernández (Gallaecio) <adriyetichaves@gmail.com>
Thu, 18 Jan 2018 17:49:54 +0000 (18:49 +0100)
committerAdrián Chaves Fernández (Gallaecio) <adriyetichaves@gmail.com>
Thu, 18 Jan 2018 17:51:27 +0000 (18:51 +0100)
Summary:
BUG: 298467

Set the focus to the active view, after leaving the terminal panel.

This is a fork of the patch at https://git.reviewboard.kde.org/r/116118/ by @emmanuelp which should fix the issue with the original patch reported by Frank Reininghaus.

Test Plan: Works for me.

Reviewers: #dolphin, emmanuelp, ngraham

Reviewed By: #dolphin, ngraham

Subscribers: ngraham, emmanuelp

Differential Revision: https://phabricator.kde.org/D9955

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/panels/terminal/terminalpanel.cpp
src/panels/terminal/terminalpanel.h

index 7b3d63fd6e999ef5a71f77d9a29b4d86a11ecd6a..ad19523613cdfb55b2cdc59ce80b5f3cc51a7a20 100644 (file)
@@ -629,6 +629,13 @@ void DolphinMainWindow::togglePanelLockState()
     GeneralSettings::setLockPanels(newLockState);
 }
 
+void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
+{
+    if (m_terminalPanel->isHiddenInVisibleWindow()) {
+        m_activeViewContainer->view()->setFocus();
+    }
+}
+
 void DolphinMainWindow::goBack()
 {
     KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
@@ -1297,6 +1304,8 @@ void DolphinMainWindow::setupDockWidgets()
         connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
         connect(terminalDock, &DolphinDockWidget::visibilityChanged,
                 m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
+        connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+                this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
 
         QAction* terminalAction = terminalDock->toggleViewAction();
         createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
index c7a06c00a9e67f9c5c22888709592cb47564f2b3..01746169bd16de848e6e161fd48eff17e2fc19db 100644 (file)
@@ -261,6 +261,12 @@ private slots:
      */
     void togglePanelLockState();
 
+    /**
+     * Is invoked if the Terminal panel got visible/invisible and takes care
+     * that the active view has the focus if the Terminal panel is invisible.
+     */
+    void slotTerminalPanelVisibilityChanged();
+
     /** Goes back one step of the URL history. */
     void goBack();
 
index c205374cdc87e7437cf159543c8d6f2c38dfcfa0..849d3f8c903965f6e62e5dfd138c76bb1726abca 100644 (file)
@@ -73,12 +73,19 @@ void TerminalPanel::terminalExited()
     emit hideTerminalPanel();
 }
 
+bool TerminalPanel::isHiddenInVisibleWindow()
+{
+    return parentWidget()
+        && parentWidget()->isHidden()
+        && m_terminal
+        && (m_terminal->foregroundProcessId() == -1);
+}
+
 void TerminalPanel::dockVisibilityChanged()
 {
     // Only react when the DockWidget itself (not some parent) is hidden. This way we don't
     // respond when e.g. Dolphin is minimized.
-    if (parentWidget() && parentWidget()->isHidden() &&
-        m_terminal && (m_terminal->foregroundProcessId() == -1)) {
+    if (isHiddenInVisibleWindow()) {
         // Make sure that the following "cd /" command will not affect the view.
         disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)),
                    this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString)));
index 4c0b93a17a936fcacbecafd9f79ad8529e811374..edaa2a6f3bec0f4944cd13f4d474faf271427d23 100644 (file)
@@ -54,6 +54,7 @@ public:
      */
     void goHome();
     QString currentWorkingDirectory();
+    bool isHiddenInVisibleWindow();
 
 public slots:
     void terminalExited();