mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
Folder: Add selective sync / ui related flags
supportsSelectiveSync(): clearer than !supportsVirtualFiles() and allows extra logic isVfsOnOffSwitchPending(): Somewhat awkward way of dealing with the phase between a user requesting vfs state to be switched and it actually happening
This commit is contained in:
parent
b91839b760
commit
5728256763
4 changed files with 25 additions and 5 deletions
|
@ -418,7 +418,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
|||
ac = menu->addAction(tr("Edit Ignored Files"));
|
||||
connect(ac, &QAction::triggered, this, &AccountSettings::slotEditCurrentIgnoredFiles);
|
||||
|
||||
if (!_ui->_folderList->isExpanded(index) && !folder->supportsVirtualFiles()) {
|
||||
if (!_ui->_folderList->isExpanded(index) && folder->supportsSelectiveSync()) {
|
||||
ac = menu->addAction(tr("Choose what to sync"));
|
||||
ac->setEnabled(folderConnected);
|
||||
connect(ac, &QAction::triggered, this, &AccountSettings::doExpand);
|
||||
|
|
|
@ -658,6 +658,11 @@ void Folder::setNewFilesAreVirtual(bool enabled)
|
|||
_journal.setPinStateForPath("", enabled ? PinState::OnlineOnly : PinState::AlwaysLocal);
|
||||
}
|
||||
|
||||
bool Folder::supportsSelectiveSync() const
|
||||
{
|
||||
return !supportsVirtualFiles() && !isVfsOnOffSwitchPending();
|
||||
}
|
||||
|
||||
void Folder::saveToSettings() const
|
||||
{
|
||||
// Remove first to make sure we don't get duplicates
|
||||
|
@ -1206,7 +1211,7 @@ void Folder::registerFolderWatcher()
|
|||
|
||||
bool Folder::supportsVirtualFiles() const
|
||||
{
|
||||
return _definition.virtualFilesMode != Vfs::Off;
|
||||
return _definition.virtualFilesMode != Vfs::Off && !isVfsOnOffSwitchPending();
|
||||
}
|
||||
|
||||
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, bool *cancel)
|
||||
|
|
|
@ -270,6 +270,13 @@ public:
|
|||
bool newFilesAreVirtual() const;
|
||||
void setNewFilesAreVirtual(bool enabled);
|
||||
|
||||
/** Whether user desires a switch that couldn't be executed yet, see member */
|
||||
bool isVfsOnOffSwitchPending() const { return _vfsOnOffPending; }
|
||||
void setVfsOnOffSwitchPending(bool pending) { _vfsOnOffPending = pending; }
|
||||
|
||||
/** Whether this folder should show selective sync ui */
|
||||
bool supportsSelectiveSync() const;
|
||||
|
||||
signals:
|
||||
void syncStateChange();
|
||||
void syncStarted();
|
||||
|
@ -456,6 +463,14 @@ private:
|
|||
*/
|
||||
bool _saveInFoldersWithPlaceholders = false;
|
||||
|
||||
/** Whether a vfs mode switch is pending
|
||||
*
|
||||
* When the user desires that vfs be switched on/off but it hasn't been
|
||||
* executed yet (syncs are still running), some options should be hidden,
|
||||
* disabled or different.
|
||||
*/
|
||||
bool _vfsOnOffPending = false;
|
||||
|
||||
/**
|
||||
* Watches this folder's local directory for changes.
|
||||
*
|
||||
|
|
|
@ -370,7 +370,7 @@ int FolderStatusModel::rowCount(const QModelIndex &parent) const
|
|||
auto info = infoForIndex(parent);
|
||||
if (!info)
|
||||
return 0;
|
||||
if (info->_folder && info->_folder->supportsVirtualFiles())
|
||||
if (info->_folder && !info->_folder->supportsSelectiveSync())
|
||||
return 0;
|
||||
if (info->hasLabel())
|
||||
return 1;
|
||||
|
@ -527,7 +527,7 @@ bool FolderStatusModel::hasChildren(const QModelIndex &parent) const
|
|||
if (!info)
|
||||
return false;
|
||||
|
||||
if (info->_folder && info->_folder->supportsVirtualFiles())
|
||||
if (info->_folder && !info->_folder->supportsSelectiveSync())
|
||||
return false;
|
||||
|
||||
if (!info->_fetched)
|
||||
|
@ -555,7 +555,7 @@ bool FolderStatusModel::canFetchMore(const QModelIndex &parent) const
|
|||
// Keep showing the error to the user, it will be hidden when the account reconnects
|
||||
return false;
|
||||
}
|
||||
if (info->_folder && info->_folder->supportsVirtualFiles()) {
|
||||
if (info->_folder && !info->_folder->supportsSelectiveSync()) {
|
||||
// Selective sync is hidden in that case
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue