mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-20 12:52:06 +03:00
28da954aad
Signed-off-by: Felix Eckhofer <felix@eckhofer.com>
28 lines
No EOL
844 B
C++
28 lines
No EOL
844 B
C++
namespace SettingsDialogCommon
|
|
{
|
|
|
|
/** display name with two lines that is displayed in the settings
|
|
* If width is bigger than 0, the string will be elided so it does not exceed that width
|
|
*/
|
|
QString shortDisplayNameForSettings(Account* account, int width)
|
|
{
|
|
QString user = account->davDisplayName();
|
|
if (user.isEmpty()) {
|
|
user = account->credentials()->user();
|
|
}
|
|
QString host = account->url().host();
|
|
int port = account->url().port();
|
|
if (port > 0 && port != 80 && port != 443) {
|
|
host.append(QLatin1Char(':'));
|
|
host.append(QString::number(port));
|
|
}
|
|
if (width > 0) {
|
|
QFont f;
|
|
QFontMetrics fm(f);
|
|
host = fm.elidedText(host, Qt::ElideMiddle, width);
|
|
user = fm.elidedText(user, Qt::ElideRight, width);
|
|
}
|
|
return user + QLatin1String("\n") + host;
|
|
}
|
|
|
|
} |