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

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@nextcloud.com>2020-12-10 14:35:16 +0300
committerKevin Ottens <kevin.ottens@nextcloud.com>2020-12-15 12:59:24 +0300
commit7e5f81ea81d2f06522920e2eeedf2343c05b66f3 (patch)
treea0d7ac6031246da27384e37cfa62cefed395fa1f /src/gui/accountsettings.cpp
parent70c2dc70a1257c77dafb30dcd58366125a5405e9 (diff)
Allow to control availability of folders in the settings dialog
It felt odd to be able to control the encryption status in the settings dialog but not the availability. Also availability was controllable on the root, so let's make it widely available. Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
Diffstat (limited to 'src/gui/accountsettings.cpp')
-rw-r--r--src/gui/accountsettings.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 69eca9563..e524f9dda 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -403,6 +403,39 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
ac = menu.addAction(tr("Edit Ignored Files"));
connect(ac, &QAction::triggered, this, &AccountSettings::slotEditCurrentLocalIgnoredFiles);
+ const auto folder = info->_folder;
+ if (folder && folder->virtualFilesEnabled()) {
+ auto availabilityMenu = menu.addMenu(tr("Availability"));
+
+ // Has '/' suffix convention for paths here but VFS and
+ // sync engine expects no such suffix
+ Q_ASSERT(info->_path.endsWith('/'));
+ const auto remotePath = info->_path.chopped(1);
+
+ // It might be an E2EE mangled path, so let's try to demangle it
+ const auto journal = folder->journalDb();
+ SyncJournalFileRecord rec;
+ journal->getFileRecordByE2eMangledName(remotePath, &rec);
+
+ const auto path = rec.isValid() ? rec._path : remotePath;
+
+ auto availability = folder->vfs().availability(path);
+ if (availability) {
+ ac = availabilityMenu->addAction(Utility::vfsCurrentAvailabilityText(*availability));
+ ac->setEnabled(false);
+ }
+
+ ac = availabilityMenu->addAction(Utility::vfsPinActionText());
+ ac->setEnabled(!availability || *availability != VfsItemAvailability::AlwaysLocal);
+ connect(ac, &QAction::triggered, this, [this, folder, path] { slotSetSubFolderAvailability(folder, path, PinState::AlwaysLocal); });
+
+ ac = availabilityMenu->addAction(Utility::vfsFreeSpaceActionText());
+ ac->setEnabled(!availability
+ || !(*availability == VfsItemAvailability::OnlineOnly
+ || *availability == VfsItemAvailability::AllDehydrated));
+ connect(ac, &QAction::triggered, this, [this, folder, path] { slotSetSubFolderAvailability(folder, path, PinState::OnlineOnly); });
+ }
+
menu.exec(QCursor::pos());
}
@@ -815,6 +848,19 @@ void AccountSettings::slotSetCurrentFolderAvailability(PinState state)
folder->scheduleThisFolderSoon();
}
+void AccountSettings::slotSetSubFolderAvailability(Folder *folder, const QString &path, PinState state)
+{
+ Q_ASSERT(folder && folder->virtualFilesEnabled());
+ Q_ASSERT(!path.endsWith('/'));
+
+ // Update the pin state on all items
+ folder->vfs().setPinState(path, state);
+
+ // Trigger sync
+ folder->schedulePathForLocalDiscovery(path);
+ folder->scheduleThisFolderSoon();
+}
+
void AccountSettings::showConnectionLabel(const QString &message, QStringList errors)
{
const QString errStyle = QLatin1String("color:#ffffff; background-color:#bb4d4d;padding:5px;"