blob: fbd9b5990e634709d5d07f9daa0d0104252cb0f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
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;
}
}
|