Expose account user id with host to QML

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-09-05 14:55:18 +08:00
parent 3c26e25a3c
commit ba3baa406b
No known key found for this signature in database
GPG key ID: C839200C384636B0
4 changed files with 11 additions and 3 deletions

View file

@ -201,7 +201,9 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
if (Mac::FileProvider::fileProviderAvailable()) {
const auto fileProviderTab = _ui->fileProviderTab;
const auto fpSettingsLayout = new QVBoxLayout(fileProviderTab);
const auto fpSettingsWidget = Mac::FileProviderSettingsController::instance()->settingsViewWidget(fileProviderTab);
const auto fpAccountUserIdAtHost = _accountState->account()->userIdAtHostWithPort();
const auto fpSettingsController = Mac::FileProviderSettingsController::instance();
const auto fpSettingsWidget = fpSettingsController->settingsViewWidget(fpAccountUserIdAtHost, fileProviderTab);
fpSettingsLayout->setMargin(0);
fpSettingsLayout->addWidget(fpSettingsWidget);
fileProviderTab->setLayout(fpSettingsLayout);

View file

@ -25,6 +25,7 @@ Page {
property bool showBorder: true
property var controller: FileProviderSettingsController
property var accountUserIdAtHost: AccountUserIdAtHost
title: qsTr("Virtual files settings")

View file

@ -28,7 +28,8 @@ class FileProviderSettingsController : public QObject
public:
static FileProviderSettingsController *instance();
[[nodiscard]] QQuickWidget *settingsViewWidget(QWidget *const parent = nullptr,
[[nodiscard]] QQuickWidget *settingsViewWidget(const QString &accountUserIdAtHost,
QWidget *const parent = nullptr,
const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView);
[[nodiscard]] Q_INVOKABLE bool vfsEnabledForAccount(const QString &userIdAtHost) const;

View file

@ -27,6 +27,7 @@ constexpr auto fpSettingsQmlPath = "qrc:/qml/src/gui/macOS/ui/FileProviderSettin
// FileProviderSettingsPage properties -- make sure they match up in QML file!
constexpr auto fpSettingsControllerProp = "FileProviderSettingsController";
constexpr auto fpSettingsAccountUserIdAtHostProp = "AccountUserIdAtHost";
// NSUserDefaults entries
constexpr auto enabledAccountsSettingsKey = "enabledAccounts";
@ -120,12 +121,15 @@ FileProviderSettingsController::FileProviderSettingsController(QObject *parent)
d = std::make_unique<FileProviderSettingsController::MacImplementation>(this);
}
QQuickWidget *FileProviderSettingsController::settingsViewWidget(QWidget *const parent, const QQuickWidget::ResizeMode resizeMode)
QQuickWidget *FileProviderSettingsController::settingsViewWidget(const QString &accountUserIdAtHost,
QWidget *const parent,
const QQuickWidget::ResizeMode resizeMode)
{
const auto settingsViewWidget = new QQuickWidget(Systray::instance()->trayEngine(), parent);
settingsViewWidget->setResizeMode(resizeMode);
settingsViewWidget->setSource(QUrl(fpSettingsQmlPath));
settingsViewWidget->rootContext()->setContextProperty(fpSettingsControllerProp, this);
settingsViewWidget->rootContext()->setContextProperty(fpSettingsAccountUserIdAtHostProp, accountUserIdAtHost);
return settingsViewWidget;
}