mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-08 20:09:48 +00:00
Balance on UI updated by the signal
This commit is contained in:
parent
eaf59243b2
commit
8ac86a8042
3 changed files with 20 additions and 1 deletions
12
main.qml
12
main.qml
|
@ -142,10 +142,19 @@ ApplicationWindow {
|
|||
console.log("Error initialize wallet: ", wallet.errorString);
|
||||
return
|
||||
}
|
||||
|
||||
// subscribing for wallet updates
|
||||
wallet.updated.connect(onWalletUpdate);
|
||||
|
||||
// TODO: refresh asynchronously without blocking UI, implement signal(s)
|
||||
wallet.refresh();
|
||||
|
||||
console.log("wallet balance: ", wallet.balance)
|
||||
|
||||
}
|
||||
|
||||
function onWalletUpdate() {
|
||||
console.log("wallet updated")
|
||||
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
||||
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
||||
}
|
||||
|
@ -176,8 +185,11 @@ ApplicationWindow {
|
|||
+ ", fee: " + walletManager.displayAmount(pendingTransaction.fee));
|
||||
if (!pendingTransaction.commit()) {
|
||||
console.log("Error committing transaction: " + pendingTransaction.errorString);
|
||||
} else {
|
||||
wallet.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
wallet.disposeTransaction(pendingTransaction);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <QTimer>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -81,7 +82,10 @@ quint64 Wallet::unlockedBalance() const
|
|||
|
||||
bool Wallet::refresh()
|
||||
{
|
||||
return m_walletImpl->refresh();
|
||||
bool result = m_walletImpl->refresh();
|
||||
if (result)
|
||||
emit updated();
|
||||
return result;
|
||||
}
|
||||
|
||||
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, quint64 amount)
|
||||
|
|
|
@ -85,6 +85,9 @@ public:
|
|||
TransactionHistory * history();
|
||||
|
||||
// TODO: setListenter() when it implemented in API
|
||||
signals:
|
||||
void updated();
|
||||
|
||||
|
||||
private:
|
||||
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
||||
|
|
Loading…
Reference in a new issue