Showing the changes to interface/src/scripting/AccountScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -18,6 +18,8 @@ AccountScriptingInterface* AccountScriptingInterface::getInstance() { · 17 unmodified lines | |||
| 18 | auto accountManager = DependencyManager::get<AccountManager>(); | 18 | auto accountManager = DependencyManager::get<AccountManager>(); |
| 19 | QObject::connect(accountManager.data(), &AccountManager::profileChanged, | 19 | QObject::connect(accountManager.data(), &AccountManager::profileChanged, |
| 20 | &sharedInstance, &AccountScriptingInterface::usernameChanged); | 20 | &sharedInstance, &AccountScriptingInterface::usernameChanged); |
| 21 | QObject::connect(accountManager.data(), &AccountManager::usernameChanged, | ||
| 22 | &sharedInstance, &AccountScriptingInterface::onUsernameChanged); | ||
| 21 | return &sharedInstance; | 23 | return &sharedInstance; |
| 22 | } | 24 | } |
| 23 | 25 | ||
| @@ -36,6 +38,16 @@ void AccountScriptingInterface::logOut() { · 12 unmodified lines | |||
| 36 | return accountManager->logout(); | 38 | return accountManager->logout(); |
| 37 | } | 39 | } |
| 38 | 40 | ||
| 41 | AccountScriptingInterface::AccountScriptingInterface(QObject *parent): QObject(parent) { | ||
| 42 | m_loggedIn = isLoggedIn(); | ||
| 43 | emit loggedInChanged(m_loggedIn); | ||
| 44 | } | ||
| 45 | |||
| 46 | void AccountScriptingInterface::onUsernameChanged(QString username) { | ||
| 47 | m_loggedIn = (username != QString()); | ||
| 48 | emit loggedInChanged(m_loggedIn); | ||
| 49 | } | ||
| 50 | |||
| 39 | QString AccountScriptingInterface::getUsername() { | 51 | QString AccountScriptingInterface::getUsername() { |
| 40 | auto accountManager = DependencyManager::get<AccountManager>(); | 52 | auto accountManager = DependencyManager::get<AccountManager>(); |
| 41 | if (accountManager->isLoggedIn()) { | 53 | if (accountManager->isLoggedIn()) { |