From 18b7a6788659bd39c0241b29be5cedc2762037b2 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 15:34:56 +0100 Subject: [PATCH] Wallet: add connectionStatusChanged signal --- src/libwalletqt/Wallet.cpp | 11 +++++++++-- src/libwalletqt/Wallet.h | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 9170073d..608bbd0f 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -87,9 +87,15 @@ Wallet::Status Wallet::status() const return static_cast(m_walletImpl->status()); } -Wallet::ConnectionStatus Wallet::connected() const +Wallet::ConnectionStatus Wallet::connected() { - return static_cast(m_walletImpl->connected()); + qDebug("Checking wallet connection status"); + ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); + if(newStatus != m_connectionStatus) { + m_connectionStatus = newStatus; + emit connectionStatusChanged(); + } + return newStatus; } bool Wallet::synchronized() const @@ -422,6 +428,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) { m_history = new TransactionHistory(m_walletImpl->history(), this); m_walletImpl->setListener(new WalletListenerImpl(this)); + m_connectionStatus = Wallet::ConnectionStatus_Disconnected; } Wallet::~Wallet() diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 14308ce5..f9cf8792 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -63,7 +63,7 @@ public: Status status() const; //! returns whether the wallet is connected, and version status - ConnectionStatus connected() const; + ConnectionStatus connected(); //! returns true if wallet was ever synchronized bool synchronized() const; @@ -196,6 +196,8 @@ signals: // emitted when transaction is created async void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount); + void connectionStatusChanged(); + private: Wallet(QObject * parent = nullptr); Wallet(Bitmonero::Wallet *w, QObject * parent = 0); @@ -217,6 +219,7 @@ private: mutable QTime m_daemonBlockChainTargetHeightTime; mutable quint64 m_daemonBlockChainTargetHeight; int m_daemonBlockChainTargetHeightTtl; + ConnectionStatus m_connectionStatus; };