diff --git a/src/gui/macOS/ui/fileprovidersettingscontroller.h b/src/gui/macOS/ui/fileprovidersettingscontroller.h index a8f0f876e772a..15ff403fb7db8 100644 --- a/src/gui/macOS/ui/fileprovidersettingscontroller.h +++ b/src/gui/macOS/ui/fileprovidersettingscontroller.h @@ -31,6 +31,8 @@ class FileProviderSettingsController : public QObject [[nodiscard]] QQuickWidget *settingsViewWidget(QWidget *const parent = nullptr, const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView); + [[nodiscard]] Q_INVOKABLE bool vfsEnabledForAccount(const QString &userIdAtHost); + private: explicit FileProviderSettingsController(QObject *parent = nullptr); ~FileProviderSettingsController() override; diff --git a/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm b/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm index 2d34b2c442de6..512eb7f11ff66 100644 --- a/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm +++ b/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm @@ -27,6 +27,9 @@ // FileProviderSettingsPage properties -- make sure they match up in QML file! constexpr auto fpSettingsControllerProp = "FileProviderSettingsController"; + +// NSUserDefaults entries +constexpr auto enabledAccountsSettingsKey = "enabledAccounts"; } // namespace namespace OCC { @@ -49,7 +52,29 @@ [_userDefaults release]; }; + QStringList enabledAccounts() const + { + QStringList qEnabledAccounts; + NSArray *const enabledAccounts = nsEnabledAccounts(); + for (NSString *const userIdAtHostString in enabledAccounts) { + qEnabledAccounts.append(QString::fromNSString(userIdAtHostString)); + } + return qEnabledAccounts; + } + + bool vfsEnabledForAccount(const QString &userIdAtHost) const + { + NSArray *const vfsEnabledAccounts = nsEnabledAccounts(); + return [vfsEnabledAccounts containsObject:userIdAtHost.toNSString()]; + } + private: + NSArray *nsEnabledAccounts() const + { + NSString *const accsKey = [NSString stringWithUTF8String:enabledAccountsSettingsKey]; + return (NSArray *)[_userDefaults objectForKey:accsKey]; + } + FileProviderSettingsController *q = nullptr; NSUserDefaults *_userDefaults = nil; }; @@ -77,6 +102,11 @@ return settingsViewWidget; } +bool FileProviderSettingsController::vfsEnabledForAccount(const QString &userIdAtHost) +{ + return d->vfsEnabledForAccount(userIdAtHost); +} + } // namespace Mac } // namespace OCC