mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 04:15:14 +02:00
Expose the username to scripts (and thus QML)
This commit is contained in:
parent
000130617e
commit
a883891197
2 changed files with 10 additions and 1 deletions
|
@ -17,7 +17,6 @@ AccountScriptingInterface::AccountScriptingInterface() {
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
connect(&accountManager, &AccountManager::balanceChanged, this,
|
connect(&accountManager, &AccountManager::balanceChanged, this,
|
||||||
&AccountScriptingInterface::updateBalance);
|
&AccountScriptingInterface::updateBalance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountScriptingInterface* AccountScriptingInterface::getInstance() {
|
AccountScriptingInterface* AccountScriptingInterface::getInstance() {
|
||||||
|
@ -39,3 +38,12 @@ void AccountScriptingInterface::updateBalance() {
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
emit balanceChanged(accountManager.getAccountInfo().getBalanceInSatoshis());
|
emit balanceChanged(accountManager.getAccountInfo().getBalanceInSatoshis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AccountScriptingInterface::getUsername() {
|
||||||
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
if (accountManager.isLoggedIn()) {
|
||||||
|
return accountManager.getAccountInfo().getUsername();
|
||||||
|
} else {
|
||||||
|
return "Unknown user";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
static AccountScriptingInterface* getInstance();
|
static AccountScriptingInterface* getInstance();
|
||||||
float getBalance();
|
float getBalance();
|
||||||
|
QString getUsername();
|
||||||
bool isLoggedIn();
|
bool isLoggedIn();
|
||||||
void updateBalance();
|
void updateBalance();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue