#include <klibloader.h>
#include <kde_terminal_interface.h>
#include <kparts/part.h>
+#include <kshell.h>
-#include <QVBoxLayout>
+#include <QBoxLayout>
+#include <QShowEvent>
TerminalSidebarPage::TerminalSidebarPage(QWidget* parent) :
SidebarPage(parent),
{
}
+QSize TerminalSidebarPage::sizeHint() const
+{
+ QSize size = SidebarPage::sizeHint();
+ size.setHeight(200);
+ return size;
+}
+
void TerminalSidebarPage::setUrl(const KUrl& url)
{
- SidebarPage::setUrl(url);
- // TODO: synchronize terminal
+ if (!SidebarPage::url().equals(url, KUrl::CompareWithoutTrailingSlash)) {
+ SidebarPage::setUrl(url);
+ if ((m_terminal != 0) && isVisible()) {
+ m_terminal->sendInput("cd " + KShell::quoteArg(url.path()) + '\n');
+ }
+ }
}
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<KParts::Part*>(factory->create(this, "KParts::ReadOnlyPart"));
+ KPluginFactory* factory = KPluginLoader("libkonsolepart").factory();
+ KParts::ReadOnlyPart* part = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : 0;
if (part != 0) {
- m_terminal = part->widget();
- m_layout->addWidget(m_terminal);
+ m_layout->addWidget(part->widget());
+ m_terminal = qobject_cast<TerminalInterface *>(part);
}
}
+ if (m_terminal != 0) {
+ m_terminal->showShellInDir(url().path());
+ m_terminal->sendInput("clear\n");
+ }
+
SidebarPage::showEvent(event);
}