diff options
author | Fabian Müller <fmueller@owncloud.com> | 2022-04-21 04:59:31 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2022-04-26 18:32:09 +0300 |
commit | d2d3cae83b8956d2b020e440beb17ae6d9af565d (patch) | |
tree | 076d2ec49bcdb509893bef434bf0ea31460f7119 /src/gui/folderman.cpp | |
parent | 8f1083da6ee709e59f6c715cc2c0097797e72fd5 (diff) |
Use folder wizard for manual sync config
This approach gives the user a lot more freedom.
The commit further moves the dialog logic out of the folder manager code, which allows us to clean up some API weirdness.
Diffstat (limited to 'src/gui/folderman.cpp')
-rw-r--r-- | src/gui/folderman.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 3ea1d0910..a21980bd4 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1411,7 +1411,7 @@ bool FolderMan::checkVfsAvailability(const QString &path, Vfs::Mode mode) const return unsupportedConfiguration(path) && Vfs::checkAvailability(path, mode); } -Folder *FolderMan::addFolderFromWizard(AccountStatePtr accountStatePtr, const QString &localFolder, const QString &remotePath, const QUrl &webDavUrl, const QString &displayName, Wizard::SyncMode syncMode) +Folder *FolderMan::addFolderFromWizard(AccountStatePtr accountStatePtr, const QString &localFolder, const QString &remotePath, const QUrl &webDavUrl, const QString &displayName, bool useVfs) { // first things first: we need to create the directory to make the sync engine happy (it will refuse to sync otherwise) QDir().mkdir(localFolder); @@ -1422,7 +1422,7 @@ Folder *FolderMan::addFolderFromWizard(AccountStatePtr accountStatePtr, const QS folderDefinition.setTargetPath(remotePath); folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles(); - if (syncMode == Wizard::SyncMode::UseVfs) { + if (useVfs) { folderDefinition.virtualFilesMode = bestAvailableVfsMode(); } @@ -1431,40 +1431,22 @@ Folder *FolderMan::addFolderFromWizard(AccountStatePtr accountStatePtr, const QS folderDefinition.navigationPaneClsid = QUuid::createUuid(); #endif - auto finalize = [this, accountStatePtr, syncMode, localFolder](const FolderDefinition &folderDefinition, const QStringList &blacklist = {}) { - auto f = addFolder(accountStatePtr, folderDefinition); + auto newFolder = addFolder(accountStatePtr, folderDefinition); - if (f) { - if (folderDefinition.virtualFilesMode != Vfs::Off && syncMode == Wizard::SyncMode::UseVfs) - f->setRootPinState(PinState::OnlineOnly); - - f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blacklist); + if (newFolder) { + if (folderDefinition.virtualFilesMode != Vfs::Off && useVfs) + newFolder->setRootPinState(PinState::OnlineOnly); - if (!OwncloudWizard::isConfirmBigFolderChecked()) { - // The user already accepted the selective sync dialog. everything is in the white list - f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, - QStringList() << QLatin1String("/")); - } - qCDebug(lcFolderMan) << "Local sync folder" << localFolder << "successfully created!"; - } else { - qCWarning(lcFolderMan) << "Failed to create local sync folder!"; + if (!OwncloudWizard::isConfirmBigFolderChecked()) { + // The user already accepted the selective sync dialog. everything is in the white list + newFolder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, + QStringList() << QLatin1String("/")); } - return f; - }; - - if (syncMode == Wizard::SyncMode::SelectiveSync) { - auto dialog = new SelectiveSyncDialog(accountStatePtr->account(), remotePath, reinterpret_cast<QDialog *>(ocApp()->gui()->settingsDialog())); - - connect(dialog, &SelectiveSyncDialog::finished, this, [finalize, folderDefinition, dialog]() { - auto folder = finalize(folderDefinition, dialog->createBlackList()); - }); - - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); + qCDebug(lcFolderMan) << "Local sync folder" << localFolder << "successfully created!"; } else { - return finalize(folderDefinition); + qCWarning(lcFolderMan) << "Failed to create local sync folder!"; } - return nullptr; + return newFolder; } } // namespace OCC |