make sure balance is cleared on logout and re-launch

This commit is contained in:
Stephen Birarda 2014-05-22 15:06:16 -07:00
parent 79f09605d5
commit 164d3c5fb3
3 changed files with 9 additions and 2 deletions

View file

@ -3103,7 +3103,6 @@ void Application::updateWindowTitle(){
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
QString title = QString() + (!username.isEmpty() ? username + " @ " : QString())
+ nodeList->getDomainHandler().getHostname() + buildVersion;
qDebug("Application title set to: %s", title.toStdString().c_str());
AccountManager& accountManager = AccountManager::getInstance();
if (accountManager.getAccountInfo().hasBalance()) {
@ -3115,6 +3114,7 @@ void Application::updateWindowTitle(){
title += " - ₵" + creditBalanceString;
}
qDebug("Application title set to: %s", title.toStdString().c_str());
_window->setWindowTitle(title);
}

View file

@ -27,7 +27,9 @@ DataServerAccountInfo::DataServerAccountInfo() :
DataServerAccountInfo::DataServerAccountInfo(const QJsonObject& jsonObject) :
_accessToken(jsonObject),
_username(),
_xmppPassword()
_xmppPassword(),
_balance(0),
_hasBalance(false)
{
QJsonObject userJSONObject = jsonObject["user"].toObject();
setUsername(userJSONObject["username"].toString());
@ -40,6 +42,8 @@ DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherI
_username = otherInfo._username;
_xmppPassword = otherInfo._xmppPassword;
_discourseApiKey = otherInfo._discourseApiKey;
_balance = otherInfo._balance;
_hasBalance = otherInfo._hasBalance;
}
DataServerAccountInfo& DataServerAccountInfo::operator=(const DataServerAccountInfo& otherInfo) {
@ -55,6 +59,8 @@ void DataServerAccountInfo::swap(DataServerAccountInfo& otherInfo) {
swap(_username, otherInfo._username);
swap(_xmppPassword, otherInfo._xmppPassword);
swap(_discourseApiKey, otherInfo._discourseApiKey);
swap(_balance, otherInfo._balance);
swap(_hasBalance, otherInfo._hasBalance);
}
void DataServerAccountInfo::setUsername(const QString& username) {

View file

@ -38,6 +38,7 @@ public:
quint64 getBalance() const { return _balance; }
void setBalance(quint64 balance);
bool hasBalance() const { return _hasBalance; }
void setHasBalance(bool hasBalance) { _hasBalance = hasBalance; }
Q_INVOKABLE void setBalanceFromJSON(const QJsonObject& jsonObject);
friend QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info);