]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Update the directory of the Terminal Panel if the current URL is not a
authorFrank Reininghaus <frank78ac@googlemail.com>
Sun, 17 May 2009 19:57:07 +0000 (19:57 +0000)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sun, 17 May 2009 19:57:07 +0000 (19:57 +0000)
"file:" URL, but is nevertheless local (e.g., "desktop:").

This fix is also applied to the new "Open external Terminal" action
which will be in KDE 4.3.

BUG: 167810

svn path=/trunk/KDE/kdebase/apps/; revision=969265

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

index 3ce1e9f2d80dcdef55689348c0cf06f9ec99f56e..f5d175482905c313169da8e40d6231e2f568d2f8 100644 (file)
@@ -813,7 +813,18 @@ void DolphinMainWindow::toggleShowMenuBar()
 
 void DolphinMainWindow::openTerminal()
 {
-    KToolInvocation::invokeTerminal(QString(), m_activeViewContainer->url().path());
+    QString dir(QDir::homePath());
+
+    // If the given directory is not local, it can still be the URL of an
+    // ioslave using UDS_LOCAL_PATH which to be converted first.
+    KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+
+    //If the URL is local after the above conversion, set the directory.
+    if (url.isLocalFile()) {
+        dir = url.toLocalFile();
+    }
+
+    KToolInvocation::invokeTerminal(QString(), dir);
 }
 
 void DolphinMainWindow::editSettings()
index ae5e45f097c091ebbe01462fcf43e7341c50bf53..8ee46d7a4f59a3e3dd05aea97a54daf67b204c48 100644 (file)
@@ -23,6 +23,7 @@
 #include <kde_terminal_interface_v2.h>
 #include <kparts/part.h>
 #include <kshell.h>
+#include <kio/netaccess.h>
 
 #include <QBoxLayout>
 #include <QShowEvent>
@@ -57,12 +58,13 @@ void TerminalPanel::setUrl(const KUrl& url)
     }
 
     Panel::setUrl(url);
+    KUrl mostLocalUrl = KIO::NetAccess::mostLocalUrl(url, 0);
     const bool sendInput = (m_terminal != 0)
                            && (m_terminal->foregroundProcessId() == -1)
                            && isVisible()
-                           && url.isLocalFile();
+                           && mostLocalUrl.isLocalFile();
     if (sendInput) {
-        m_terminal->sendInput("cd " + KShell::quoteArg(url.toLocalFile()) + '\n');
+        m_terminal->sendInput("cd " + KShell::quoteArg(mostLocalUrl.toLocalFile()) + '\n');
     }
 
 }