X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d3496b12310d9fec0e52e537c341e87fcaa2f8b5..c8d8556950005dfd96ebdb41d2f43ad90356367c:/src/panels/terminal/terminalpanel.cpp diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index 61d80cbfa..b3bf0506f 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -19,6 +19,8 @@ #include "terminalpanel.h" +#include + #include #include #include @@ -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');