+ if (dir == m_konsolePartCurrentDirectory) {
+ m_clearTerminal = false;
+ return;
+ }
+
+#ifndef Q_OS_WIN
+ if (!m_clearTerminal) {
+ // 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 SIGINT is sent.
+ const int processId = m_terminal->terminalProcessId();
+ if (processId > 0) {
+ kill(processId, SIGINT);
+ }
+ }
+#endif
+
+ m_terminal->sendInput(" cd " + KShell::quoteArg(dir) + '\n');
+
+ // We want to ignore the currentDirectoryChanged(QString) signal, which we will receive after
+ // the directory change, because this directory change is not caused by a "cd" command that the
+ // user entered in the panel. Therefore, we have to remember 'dir'. Note that it could also be
+ // a symbolic link -> remember the 'canonical' path.
+ if (addToHistory == HistoryPolicy::AddToHistory)
+ m_sendCdToTerminalHistory.enqueue(QDir(dir).canonicalPath());
+
+ if (m_clearTerminal) {
+ m_terminal->sendInput(QStringLiteral(" clear\n"));
+ m_clearTerminal = false;
+ }
+}
+
+void TerminalPanel::sendCdToTerminalKIOFuse(const QUrl &url) {
+ // URL isn't local, only hope for the terminal to be in sync with the
+ // DolphinView is to mount the remote URL in KIOFuse and point to it.
+ // If we can't do that for any reason, silently fail.
+ auto reply = m_kiofuseInterface.mountUrl(url.toString());
+ QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher(reply, this);
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher* watcher) {
+ watcher->deleteLater();
+ if (!reply.isError()) {
+ // Successfully mounted, point to the KIOFuse equivalent path.
+ sendCdToTerminal(reply.value());
+ }
+ });