@@ -55,6 +55,8 @@ static const float buttonSizeRatio = 1.618; // golden ratio
55
55
56
56
namespace OCC {
57
57
58
+ #include " settingsdialogcommon.cpp"
59
+
58
60
static QIcon circleMask (const QImage &avatar)
59
61
{
60
62
int dim = avatar.width ();
@@ -236,7 +238,7 @@ void SettingsDialog::accountAdded(AccountState *s)
236
238
237
239
if (!brandingSingleAccount) {
238
240
accountAction->setToolTip (s->account ()->displayName ());
239
- accountAction->setIconText (shortDisplayNameForSettings (s->account ().data (), height * buttonSizeRatio));
241
+ accountAction->setIconText (SettingsDialogCommon:: shortDisplayNameForSettings (s->account ().data (), height * buttonSizeRatio));
240
242
}
241
243
_toolBar->insertAction (_toolBar->actions ().at (0 ), accountAction);
242
244
auto accountSettings = new AccountSettings (s, this );
@@ -278,32 +280,11 @@ void SettingsDialog::slotAccountDisplayNameChanged()
278
280
QString displayName = account->displayName ();
279
281
action->setText (displayName);
280
282
auto height = _toolBar->sizeHint ().height ();
281
- action->setIconText (shortDisplayNameForSettings (account, height * buttonSizeRatio));
283
+ action->setIconText (SettingsDialogCommon:: shortDisplayNameForSettings (account, height * buttonSizeRatio));
282
284
}
283
285
}
284
286
}
285
287
286
- QString SettingsDialog::shortDisplayNameForSettings (Account* account, int width) const
287
- {
288
- QString user = account->davDisplayName ();
289
- if (user.isEmpty ()) {
290
- user = account->credentials ()->user ();
291
- }
292
- QString host = account->url ().host ();
293
- int port = account->url ().port ();
294
- if (port > 0 && port != 80 && port != 443 ) {
295
- host.append (QLatin1Char (' :' ));
296
- host.append (QString::number (port));
297
- }
298
- if (width > 0 ) {
299
- QFont f;
300
- QFontMetrics fm (f);
301
- host = fm.elidedText (host, Qt::ElideMiddle, width);
302
- user = fm.elidedText (user, Qt::ElideRight, width);
303
- }
304
- return user + QLatin1String (" \n " ) + host;
305
- }
306
-
307
288
void SettingsDialog::accountRemoved (AccountState *s)
308
289
{
309
290
for (auto it = _actionGroupWidgets.begin (); it != _actionGroupWidgets.end (); ++it) {
0 commit comments