X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/016a3f91012ea9229bd1a28c576cfee78774e4d8..7bdfc2600908b72fbf790e6b96f8ca6de997931a:/src/terminalsidebarpage.cpp diff --git a/src/terminalsidebarpage.cpp b/src/terminalsidebarpage.cpp index 341b637bd..4a82599f0 100644 --- a/src/terminalsidebarpage.cpp +++ b/src/terminalsidebarpage.cpp @@ -22,13 +22,16 @@ #include #include #include +#include -#include +#include +#include TerminalSidebarPage::TerminalSidebarPage(QWidget* parent) : SidebarPage(parent), m_layout(0), - m_terminal(0) + m_terminal(0), + m_terminalWidget(0) { m_layout = new QVBoxLayout(this); m_layout->setMargin(0); @@ -38,29 +41,52 @@ TerminalSidebarPage::~TerminalSidebarPage() { } +QSize TerminalSidebarPage::sizeHint() const +{ + QSize size = SidebarPage::sizeHint(); + size.setHeight(200); + return size; +} + void TerminalSidebarPage::setUrl(const KUrl& url) { if (!SidebarPage::url().equals(url, KUrl::CompareWithoutTrailingSlash)) { SidebarPage::setUrl(url); if ((m_terminal != 0) && isVisible()) { - m_terminal->sendInput("cd " + url.path() + '\n'); + m_terminal->sendInput("cd " + KShell::quoteArg(url.path()) + '\n'); } } } +void TerminalSidebarPage::terminalExited() +{ + emit hideTerminalSidebarPage(); + + m_terminal = 0; +} + void TerminalSidebarPage::showEvent(QShowEvent* event) { + if (event->spontaneous()) { + SidebarPage::showEvent(event); + return; + } + if (m_terminal == 0) { - KLibFactory* factory = KLibLoader::self()->factory("libkonsolepart"); - KParts::Part* part = static_cast(factory->create(this, "KParts::ReadOnlyPart")); + KPluginFactory* factory = KPluginLoader("libkonsolepart").factory(); + KParts::ReadOnlyPart* part = factory ? (factory->create(this)) : 0; if (part != 0) { - m_layout->addWidget(part->widget()); + connect(part, SIGNAL(destroyed(QObject*)), this, SLOT(terminalExited())); + m_terminalWidget = part->widget(); + m_layout->addWidget(m_terminalWidget); m_terminal = qobject_cast(part); + m_terminal->showShellInDir(url().path()); } } if (m_terminal != 0) { - m_terminal->showShellInDir(url().path()); + m_terminal->sendInput("cd " + KShell::quoteArg(url().path()) + '\n'); m_terminal->sendInput("clear\n"); + m_terminalWidget->setFocus(); } SidebarPage::showEvent(event);