]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/terminal/terminalpanel.cpp
Fix style-issues in items when not using Oxygen
[dolphin.git] / src / panels / terminal / terminalpanel.cpp
index 61d80cbfa26fb17d0ba403a52f2ab57fbae7b3cc..b3bf0506f236c6e6312189aca3adb08a78ca7fcf 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "terminalpanel.h"
 
+#include <signal.h>
+
 #include <KPluginLoader>
 #include <KPluginFactory>
 #include <kde_terminal_interface_v2.h>
@@ -48,8 +50,19 @@ TerminalPanel::~TerminalPanel()
 
 void TerminalPanel::terminalExited()
 {
-    emit hideTerminalPanel();
     m_terminal = 0;
+    emit hideTerminalPanel();
+}
+
+void TerminalPanel::dockVisibilityChanged()
+{
+    // Only react when the DockWidget itself (not some parent) is hidden. This way we don't
+    // respond when e.g. Dolphin is minimized.
+    if (parentWidget() && parentWidget()->isHidden() &&
+        m_terminal && (m_terminal->foregroundProcessId() == -1)) {
+        // Make sure this terminal does not prevent unmounting any removable drives
+        changeDir(KUrl::fromPath("/"));
+    }
 }
 
 bool TerminalPanel::urlChanged()
@@ -113,11 +126,8 @@ void TerminalPanel::sendCdToTerminal(const QString& dir)
         // The TerminalV2 interface does not provide a way to delete the
         // current line before sending a new input. This is mandatory,
         // otherwise sending a 'cd x' to a existing 'rm -rf *' might
-        // result in data loss. As workaround Ctrl+C is send.
-        QString cancel;
-        cancel.append(QChar(3));
-        cancel.append(QChar('c'));
-        m_terminal->sendInput(cancel);
+        // result in data loss. As workaround SIGINT is send.
+        kill(m_terminal->terminalProcessId(), SIGINT);
     }
 
     m_terminal->sendInput("cd " + KShell::quoteArg(dir) + '\n');