From e43f627c9f4a1bf299732992965c2cd86c21c9cf Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 5 May 2023 10:44:10 +0800 Subject: [PATCH] Add forceLegacyImport property to accountmanager Signed-off-by: Claudio Cambra --- src/gui/accountmanager.cpp | 15 +++++++++++++++ src/gui/accountmanager.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 61b240985..d266bf54d 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -558,4 +558,19 @@ void AccountManager::addAccountState(AccountState *accountState) ptr->trySignIn(); emit accountAdded(accountState); } + +bool AccountManager::forceLegacyImport() const +{ + return _forceLegacyImport; +} + +void AccountManager::setForceLegacyImport(const bool forceLegacyImport) +{ + if (_forceLegacyImport == forceLegacyImport) { + return; + } + + _forceLegacyImport = forceLegacyImport; + Q_EMIT forceLegacyImportChanged(); +} } diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index 8f853df89..da5f3464a 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -26,6 +26,9 @@ namespace OCC { class AccountManager : public QObject { Q_OBJECT + + Q_PROPERTY(bool forceLegacyImport READ forceLegacyImport WRITE setForceLegacyImport NOTIFY forceLegacyImportChanged) + public: enum AccountsRestoreResult { AccountsRestoreFailure = 0, @@ -69,6 +72,12 @@ public: [[nodiscard]] AccountStatePtr accountFromUserId(const QString &id) const; + /** + * Returns whether the account setup will force an import of + * legacy clients' accounts (true), or ask first (false) + */ + [[nodiscard]] bool forceLegacyImport() const; + /** * Creates an account and sets up some basic handlers. * Does *not* add the account to the account manager just yet. @@ -97,11 +106,14 @@ public slots: /// Remove all accounts void shutdown(); + void setForceLegacyImport(const bool forceLegacyImport); + signals: void accountAdded(OCC::AccountState *account); void accountRemoved(OCC::AccountState *account); void accountSyncConnectionRemoved(OCC::AccountState *account); void removeAccountFolders(OCC::AccountState *account); + void forceLegacyImportChanged(); private: // saving and loading Account to settings @@ -120,5 +132,6 @@ private: QList _accounts; /// Account ids from settings that weren't read QSet _additionalBlockedAccountIds; + bool _forceLegacyImport = false; }; }