diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index f327c6acef76d..24af2c4dd3c06 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -177,7 +177,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) #if defined(BUILD_FILE_PROVIDER_MODULE) if (Mac::FileProvider::fileProviderAvailable()) { - const auto fpSettingsWidget = _fpSettingsController.settingsViewWidget(); + const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget(); const auto fpSettingsLayout = new QVBoxLayout(_ui->fileProviderTab); fpSettingsLayout->setMargin(0); fpSettingsLayout->addWidget(fpSettingsWidget); diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h index 8f08cdecb20d7..b6a5cacb513b9 100644 --- a/src/gui/accountsettings.h +++ b/src/gui/accountsettings.h @@ -154,10 +154,6 @@ private slots: bool _menuShown = false; QHash _folderConnections; - -#ifdef BUILD_FILE_PROVIDER_MODULE - Mac::FileProviderSettingsController _fpSettingsController; -#endif }; } // namespace OCC diff --git a/src/gui/macOS/ui/fileprovidersettingscontroller.h b/src/gui/macOS/ui/fileprovidersettingscontroller.h index cf3fccfc29535..a8742d792eba1 100644 --- a/src/gui/macOS/ui/fileprovidersettingscontroller.h +++ b/src/gui/macOS/ui/fileprovidersettingscontroller.h @@ -26,12 +26,14 @@ class FileProviderSettingsController : public QObject Q_OBJECT public: - explicit FileProviderSettingsController(QObject *parent = nullptr); - ~FileProviderSettingsController() override; + static FileProviderSettingsController *instance(); [[nodiscard]] QQuickWidget *settingsViewWidget(); private: + explicit FileProviderSettingsController(QObject *parent = nullptr); + ~FileProviderSettingsController() override; + void instantiateSettingsWidget(); class MacImplementation; diff --git a/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm b/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm index fb02c31476ab7..a14cfa851aaf9 100644 --- a/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm +++ b/src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm @@ -54,6 +54,12 @@ NSUserDefaults *_userDefaults = nil; }; +FileProviderSettingsController *FileProviderSettingsController::instance() +{ + static FileProviderSettingsController controller; + return &controller; +} + FileProviderSettingsController::~FileProviderSettingsController() = default; FileProviderSettingsController::FileProviderSettingsController(QObject *parent)