From: Peter Penz Date: Mon, 7 May 2007 05:33:49 +0000 (+0000) Subject: synchronize embedded terminal with the current directory X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/ca0a0438eaebe7107bdf054b23c98478018d6fee synchronize embedded terminal with the current directory svn path=/trunk/KDE/kdebase/apps/; revision=661960 --- diff --git a/src/terminalsidebarpage.cpp b/src/terminalsidebarpage.cpp index 841959097..2d2b3a5bb 100644 --- a/src/terminalsidebarpage.cpp +++ b/src/terminalsidebarpage.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -40,9 +41,12 @@ TerminalSidebarPage::~TerminalSidebarPage() void TerminalSidebarPage::setUrl(const KUrl& url) { - SidebarPage::setUrl(url); - // TODO: synchronize terminal - // m_terminal->showShellInDir(...); + if (!SidebarPage::url().equals(url, KUrl::CompareWithoutTrailingSlash)) { + SidebarPage::setUrl(url); + if ((m_terminal != 0) && isVisible()) { + m_terminal->showShellInDir(url.path()); + } + } } void TerminalSidebarPage::showEvent(QShowEvent* event) @@ -52,13 +56,19 @@ void TerminalSidebarPage::showEvent(QShowEvent* event) KParts::Part* part = static_cast(factory->create(this, "KParts::ReadOnlyPart")); if (part != 0) { m_layout->addWidget(part->widget()); - } - // TODO: port to KDE4 - //TerminalInterface* m_terminal = static_cast(part->qt_cast("TerminalInterface")); - // like this? - //m_terminal = qobject_cast(part); + // TODO: in KDE3 the following code worked: + // m_terminal = static_cast(part->qt_cast("TerminalInterface")); + // which does not work anymore in Qt4. As temporary workaround is + // included directly: + m_terminal = static_cast(reinterpret_cast(part)); + } + } + if (m_terminal != 0) { + m_terminal->showShellInDir(url().path()); + m_terminal->sendInput("clear\n"); } + SidebarPage::showEvent(event); }