diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 0cdcace834d60..f27d2742703a7 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -509,7 +509,6 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) } acc->setCredentials(CredentialsFactory::create(authType)); - acc->setDisplayName(acc->credentials()->user()); acc->setNetworkProxySetting(settings.value(networkProxySettingC).value()); acc->setProxyType(settings.value(networkProxyTypeC).value()); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index fbe88657d39ad..f35781d5ebe3b 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -159,19 +159,19 @@ void Account::setAvatar(const QImage &img) QString Account::displayName() const { - return _displayName; -} + auto credentialsUser = _davUser; + if (_credentials && !_credentials->user().isEmpty()) { + credentialsUser = _credentials->user(); + } -void Account::setDisplayName(const QString &username) -{ - auto displayName = QString("%1@%2").arg(username, _url.host()); + auto displayName = QString("%1@%2").arg(credentialsUser, _url.host()); const auto port = url().port(); if (port > 0 && port != 80 && port != 443) { displayName.append(QLatin1Char(':')); displayName.append(QString::number(port)); } - _displayName = displayName; + return displayName; } QString Account::userIdAtHostWithPort() const diff --git a/src/libsync/account.h b/src/libsync/account.h index a991daed9cd47..4979931bd870d 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -146,7 +146,6 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject /// The name of the account as shown in the toolbar [[nodiscard]] QString displayName() const; - void setDisplayName(const QString &username); /// User id in a form 'user@example.de, optionally port is added (if it is not 80 or 443) [[nodiscard]] QString userIdAtHostWithPort() const;