[Pkg-owncloud-commits] [owncloud-client] 453/498: SettingsDialog: use the same short display name on Win/Linux than on Mac
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:49:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 646890abb3e3268d806840dc77443d07143ae26e
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Wed Aug 5 14:49:16 2015 +0200
SettingsDialog: use the same short display name on Win/Linux than on Mac
Issue #3516
---
src/gui/accountstate.cpp | 16 ++++++++++++++++
src/gui/accountstate.h | 3 +++
src/gui/settingsdialog.cpp | 11 +++++++----
src/gui/settingsdialogmac.cpp | 12 +-----------
4 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp
index 2483576..e7006f3 100644
--- a/src/gui/accountstate.cpp
+++ b/src/gui/accountstate.cpp
@@ -252,5 +252,21 @@ std::unique_ptr<QSettings> AccountState::settings()
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
diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h
index 36ee4ad..d5412aa 100644
--- a/src/gui/accountstate.h
+++ b/src/gui/accountstate.h
@@ -89,6 +89,9 @@ public:
/** Returns a new settings object for this account, already in the right groups. */
std::unique_ptr<QSettings> settings();
+ /** display name with two lines that is displayed in the settings */
+ QString shortDisplayNameForSettings() const;
+
private:
void setState(State state);
diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp
index d79b57a..ce57eeb 100644
--- a/src/gui/settingsdialog.cpp
+++ b/src/gui/settingsdialog.cpp
@@ -76,20 +76,22 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
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"));
- _protocolAction = toolBar->addAction(protocolIcon, tr("Activity"));
+ _protocolAction = toolBar->addAction(protocolIcon, tr("Activity") + QLatin1Char('\n'));
_protocolAction->setCheckable(true);
ProtocolWidget *protocolWidget = new ProtocolWidget;
_ui->stack->addWidget(protocolWidget);
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);
GeneralSettings *generalSettings = new GeneralSettings;
_ui->stack->addWidget(generalSettings);
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);
NetworkSettings *networkSettings = new NetworkSettings;
_ui->stack->addWidget(networkSettings);
@@ -163,7 +165,8 @@ void SettingsDialog::accountAdded(AccountState *s)
QIcon accountIcon(QLatin1String(":/client/resources/account.png"));
auto toolBar = qobject_cast<QToolBar*>(layout()->menuBar());
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);
accountAction->setCheckable(true);
auto accountSettings = new AccountSettings(s, this);
diff --git a/src/gui/settingsdialogmac.cpp b/src/gui/settingsdialogmac.cpp
index 053e5a9..e7b95dc 100644
--- a/src/gui/settingsdialogmac.cpp
+++ b/src/gui/settingsdialogmac.cpp
@@ -114,17 +114,7 @@ void SettingsDialogMac::accountAdded(AccountState *s)
QIcon accountIcon = MacStandardIcon::icon(MacStandardIcon::UserAccounts);
auto accountSettings = new AccountSettings(s, this);
- QString userWithoutMailHost = s->account()->credentials()->user();
- 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);
+ QString displayName = s->shortDisplayNameForSettings();
insertPreferencesPanel(0, accountIcon, displayName, accountSettings);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list