diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 28a0b78c5..0b5eed458 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -215,6 +215,16 @@ AccountPtr AccountManager::load(QSettings& settings) return acc; } +AccountStatePtr AccountManager::account(const QString& name) +{ + foreach (const auto& acc, _accounts) { + if (acc->account()->displayName() == name) { + return acc; + } + } + return AccountStatePtr(); +} + AccountState *AccountManager::addAccount(const AccountPtr& newAccount) { auto id = newAccount->id(); diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index eed8e43e3..296b3b33e 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -58,6 +58,11 @@ public: */ QList accounts() { return _accounts; } + /** + * Return the account state pointer for an account identified by its display name + */ + AccountStatePtr account(const QString& name); + /** * Delete the AccountState */