From b79794b75497a1856fee4332449db3d59203b541 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 21 Aug 2024 17:41:35 +0200 Subject: [PATCH] only empty top folders offer the menu entry to encrypt in the contextual menu shown in files explorer will show encrypt menu entry only for top folders that are non-encrypted and empty Signed-off-by: Matthieu Gallien --- src/gui/socketapi/socketapi.cpp | 12 +++++++++++- src/gui/socketapi/socketapi.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index 5f3358ea7c881..effac32dfd8af 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -1226,7 +1226,8 @@ void SocketApi::sendEncryptFolderCommandMenuEntries(const QFileInfo &fileInfo, !fileData.folder->accountState()->account() || !fileData.folder->accountState()->account()->capabilities().clientSideEncryptionAvailable() || !fileInfo.isDir() || - isE2eEncryptedPath) { + isE2eEncryptedPath || + !fileData.isFolderEmpty(fileInfo)) { return; } @@ -1312,6 +1313,15 @@ QString SocketApi::FileData::folderRelativePathNoVfsSuffix() const return result; } +bool SocketApi::FileData::isFolderEmpty(const QFileInfo &fileInfo) const +{ + if (fileInfo.isDir()) { + const auto nativeFolder = QDir{localPath}; + return nativeFolder.isEmpty(); + } + return false; +} + SyncFileStatus SocketApi::FileData::syncFileStatus() const { if (!folder) diff --git a/src/gui/socketapi/socketapi.h b/src/gui/socketapi/socketapi.h index 8662fde9b70a9..e97d9750708cb 100644 --- a/src/gui/socketapi/socketapi.h +++ b/src/gui/socketapi/socketapi.h @@ -99,6 +99,8 @@ private slots: // Relative path of the file locally, without any vfs suffix [[nodiscard]] QString folderRelativePathNoVfsSuffix() const; + [[nodiscard]] bool isFolderEmpty(const QFileInfo &fileInfo) const; + Folder *folder = nullptr; // Absolute path of the file locally. (May be a virtual file) QString localPath;