]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/terminalsidebarpage.cpp
There are some extractable strings in subdirs too.
[dolphin.git] / src / terminalsidebarpage.cpp
index d3673b164e205acc954273c2bb101030e9d2f376..4749e7714c49fbf9eb634d533c4628a3ba2d2ced 100644 (file)
@@ -30,7 +30,8 @@
 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);
@@ -49,14 +50,23 @@ QSize TerminalSidebarPage::sizeHint() const
 
 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 " + KShell::quoteArg(url.path()) + '\n');
-        }
+    if (!url.isValid() || (url == SidebarPage::url())) {
+        return;
+    }
+
+    SidebarPage::setUrl(url);
+    if ((m_terminal != 0) && isVisible() && url.isLocalFile()) {
+        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()) {
@@ -65,16 +75,20 @@ void TerminalSidebarPage::showEvent(QShowEvent* event)
     }
 
     if (m_terminal == 0) {
-        KPluginFactory* factory = KLibLoader::self()->factory("libkonsolepart");
+        KPluginFactory* factory = KPluginLoader("libkonsolepart").factory();
         KParts::ReadOnlyPart* part = factory ? (factory->create<KParts::ReadOnlyPart>(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<TerminalInterface *>(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);