Wallet: add connectionStatusChanged signal

This commit is contained in:
Jaquee 2016-11-26 15:34:56 +01:00
parent d9f4ab45e2
commit 18b7a67886
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39
2 changed files with 13 additions and 3 deletions

View file

@ -87,9 +87,15 @@ Wallet::Status Wallet::status() const
return static_cast<Status>(m_walletImpl->status()); return static_cast<Status>(m_walletImpl->status());
} }
Wallet::ConnectionStatus Wallet::connected() const Wallet::ConnectionStatus Wallet::connected()
{ {
return static_cast<ConnectionStatus>(m_walletImpl->connected()); qDebug("Checking wallet connection status");
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
if(newStatus != m_connectionStatus) {
m_connectionStatus = newStatus;
emit connectionStatusChanged();
}
return newStatus;
} }
bool Wallet::synchronized() const bool Wallet::synchronized() const
@ -422,6 +428,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
{ {
m_history = new TransactionHistory(m_walletImpl->history(), this); m_history = new TransactionHistory(m_walletImpl->history(), this);
m_walletImpl->setListener(new WalletListenerImpl(this)); m_walletImpl->setListener(new WalletListenerImpl(this));
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
} }
Wallet::~Wallet() Wallet::~Wallet()

View file

@ -63,7 +63,7 @@ public:
Status status() const; Status status() const;
//! returns whether the wallet is connected, and version status //! returns whether the wallet is connected, and version status
ConnectionStatus connected() const; ConnectionStatus connected();
//! returns true if wallet was ever synchronized //! returns true if wallet was ever synchronized
bool synchronized() const; bool synchronized() const;
@ -196,6 +196,8 @@ signals:
// emitted when transaction is created async // emitted when transaction is created async
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount); void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
void connectionStatusChanged();
private: private:
Wallet(QObject * parent = nullptr); Wallet(QObject * parent = nullptr);
Wallet(Bitmonero::Wallet *w, QObject * parent = 0); Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
@ -217,6 +219,7 @@ private:
mutable QTime m_daemonBlockChainTargetHeightTime; mutable QTime m_daemonBlockChainTargetHeightTime;
mutable quint64 m_daemonBlockChainTargetHeight; mutable quint64 m_daemonBlockChainTargetHeight;
int m_daemonBlockChainTargetHeightTtl; int m_daemonBlockChainTargetHeightTtl;
ConnectionStatus m_connectionStatus;
}; };