Skip to content

Commit

Permalink
Use prettyName more widely, instead of duplicating fallback string code
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
  • Loading branch information
claucambra committed Oct 6, 2022
1 parent f46b97f commit 78184f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,7 @@ void AccountSettings::slotAccountStateChanged()
Utility::escape(safeUrl.toString()));
QString serverWithUser = server;
if (AbstractCredentials *cred = account->credentials()) {
QString user = account->davDisplayName();
if (user.isEmpty()) {
user = cred->user();
}
QString user = account->prettyName();
serverWithUser = tr("%1 as %2").arg(server, Utility::escape(user));
}

Expand Down
5 changes: 1 addition & 4 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ const float buttonSizeRatio = 1.618f; // golden ratio
*/
QString shortDisplayNameForSettings(OCC::Account *account, int width)
{
QString user = account->davDisplayName();
if (user.isEmpty()) {
user = account->credentials()->user();
}
QString user = account->prettyName();
QString host = account->url().host();
int port = account->url().port();
if (port > 0 && port != 80 && port != 443) {
Expand Down
7 changes: 1 addition & 6 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,7 @@ void User::logout() const

QString User::name() const
{
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
QString name = _account->account()->davDisplayName();
if (name == "") {
name = _account->account()->credentials()->user();
}
return name;
return _account->account()->prettyName();
}

QString User::server(bool shortened) const
Expand Down

0 comments on commit 78184f0

Please sign in to comment.