Skip to content

Commit

Permalink
Make the fp settings controller static
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Sep 4, 2023
1 parent 62e85b3 commit 9f4f1ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ private slots:
bool _menuShown = false;

QHash<QString, QMetaObject::Connection> _folderConnections;

#ifdef BUILD_FILE_PROVIDER_MODULE
Mac::FileProviderSettingsController _fpSettingsController;
#endif
};

} // namespace OCC
Expand Down
6 changes: 4 additions & 2 deletions src/gui/macOS/ui/fileprovidersettingscontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/gui/macOS/ui/fileprovidersettingscontroller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
NSUserDefaults *_userDefaults = nil;
};

FileProviderSettingsController *FileProviderSettingsController::instance()
{
static FileProviderSettingsController controller;
return &controller;
}

FileProviderSettingsController::~FileProviderSettingsController() = default;

FileProviderSettingsController::FileProviderSettingsController(QObject *parent)
Expand Down

0 comments on commit 9f4f1ac

Please sign in to comment.