mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Treat FileProviderSettingsController::settingsViewWidget as a factory method
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
20f89c6999
commit
94ce3da9c5
3 changed files with 12 additions and 22 deletions
|
@ -199,11 +199,12 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
||||||
|
|
||||||
#if defined(BUILD_FILE_PROVIDER_MODULE)
|
#if defined(BUILD_FILE_PROVIDER_MODULE)
|
||||||
if (Mac::FileProvider::fileProviderAvailable()) {
|
if (Mac::FileProvider::fileProviderAvailable()) {
|
||||||
const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget();
|
const auto fileProviderTab = _ui->fileProviderTab;
|
||||||
const auto fpSettingsLayout = new QVBoxLayout(_ui->fileProviderTab);
|
const auto fpSettingsLayout = new QVBoxLayout(fileProviderTab);
|
||||||
|
const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget(fileProviderTab);
|
||||||
fpSettingsLayout->setMargin(0);
|
fpSettingsLayout->setMargin(0);
|
||||||
fpSettingsLayout->addWidget(fpSettingsWidget);
|
fpSettingsLayout->addWidget(fpSettingsWidget);
|
||||||
_ui->fileProviderTab->setLayout(fpSettingsLayout);
|
fileProviderTab->setLayout(fpSettingsLayout);
|
||||||
} else {
|
} else {
|
||||||
disguiseTabWidget();
|
disguiseTabWidget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,18 +28,15 @@ class FileProviderSettingsController : public QObject
|
||||||
public:
|
public:
|
||||||
static FileProviderSettingsController *instance();
|
static FileProviderSettingsController *instance();
|
||||||
|
|
||||||
[[nodiscard]] QQuickWidget *settingsViewWidget();
|
[[nodiscard]] QQuickWidget *settingsViewWidget(QWidget *const parent = nullptr,
|
||||||
|
const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit FileProviderSettingsController(QObject *parent = nullptr);
|
explicit FileProviderSettingsController(QObject *parent = nullptr);
|
||||||
~FileProviderSettingsController() override;
|
~FileProviderSettingsController() override;
|
||||||
|
|
||||||
void instantiateSettingsWidget();
|
|
||||||
|
|
||||||
class MacImplementation;
|
class MacImplementation;
|
||||||
std::unique_ptr<MacImplementation> d;
|
std::unique_ptr<MacImplementation> d;
|
||||||
|
|
||||||
std::unique_ptr<QQuickWidget> _settingsViewWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Mac
|
} // Mac
|
||||||
|
|
|
@ -68,21 +68,13 @@ FileProviderSettingsController::FileProviderSettingsController(QObject *parent)
|
||||||
d = std::make_unique<FileProviderSettingsController::MacImplementation>(this);
|
d = std::make_unique<FileProviderSettingsController::MacImplementation>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileProviderSettingsController::instantiateSettingsWidget()
|
QQuickWidget *FileProviderSettingsController::settingsViewWidget(QWidget *const parent, const QQuickWidget::ResizeMode resizeMode)
|
||||||
{
|
{
|
||||||
_settingsViewWidget = std::make_unique<QQuickWidget>(Systray::instance()->trayEngine(), nullptr);
|
const auto settingsViewWidget = new QQuickWidget(Systray::instance()->trayEngine(), parent);
|
||||||
_settingsViewWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
settingsViewWidget->setResizeMode(resizeMode);
|
||||||
_settingsViewWidget->setSource(QUrl(fpSettingsQmlPath));
|
settingsViewWidget->setSource(QUrl(fpSettingsQmlPath));
|
||||||
_settingsViewWidget->rootContext()->setContextProperty(fpSettingsControllerProp, this);
|
settingsViewWidget->rootContext()->setContextProperty(fpSettingsControllerProp, this);
|
||||||
}
|
return settingsViewWidget;
|
||||||
|
|
||||||
QQuickWidget *FileProviderSettingsController::settingsViewWidget()
|
|
||||||
{
|
|
||||||
if (!_settingsViewWidget) {
|
|
||||||
instantiateSettingsWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _settingsViewWidget.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Mac
|
} // namespace Mac
|
||||||
|
|
Loading…
Reference in a new issue