mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
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>
This commit is contained in:
parent
70c2dc70a1
commit
7e5f81ea81
2 changed files with 47 additions and 0 deletions
|
@ -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;"
|
||||
|
|
|
@ -89,6 +89,7 @@ protected slots:
|
|||
void slotEnableVfsCurrentFolder();
|
||||
void slotDisableVfsCurrentFolder();
|
||||
void slotSetCurrentFolderAvailability(PinState state);
|
||||
void slotSetSubFolderAvailability(Folder *folder, const QString &path, PinState state);
|
||||
void slotFolderWizardAccepted();
|
||||
void slotFolderWizardRejected();
|
||||
void slotDeleteAccount();
|
||||
|
|
Loading…
Reference in a new issue