Qt: When multiple wallets are used, include in notifications the name

pull/12610/head
Jonas Schnelli 7 years ago
parent d1ec34a761
commit 12d8d2681e
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D

@ -1000,12 +1000,15 @@ void BitcoinGUI::showEvent(QShowEvent *event)
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label) void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName)
{ {
// On new transaction, make an info balloon // On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(date) + QString msg = tr("Date: %1\n").arg(date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) + tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
tr("Type: %1\n").arg(type); if (WalletModel::isMultiwallet() && !walletName.isEmpty()) {
msg += tr("Wallet: %1\n").arg(walletName);
}
msg += tr("Type: %1\n").arg(type);
if (!label.isEmpty()) if (!label.isEmpty())
msg += tr("Label: %1\n").arg(label); msg += tr("Label: %1\n").arg(label);
else if (!address.isEmpty()) else if (!address.isEmpty())

@ -196,7 +196,7 @@ public Q_SLOTS:
bool handlePaymentRequest(const SendCoinsRecipient& recipient); bool handlePaymentRequest(const SendCoinsRecipient& recipient);
/** Show incoming transaction notification for new transactions. */ /** 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); void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
private Q_SLOTS: private Q_SLOTS:

@ -744,3 +744,18 @@ int WalletModel::getDefaultConfirmTarget() const
{ {
return nTxConfirmTarget; return nTxConfirmTarget;
} }
QString WalletModel::getWalletName() const
{
LOCK(wallet->cs_wallet);
QString walletName = QString::fromStdString(wallet->GetName());
if (walletName.endsWith(".dat")) {
walletName.truncate(walletName.size() - 4);
}
return walletName;
}
bool WalletModel::isMultiwallet()
{
return gArgs.GetArgs("-wallet").size() > 1;
}

@ -222,6 +222,9 @@ public:
int getDefaultConfirmTarget() const; int getDefaultConfirmTarget() const;
QString getWalletName() const;
static bool isMultiwallet();
private: private:
CWallet *wallet; CWallet *wallet;
bool fHaveWatchOnly; bool fHaveWatchOnly;

@ -104,7 +104,7 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
connect(this, SIGNAL(encryptionStatusChanged()), gui, SLOT(updateWalletStatus())); connect(this, SIGNAL(encryptionStatusChanged()), gui, SLOT(updateWalletStatus()));
// Pass through transaction notifications // Pass through transaction notifications
connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString))); connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString,QString)));
// Connect HD enabled state signal // Connect HD enabled state signal
connect(this, SIGNAL(hdEnabledStatusChanged()), gui, SLOT(updateWalletStatus())); connect(this, SIGNAL(hdEnabledStatusChanged()), gui, SLOT(updateWalletStatus()));
@ -172,7 +172,7 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int
QString address = ttm->data(index, TransactionTableModel::AddressRole).toString(); QString address = ttm->data(index, TransactionTableModel::AddressRole).toString();
QString label = ttm->data(index, TransactionTableModel::LabelRole).toString(); QString label = ttm->data(index, TransactionTableModel::LabelRole).toString();
Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label, walletModel->getWalletName());
} }
void WalletView::gotoOverviewPage() void WalletView::gotoOverviewPage()

@ -124,7 +124,7 @@ Q_SIGNALS:
/** HD-Enabled status of wallet changed (only possible during startup) */ /** HD-Enabled status of wallet changed (only possible during startup) */
void hdEnabledStatusChanged(); void hdEnabledStatusChanged();
/** Notify that a new transaction appeared */ /** 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); void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
/** Notify that the out of sync warning icon has been pressed */ /** Notify that the out of sync warning icon has been pressed */
void outOfSyncWarningClicked(); void outOfSyncWarningClicked();
}; };

Loading…
Cancel
Save