diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -272,6 +272,7 @@
qt5_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/dolphinmainwindow.h org.kde.DolphinMainWindow.xml)
qt5_add_dbus_adaptor(dolphinstatic_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.DolphinMainWindow.xml dolphinmainwindow.h DolphinMainWindow)
qt5_add_dbus_interface(dolphinstatic_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.DolphinMainWindow.xml dolphinmainwindowinterface)
+qt5_add_dbus_interface(dolphinstatic_SRCS panels/terminal/org.kde.KIOFuse.VFS.xml kiofuse_interface)
add_library(dolphinstatic STATIC ${dolphinstatic_SRCS})
diff --git a/src/panels/terminal/org.kde.KIOFuse.VFS.xml b/src/panels/terminal/org.kde.KIOFuse.VFS.xml
new file mode 100644
--- /dev/null
+++ b/src/panels/terminal/org.kde.KIOFuse.VFS.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h
--- a/src/panels/terminal/terminalpanel.h
+++ b/src/panels/terminal/terminalpanel.h
@@ -21,6 +21,7 @@
#define TERMINALPANEL_H
#include "panels/panel.h"
+#include "kiofuse_interface.h"
#include
@@ -101,6 +102,7 @@
KParts::ReadOnlyPart* m_konsolePart;
QString m_konsolePartCurrentDirectory;
QQueue m_sendCdToTerminalHistory;
+ org::kde::KIOFuse::VFS m_kiofuseInterface;
};
#endif // TERMINALPANEL_H
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp
--- a/src/panels/terminal/terminalpanel.cpp
+++ b/src/panels/terminal/terminalpanel.cpp
@@ -18,13 +18,15 @@
***************************************************************************/
#include "terminalpanel.h"
+#include "kiofuse_interface.h"
#include
#include
#include
#include
#include
#include
+#include
#include
#include
#include
@@ -50,7 +52,10 @@
m_konsolePartMissingMessage(nullptr),
m_konsolePart(nullptr),
m_konsolePartCurrentDirectory(),
- m_sendCdToTerminalHistory()
+ m_sendCdToTerminalHistory(),
+ m_kiofuseInterface(QStringLiteral("org.kde.KIOFuse"),
+ QStringLiteral("/org/kde/KIOFuse"),
+ QDBusConnection::sessionBus())
{
m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
@@ -244,6 +249,19 @@
const QUrl url = statJob->mostLocalUrl();
if (url.isLocalFile()) {
sendCdToTerminal(url.toLocalFile());
+ } else {
+ // 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());
+ }
+ });
}
m_mostLocalUrlJob = nullptr;
@@ -261,8 +279,31 @@
}
}
+ // User may potentially be browsing inside a KIOFuse mount.
+ // If so lets try and change the DolphinView to point to the remote URL equivalent.
+ // instead of into the KIOFuse mount itself (which can cause performance issues!)
const QUrl url(QUrl::fromLocalFile(dir));
- emit changeUrl(url);
+
+ KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(m_konsolePartCurrentDirectory);
+ if (mountPoint && mountPoint->mountType() != QStringLiteral("fuse.kio-fuse")) {
+ // Not in KIOFUse mount, so just switch to the corresponding URL.
+ emit changeUrl(url);
+ return;
+ }
+
+ auto reply = m_kiofuseInterface.remoteUrl(m_konsolePartCurrentDirectory);
+ QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher(reply, this);
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher* watcher) {
+ watcher->deleteLater();
+ if (reply.isError()) {
+ // KIOFuse errored out... just show the normal URL
+ emit changeUrl(url);
+ } else {
+ // Our location happens to be in a KIOFuse mount and is mounted.
+ // Let's change the DolphinView to point to the remote URL equivalent.
+ emit changeUrl(QUrl::fromUserInput(reply.value()));
+ }
+ });
}
bool TerminalPanel::terminalHasFocus() const