}
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();
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()) {
return;
_davUser = newDavUser;
emit wantsAccountSaved(this);
+ emit prettyNameChanged();
}
#ifndef TOKEN_AUTH_ONLY
{
_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
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:
/// 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;
void accountChangedAvatar();
void accountChangedDisplayName();
+ void prettyNameChanged();
/// Used in RemoteWipe
void appPasswordRetrieved(QString);