From b45a5ec5e2399bffd74e60e1e75bd8e9e325352f Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 17 Dec 2022 20:39:40 +0100 Subject: [PATCH] Fix path handling in Dolphin menu --- fileitemactionplugin/syncthingfileitemaction.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fileitemactionplugin/syncthingfileitemaction.cpp b/fileitemactionplugin/syncthingfileitemaction.cpp index 2dfaf6e..52d6beb 100644 --- a/fileitemactionplugin/syncthingfileitemaction.cpp +++ b/fileitemactionplugin/syncthingfileitemaction.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -116,7 +117,7 @@ QList SyncthingFileItemAction::createActions(const KFileItemListPrope // don't show any actions when remote files are selected return actions; } - paths << item.localPath(); + paths << QDir::cleanPath(item.localPath()); } // determine relevant Syncthing dirs @@ -125,15 +126,16 @@ QList SyncthingFileItemAction::createActions(const KFileItemListPrope QList detectedItems; const SyncthingDir *lastDir = nullptr; for (const SyncthingDir &dir : dirs) { - QStringRef dirPath(dir.pathWithoutTrailingSlash()); + auto dirPath = QDir::cleanPath(dir.path); + auto dirPathWithSlash = dirPath + QChar('/'); for (const QString &path : std::as_const(paths)) { if (path == dirPath) { lastDir = &dir; if (!detectedDirs.contains(lastDir)) { detectedDirs << lastDir; } - } else if (path.startsWith(dir.path)) { - detectedItems << SyncthingItem(&dir, path.mid(dir.path.size())); + } else if (path.startsWith(dirPathWithSlash)) { + detectedItems << SyncthingItem(&dir, path.mid(dirPathWithSlash.size())); lastDir = &dir; if (!containingDirs.contains(lastDir)) { containingDirs << lastDir;