Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2022-07-01 17:41:07 +0300
committerHannah von Reth <vonreth@kde.org>2022-07-05 11:07:55 +0300
commit4806e7459dd5b4a710b1ebfee4be22d8ac22e916 (patch)
tree55a23ace1e8817cde7b8e758afe4f0c3d81b0f62 /src/gui
parent38eb71b0a7a705bfe50f1d958dcd1d45f4a3bbb8 (diff)
Disable context menu on root
Fixes: #8595
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/socketapi/socketapi.cpp119
-rw-r--r--src/gui/socketapi/socketapi.h2
2 files changed, 67 insertions, 54 deletions
diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp
index 08dc99c0b..fcec8cb88 100644
--- a/src/gui/socketapi/socketapi.cpp
+++ b/src/gui/socketapi/socketapi.cpp
@@ -970,6 +970,11 @@ QString SocketApi::FileData::folderRelativePathNoVfsSuffix() const
return folderRelativePath;
}
+bool OCC::SocketApi::FileData::isSyncFolder() const
+{
+ return folderRelativePath.isEmpty();
+}
+
SyncFileStatus SocketApi::FileData::syncFileStatus() const
{
if (!folder)
@@ -1014,71 +1019,77 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
// Some options only show for single files
if (files.size() == 1) {
const FileData fileData = FileData::get(files.first());
- const auto record = fileData.journalRecord();
- const bool isOnTheServer = record.isValid();
- const auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:");
+ if (!fileData.isSyncFolder()) {
+ const auto record = fileData.journalRecord();
+ const bool isOnTheServer = record.isValid();
+ const auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:");
- if (fileData.folder && fileData.folder->accountState()->isConnected()) {
- sendSharingContextMenuOptions(fileData, listener);
+ if (fileData.folder && fileData.folder->accountState()->isConnected()) {
+ sendSharingContextMenuOptions(fileData, listener);
- const auto &capabilities = folder->accountState()->account()->capabilities();
- if (capabilities.privateLinkPropertyAvailable()) {
- listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
- }
- // Add link to versions pane if possible
- if (capabilities.versioningEnabled()
- && capabilities.privateLinkDetailsParamAvailable()
- && isOnTheServer
- && !record.isDirectory()) {
- listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK_VERSIONS") + flagString + tr("Show file versions in browser"));
- }
+ const auto &capabilities = fileData.folder->accountState()->account()->capabilities();
+ if (capabilities.privateLinkPropertyAvailable()) {
+ listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
+ }
+ // Add link to versions pane if possible
+ if (capabilities.versioningEnabled()
+ && capabilities.privateLinkDetailsParamAvailable()
+ && isOnTheServer
+ && !record.isDirectory()) {
+ listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK_VERSIONS") + flagString + tr("Show file versions in browser"));
+ }
- // Conflict files get conflict resolution actions
- const bool isConflict = Utility::isConflictFile(fileData.folderRelativePath);
- if (isConflict || !isOnTheServer) {
- // Check whether this new file is in a read-only directory
- const QFileInfo fileInfo(fileData.localPath);
- const auto parentDir = fileData.parentFolder();
- const auto parentRecord = parentDir.journalRecord();
- const bool canAddToDir = !parentRecord._remotePerm.isNull()
- && ((fileInfo.isFile() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddFile))
- || (fileInfo.isDir() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)));
- const bool canChangeFile =
- !isOnTheServer
- || (record._remotePerm.hasPermission(RemotePermissions::CanDelete)
- && record._remotePerm.hasPermission(RemotePermissions::CanMove)
- && record._remotePerm.hasPermission(RemotePermissions::CanRename));
-
- if (isConflict && canChangeFile) {
- if (canAddToDir) {
- if (isOnTheServer) {
- // Conflict file that is already uploaded
- listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Rename..."));
+ // Conflict files get conflict resolution actions
+ const bool isConflict = Utility::isConflictFile(fileData.folderRelativePath);
+ if (isConflict || !isOnTheServer) {
+ // Check whether this new file is in a read-only directory
+ const QFileInfo fileInfo(fileData.localPath);
+ const auto parentDir = fileData.parentFolder();
+ const auto parentRecord = parentDir.journalRecord();
+ const bool canAddToDir = !parentRecord._remotePerm.isNull()
+ && ((fileInfo.isFile() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddFile))
+ || (fileInfo.isDir() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)));
+ const bool canChangeFile =
+ !isOnTheServer
+ || (record._remotePerm.hasPermission(RemotePermissions::CanDelete)
+ && record._remotePerm.hasPermission(RemotePermissions::CanMove)
+ && record._remotePerm.hasPermission(RemotePermissions::CanRename));
+
+ if (isConflict && canChangeFile) {
+ if (canAddToDir) {
+ if (isOnTheServer) {
+ // Conflict file that is already uploaded
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Rename..."));
+ } else {
+ // Local-only conflict file
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Rename and upload..."));
+ }
} else {
- // Local-only conflict file
- listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Rename and upload..."));
+ if (isOnTheServer) {
+ // Uploaded conflict file in read-only directory
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move and rename..."));
+ } else {
+ if (isOnTheServer) {
+ // Uploaded conflict file in read-only directory
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move and rename..."));
+ } else {
+ // Local-only conflict file in a read-only dir
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move, rename and upload..."));
+ }
+ }
+ listener->sendMessage(QLatin1String("MENU_ITEM:DELETE_ITEM::") + tr("Delete local changes"));
}
- } else {
- if (isOnTheServer) {
- // Uploaded conflict file in read-only directory
- listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move and rename..."));
- } else {
- // Local-only conflict file in a read-only dir
- listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move, rename and upload..."));
+
+ // File in a read-only directory?
+ if (!isConflict && !isOnTheServer && !canAddToDir) {
+ listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move and upload..."));
+ listener->sendMessage(QLatin1String("MENU_ITEM:DELETE_ITEM::") + tr("Delete"));
}
}
- listener->sendMessage(QLatin1String("MENU_ITEM:DELETE_ITEM::") + tr("Delete local changes"));
- }
-
- // File in a read-only directory?
- if (!isConflict && !isOnTheServer && !canAddToDir) {
- listener->sendMessage(QLatin1String("MENU_ITEM:MOVE_ITEM::") + tr("Move and upload..."));
- listener->sendMessage(QLatin1String("MENU_ITEM:DELETE_ITEM::") + tr("Delete"));
}
}
}
}
-
// File availability actions
if (folder
&& folder->isReady()
diff --git a/src/gui/socketapi/socketapi.h b/src/gui/socketapi/socketapi.h
index f83aa9c9d..43c71cafe 100644
--- a/src/gui/socketapi/socketapi.h
+++ b/src/gui/socketapi/socketapi.h
@@ -94,6 +94,8 @@ private:
QString folderRelativePath;
// Path of the file on the server (In case of virtual file, it points to the actual file)
QString serverRelativePath;
+
+ bool isSyncFolder() const;
};
void broadcastMessage(const QString &msg, bool doWait = false);