]> cloud.milkyroute.net Git - dolphin.git/commitdiff
TerminalPanel: better check if terminal needs to change its currentWorkingDirectory...
authorMéven Car <meven@kde.org>
Thu, 20 Apr 2023 16:15:56 +0000 (18:15 +0200)
committerMéven Car <meven@kde.org>
Fri, 21 Apr 2023 13:32:58 +0000 (15:32 +0200)
CCBUG: 467403

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

index 76b8ded6f5a7045f0f4f4464811c8ac0a34a539b..f043df310c23116fb907f29e384f0d15611e254f 100644 (file)
@@ -1504,7 +1504,7 @@ void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString &mo
         setViewsToHomeIfMountPathOpen(mountPath);
     });
 
-    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsParentOf(mountPath)) {
         m_tearDownFromPlacesRequested = true;
         m_terminalPanel->goHome();
         // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
@@ -1519,7 +1519,7 @@ void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString &mo
         setViewsToHomeIfMountPathOpen(mountPath);
     });
 
-    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsParentOf(mountPath)) {
         m_tearDownFromPlacesRequested = false;
         m_terminalPanel->goHome();
     }
index 53464e620aa0f45c0e962d7cac57e30ff80a612e..49eb42c1dca577f06f60e38471513b1edd31247d 100644 (file)
@@ -54,12 +54,12 @@ void TerminalPanel::goHome()
     sendCdToTerminal(QDir::homePath(), HistoryPolicy::SkipHistory);
 }
 
-QString TerminalPanel::currentWorkingDirectory()
+bool TerminalPanel::currentWorkingDirectoryIsParentOf(const QString &path) const
 {
     if (m_terminal) {
-        return m_terminal->currentWorkingDirectory();
+        return m_terminal->currentWorkingDirectory().startsWith(path);
     }
-    return QString();
+    return false;
 }
 
 void TerminalPanel::terminalExited()
index a1b7af03aa31b43986629a4dbe96100f763166ec..49fd1b70d77fc70a495c843a9a2a4f9ff7229c96 100644 (file)
@@ -45,7 +45,7 @@ public:
      *        home when an unmounting request is received.
      */
     void goHome();
-    QString currentWorkingDirectory();
+    bool currentWorkingDirectoryIsParentOf(const QString &path) const;
     bool isHiddenInVisibleWindow() const;
     bool terminalHasFocus() const;
     bool hasProgramRunning() const;