Skip to content

Commit

Permalink
Fix tests: make sure displayName is not empty.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Nov 14, 2024
1 parent 30b4767 commit 9f7920b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Account::AccountNetworkProxySetting>());
acc->setProxyType(settings.value(networkProxyTypeC).value<QNetworkProxy::ProxyType>());
Expand Down
12 changes: 6 additions & 6 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 '[email protected], optionally port is added (if it is not 80 or 443)
[[nodiscard]] QString userIdAtHostWithPort() const;
Expand Down

0 comments on commit 9f7920b

Please sign in to comment.