From: Frank Reininghaus Date: Sun, 17 May 2009 19:57:07 +0000 (+0000) Subject: Update the directory of the Terminal Panel if the current URL is not a X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/07ad9b3726d8d16041cd8bc6b394eaa784c063b1 Update the directory of the Terminal Panel if the current URL is not a "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 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3ce1e9f2d..f5d175482 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -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() diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index ae5e45f09..8ee46d7a4 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -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'); } }