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 (Mac::FileProvider::fileProviderAvailable()) {
|
||||
const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget();
|
||||
const auto fpSettingsLayout = new QVBoxLayout(_ui->fileProviderTab);
|
||||
const auto fileProviderTab = _ui->fileProviderTab;
|
||||
const auto fpSettingsLayout = new QVBoxLayout(fileProviderTab);
|
||||
const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget(fileProviderTab);
|
||||
fpSettingsLayout->setMargin(0);
|
||||
fpSettingsLayout->addWidget(fpSettingsWidget);
|
||||
_ui->fileProviderTab->setLayout(fpSettingsLayout);
|
||||
fileProviderTab->setLayout(fpSettingsLayout);
|
||||
} else {
|
||||
disguiseTabWidget();
|
||||
}
|
||||
|
|
|
@ -28,18 +28,15 @@ class FileProviderSettingsController : public QObject
|
|||
public:
|
||||
static FileProviderSettingsController *instance();
|
||||
|
||||
[[nodiscard]] QQuickWidget *settingsViewWidget();
|
||||
[[nodiscard]] QQuickWidget *settingsViewWidget(QWidget *const parent = nullptr,
|
||||
const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView);
|
||||
|
||||
private:
|
||||
explicit FileProviderSettingsController(QObject *parent = nullptr);
|
||||
~FileProviderSettingsController() override;
|
||||
|
||||
void instantiateSettingsWidget();
|
||||
|
||||
class MacImplementation;
|
||||
std::unique_ptr<MacImplementation> d;
|
||||
|
||||
std::unique_ptr<QQuickWidget> _settingsViewWidget;
|
||||
};
|
||||
|
||||
} // Mac
|
||||
|
|
|
@ -68,21 +68,13 @@ FileProviderSettingsController::FileProviderSettingsController(QObject *parent)
|
|||
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);
|
||||
_settingsViewWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
_settingsViewWidget->setSource(QUrl(fpSettingsQmlPath));
|
||||
_settingsViewWidget->rootContext()->setContextProperty(fpSettingsControllerProp, this);
|
||||
}
|
||||
|
||||
QQuickWidget *FileProviderSettingsController::settingsViewWidget()
|
||||
{
|
||||
if (!_settingsViewWidget) {
|
||||
instantiateSettingsWidget();
|
||||
}
|
||||
|
||||
return _settingsViewWidget.get();
|
||||
const auto settingsViewWidget = new QQuickWidget(Systray::instance()->trayEngine(), parent);
|
||||
settingsViewWidget->setResizeMode(resizeMode);
|
||||
settingsViewWidget->setSource(QUrl(fpSettingsQmlPath));
|
||||
settingsViewWidget->rootContext()->setContextProperty(fpSettingsControllerProp, this);
|
||||
return settingsViewWidget;
|
||||
}
|
||||
|
||||
} // namespace Mac
|
||||
|
|
Loading…
Reference in a new issue