From 28306e5dfbeb2b08ff63fbbf41e44cbd3bfb2051 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 23 Apr 2015 14:51:06 +0200 Subject: [PATCH] Move AccountState::displayName to Account. --- src/gui/accountstate.cpp | 7 ------- src/gui/accountstate.h | 3 --- src/gui/settingsdialog.cpp | 2 +- src/libsync/account.cpp | 6 ++++++ src/libsync/account.h | 3 +++ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 6003467490..8904b2c1bd 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -234,12 +234,5 @@ void AccountState::slotCredentialsFetched(AbstractCredentials* credentials) checkConnectivity(); } -QString AccountState::displayName() -{ - auto user = account()->credentials()->user(); - auto url = account()->url(); - return tr("%1@%2").arg(user, url.host()); -} - } // namespace OCC diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 2dae899abf..9175750849 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -85,9 +85,6 @@ public: /// connection status and errors. void checkConnectivity(); - // The name of the account as shown in the toolbar - QString displayName(); - private: void setState(State state); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 93b20f8a93..b7c466009a 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -159,7 +159,7 @@ void SettingsDialog::accountAdded(AccountState *s) QIcon accountIcon(QLatin1String(":/client/resources/account.png")); auto toolBar = qobject_cast(layout()->menuBar()); Q_ASSERT(toolBar); - auto accountAction = new QAction(accountIcon, s->displayName(), this); + auto accountAction = new QAction(accountIcon, s->account()->displayName(), this); toolBar->insertAction(toolBar->actions().at(0), accountAction); accountAction->setCheckable(true); auto accountSettings = new AccountSettings(s, this); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 95df4774eb..b64f84b35f 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -71,6 +71,12 @@ AccountPtr Account::sharedFromThis() } +QString Account::displayName() const +{ + auto user = _credentials->user(); + return tr("%1@%2").arg(user, _url.host()); +} + static bool isEqualExceptProtocol(const QUrl &url1, const QUrl &url2) { return (url1.host() != url2.host() || diff --git a/src/libsync/account.h b/src/libsync/account.h index d4cec2611b..c26ddda783 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -62,6 +62,9 @@ public: void setSharedThis(AccountPtr sharedThis); AccountPtr sharedFromThis(); + /// The name of the account as shown in the toolbar + QString displayName() const; + /** * @brief Checks the Account instance is different from \param other *