mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
SettingsDialog: use the same short display name on Win/Linux than on Mac
Issue #3516
This commit is contained in:
parent
cad33de824
commit
646890abb3
4 changed files with 27 additions and 15 deletions
|
@ -252,5 +252,21 @@ std::unique_ptr<QSettings> AccountState::settings()
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AccountState::shortDisplayNameForSettings() const
|
||||||
|
{
|
||||||
|
QString userWithoutMailHost = account()->credentials()->user();
|
||||||
|
if (userWithoutMailHost.contains('@')) {
|
||||||
|
userWithoutMailHost = userWithoutMailHost.left(userWithoutMailHost.lastIndexOf('@'));
|
||||||
|
}
|
||||||
|
QString hostWithoutTld = account()->url().host();
|
||||||
|
if (hostWithoutTld.contains('.')) {
|
||||||
|
hostWithoutTld = hostWithoutTld.left(hostWithoutTld.lastIndexOf('.'));
|
||||||
|
hostWithoutTld = hostWithoutTld.replace(QLatin1String("www."), QLatin1String(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
return userWithoutMailHost + QLatin1String("\n") + hostWithoutTld;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -89,6 +89,9 @@ public:
|
||||||
/** Returns a new settings object for this account, already in the right groups. */
|
/** Returns a new settings object for this account, already in the right groups. */
|
||||||
std::unique_ptr<QSettings> settings();
|
std::unique_ptr<QSettings> settings();
|
||||||
|
|
||||||
|
/** display name with two lines that is displayed in the settings */
|
||||||
|
QString shortDisplayNameForSettings() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setState(State state);
|
void setState(State state);
|
||||||
|
|
||||||
|
|
|
@ -76,20 +76,22 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
||||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
toolBar->addWidget(spacer);
|
toolBar->addWidget(spacer);
|
||||||
|
|
||||||
|
// Note: all the actions have a '\n' because the account name is in two lines and
|
||||||
|
// all buttons must have the same size in order to keep a good layout
|
||||||
QIcon protocolIcon(QLatin1String(":/client/resources/activity.png"));
|
QIcon protocolIcon(QLatin1String(":/client/resources/activity.png"));
|
||||||
_protocolAction = toolBar->addAction(protocolIcon, tr("Activity"));
|
_protocolAction = toolBar->addAction(protocolIcon, tr("Activity") + QLatin1Char('\n'));
|
||||||
_protocolAction->setCheckable(true);
|
_protocolAction->setCheckable(true);
|
||||||
ProtocolWidget *protocolWidget = new ProtocolWidget;
|
ProtocolWidget *protocolWidget = new ProtocolWidget;
|
||||||
_ui->stack->addWidget(protocolWidget);
|
_ui->stack->addWidget(protocolWidget);
|
||||||
|
|
||||||
QIcon generalIcon(QLatin1String(":/client/resources/settings.png"));
|
QIcon generalIcon(QLatin1String(":/client/resources/settings.png"));
|
||||||
QAction *generalAction = toolBar->addAction(generalIcon, tr("General"));
|
QAction *generalAction = toolBar->addAction(generalIcon, tr("General") + QLatin1Char('\n'));
|
||||||
generalAction->setCheckable(true);
|
generalAction->setCheckable(true);
|
||||||
GeneralSettings *generalSettings = new GeneralSettings;
|
GeneralSettings *generalSettings = new GeneralSettings;
|
||||||
_ui->stack->addWidget(generalSettings);
|
_ui->stack->addWidget(generalSettings);
|
||||||
|
|
||||||
QIcon networkIcon(QLatin1String(":/client/resources/network.png"));
|
QIcon networkIcon(QLatin1String(":/client/resources/network.png"));
|
||||||
QAction *networkAction = toolBar->addAction(networkIcon, tr("Network"));
|
QAction *networkAction = toolBar->addAction(networkIcon, tr("Network") + QLatin1Char('\n'));
|
||||||
networkAction->setCheckable(true);
|
networkAction->setCheckable(true);
|
||||||
NetworkSettings *networkSettings = new NetworkSettings;
|
NetworkSettings *networkSettings = new NetworkSettings;
|
||||||
_ui->stack->addWidget(networkSettings);
|
_ui->stack->addWidget(networkSettings);
|
||||||
|
@ -163,7 +165,8 @@ void SettingsDialog::accountAdded(AccountState *s)
|
||||||
QIcon accountIcon(QLatin1String(":/client/resources/account.png"));
|
QIcon accountIcon(QLatin1String(":/client/resources/account.png"));
|
||||||
auto toolBar = qobject_cast<QToolBar*>(layout()->menuBar());
|
auto toolBar = qobject_cast<QToolBar*>(layout()->menuBar());
|
||||||
Q_ASSERT(toolBar);
|
Q_ASSERT(toolBar);
|
||||||
auto accountAction = new QAction(accountIcon, s->account()->displayName(), this);
|
auto accountAction = new QAction(accountIcon, s->shortDisplayNameForSettings(), this);
|
||||||
|
accountAction->setToolTip(s->account()->displayName());
|
||||||
toolBar->insertAction(toolBar->actions().at(0), accountAction);
|
toolBar->insertAction(toolBar->actions().at(0), accountAction);
|
||||||
accountAction->setCheckable(true);
|
accountAction->setCheckable(true);
|
||||||
auto accountSettings = new AccountSettings(s, this);
|
auto accountSettings = new AccountSettings(s, this);
|
||||||
|
|
|
@ -114,17 +114,7 @@ void SettingsDialogMac::accountAdded(AccountState *s)
|
||||||
QIcon accountIcon = MacStandardIcon::icon(MacStandardIcon::UserAccounts);
|
QIcon accountIcon = MacStandardIcon::icon(MacStandardIcon::UserAccounts);
|
||||||
auto accountSettings = new AccountSettings(s, this);
|
auto accountSettings = new AccountSettings(s, this);
|
||||||
|
|
||||||
QString userWithoutMailHost = s->account()->credentials()->user();
|
QString displayName = s->shortDisplayNameForSettings();
|
||||||
if (userWithoutMailHost.contains('@')) {
|
|
||||||
userWithoutMailHost = userWithoutMailHost.left(userWithoutMailHost.lastIndexOf('@'));
|
|
||||||
}
|
|
||||||
QString hostWithoutTld = s->account()->url().host();
|
|
||||||
if (hostWithoutTld.contains('.')) {
|
|
||||||
hostWithoutTld = hostWithoutTld.left(hostWithoutTld.lastIndexOf('.'));
|
|
||||||
hostWithoutTld = hostWithoutTld.replace(QLatin1String("www."), QLatin1String(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString displayName = tr("%1\n%2").arg(userWithoutMailHost, hostWithoutTld);
|
|
||||||
|
|
||||||
insertPreferencesPanel(0, accountIcon, displayName, accountSettings);
|
insertPreferencesPanel(0, accountIcon, displayName, accountSettings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue