#include "terminalpanel.h"
+#include <signal.h>
+
#include <KPluginLoader>
#include <KPluginFactory>
#include <kde_terminal_interface_v2.h>
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()
// 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');