Skip to content

Commit

Permalink
GUI: Pre-render amount for transaction notifications so asset is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 10, 2019
1 parent 3bedac4 commit f963920
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/qt/bitcoingui.cpp
Expand Up @@ -1008,11 +1008,11 @@ void BitcoinGUI::showEvent(QShowEvent *event)
}

#ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName)
void BitcoinGUI::incomingTransaction(const QString& date, const QString& assetamount_str, const QString& type, const QString& address, const QString& label, const QString& walletName)
{
// On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
tr("Amount: %1\n").arg(assetamount_str) +
if (m_node.getWallets().size() > 1 && !walletName.isEmpty()) {
msg += tr("Wallet: %1\n").arg(walletName);
}
Expand All @@ -1021,7 +1021,7 @@ void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmoun
msg += tr("Label: %1\n").arg(label);
else if (!address.isEmpty())
msg += tr("Address: %1\n").arg(address);
message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
message(assetamount_str.startsWith("-") ? tr("Sent transaction") : tr("Incoming transaction"),
msg, CClientUIInterface::MSG_INFORMATION);
}
#endif // ENABLE_WALLET
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.h
Expand Up @@ -221,7 +221,7 @@ public Q_SLOTS:
bool handlePaymentRequest(const SendCoinsRecipient& recipient);

/** Show incoming transaction notification for new transactions. */
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
void incomingTransaction(const QString& date, const QString& assetamount_str, const QString& type, const QString& address, const QString& label, const QString& walletName);
#endif // ENABLE_WALLET

private:
Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletview.cpp
Expand Up @@ -165,13 +165,13 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int
return;

QString date = ttm->index(start, TransactionTableModel::Date, parent).data().toString();
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent).data(Qt::EditRole).toULongLong();
QString assetamount_str = ttm->index(start, TransactionTableModel::Amount, parent).data().toString();
QString type = ttm->index(start, TransactionTableModel::Type, parent).data().toString();
QModelIndex index = ttm->index(start, 0, parent);
QString address = ttm->data(index, TransactionTableModel::AddressRole).toString();
QString label = ttm->data(index, TransactionTableModel::LabelRole).toString();

Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label, walletModel->getWalletName());
Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), assetamount_str, address, label, walletModel->getWalletName());
}

void WalletView::gotoOverviewPage()
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletview.h
Expand Up @@ -124,7 +124,7 @@ public Q_SLOTS:
/** HD-Enabled status of wallet changed (only possible during startup) */
void hdEnabledStatusChanged();
/** Notify that a new transaction appeared */
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
void incomingTransaction(const QString& date, const QString& assetamount_str, const QString& type, const QString& address, const QString& label, const QString& walletName);
/** Notify that the out of sync warning icon has been pressed */
void outOfSyncWarningClicked();
};
Expand Down

0 comments on commit f963920

Please sign in to comment.