diff options
author | Claudio Cambra <claudio.cambra@nextcloud.com> | 2022-10-06 20:45:24 +0300 |
---|---|---|
committer | Claudio Cambra <claudio.cambra@nextcloud.com> | 2022-10-19 14:31:44 +0300 |
commit | 359627007b16864dd012dfbcb83f8086dd065f6a (patch) | |
tree | 5b5ae5f90f8fb4e8e41a32c1946d200be0f7e56c /src | |
parent | 29afd9d5f36471b88c68d2fc146cbecad6dac0de (diff) |
Display the user's 'pretty' name in the webflow credentials
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/creds/webflowcredentials.cpp | 4 | ||||
-rw-r--r-- | src/libsync/account.cpp | 14 | ||||
-rw-r--r-- | src/libsync/account.h | 7 |
3 files changed, 23 insertions, 2 deletions
diff --git a/src/gui/creds/webflowcredentials.cpp b/src/gui/creds/webflowcredentials.cpp index b2e28dafd..6b388cd88 100644 --- a/src/gui/creds/webflowcredentials.cpp +++ b/src/gui/creds/webflowcredentials.cpp @@ -164,7 +164,7 @@ void WebFlowCredentials::askFromUser() { } QString msg = tr("You have been logged out of your account %1 at %2. Please login again.") - .arg(_account->davUser(), _account->url().toDisplayString()); + .arg(_account->prettyName(), _account->url().toDisplayString()); _askDialog->setInfo(msg); _askDialog->show(); @@ -188,7 +188,7 @@ void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user, qCInfo(lcWebFlowCredentials()) << "Authed with the wrong user!"; QString msg = tr("Please login with the account: %1") - .arg(_account->davUser()); + .arg(_account->prettyName()); _askDialog->setError(msg); if (!_askDialog->isUsingFlow2()) { diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index f3f8c1f10..7f640416d 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -131,6 +131,7 @@ void Account::setDavUser(const QString &newDavUser) return; _davUser = newDavUser; emit wantsAccountSaved(this); + emit prettyNameChanged(); } #ifndef TOKEN_AUTH_ONLY @@ -165,6 +166,19 @@ void Account::setDavDisplayName(const QString &newDisplayName) { _displayName = newDisplayName; emit accountChangedDisplayName(); + emit prettyNameChanged(); +} + +QString Account::prettyName() const +{ + // If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username + auto name = davDisplayName(); + + if (name.isEmpty()) { + name = davUser(); + } + + return name; } QColor Account::headerColor() const diff --git a/src/libsync/account.h b/src/libsync/account.h index 635caeac8..d96597dee 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -83,6 +83,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject Q_PROPERTY(QString id MEMBER _id) Q_PROPERTY(QString davUser MEMBER _davUser) Q_PROPERTY(QString displayName MEMBER _displayName) + Q_PROPERTY(QString prettyName READ prettyName NOTIFY prettyNameChanged) Q_PROPERTY(QUrl url MEMBER _url) public: @@ -113,6 +114,11 @@ public: /// The name of the account as shown in the toolbar [[nodiscard]] QString displayName() const; + /// The name of the account that is displayed as nicely as possible, + /// e.g. the actual name of the user (John Doe). If this cannot be + /// provided, defaults to davUser (e.g. johndoe) + [[nodiscard]] QString prettyName() const; + [[nodiscard]] QColor accentColor() const; [[nodiscard]] QColor headerColor() const; [[nodiscard]] QColor headerTextColor() const; @@ -319,6 +325,7 @@ signals: void accountChangedAvatar(); void accountChangedDisplayName(); + void prettyNameChanged(); /// Used in RemoteWipe void appPasswordRetrieved(QString); |