mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 10:52:18 +02:00
account to global services merge tweaks
This commit is contained in:
parent
b60bf4f8cb
commit
f6f49fc2e5
3 changed files with 13 additions and 11 deletions
|
@ -17,13 +17,12 @@
|
|||
class AccountScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString username READ getUsername)
|
||||
Q_PROPERTY(bool loggedIn READ loggedIn)
|
||||
|
||||
/**jsdoc
|
||||
* @namespace Account
|
||||
* @property username {String} username if user is logged in, otherwise it returns "Unknown user"
|
||||
*/
|
||||
Q_PROPERTY(QString username READ getUsername)
|
||||
Q_PROPERTY(bool loggedIn READ loggedIn)
|
||||
|
||||
public slots:
|
||||
static AccountScriptingInterface* getInstance();
|
||||
|
|
|
@ -49,7 +49,13 @@ GlobalServicesScriptingInterface* GlobalServicesScriptingInterface::getInstance(
|
|||
}
|
||||
|
||||
const QString& GlobalServicesScriptingInterface::getUsername() const {
|
||||
return DependencyManager::get<AccountManager>()->getAccountInfo().getUsername();
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
if (accountManager->isLoggedIn()) {
|
||||
return accountManager->getAccountInfo().getUsername();
|
||||
}
|
||||
else {
|
||||
return "Unknown user";
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalServicesScriptingInterface::isLoggedIn() {
|
||||
|
@ -95,7 +101,7 @@ void GlobalServicesScriptingInterface::discoverabilityModeChanged(Discoverabilit
|
|||
emit findableByChanged(DiscoverabilityManager::findableByString(discoverabilityMode));
|
||||
}
|
||||
|
||||
void GlobalServicesScriptingInterface::onUsernameChanged(QString username) {
|
||||
void GlobalServicesScriptingInterface::onUsernameChanged(const QString& username) {
|
||||
_loggedIn = (username != QString());
|
||||
emit myUsernameChanged(username);
|
||||
emit loggedInChanged(_loggedIn);
|
||||
|
|
|
@ -35,7 +35,7 @@ void DownloadInfoResultFromScriptValue(const QScriptValue& object, DownloadInfoR
|
|||
class GlobalServicesScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString username READ getUsername)
|
||||
Q_PROPERTY(QString username READ getUsername NOTIFY myUsernameChanged)
|
||||
Q_PROPERTY(bool loggedIn READ loggedIn NOTIFY loggedInChanged)
|
||||
Q_PROPERTY(QString findableBy READ getFindableBy WRITE setFindableBy NOTIFY findableByChanged)
|
||||
|
||||
|
@ -43,10 +43,7 @@ public:
|
|||
static GlobalServicesScriptingInterface* getInstance();
|
||||
|
||||
const QString& getUsername() const;
|
||||
|
||||
bool loggedIn() const {
|
||||
return _loggedIn;
|
||||
}
|
||||
bool loggedIn() const { return _loggedIn; }
|
||||
|
||||
public slots:
|
||||
DownloadInfoResult getDownloadInfo();
|
||||
|
@ -64,7 +61,7 @@ private slots:
|
|||
void setFindableBy(const QString& discoverabilityMode);
|
||||
void discoverabilityModeChanged(Discoverability::Mode discoverabilityMode);
|
||||
|
||||
void onUsernameChanged(QString username);
|
||||
void onUsernameChanged(const QString& username);
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
|
|
Loading…
Reference in a new issue