Merge #12421: [qt] navigate to transaction history page after send

e7d9fc5 [qt] navigate to  transaction history page after send (Sjors Provoost)

Pull request description:

  Before this change QT just remained on the Send tab, which I found confusing. Now it switches to the Transactions tab. This makes it more clear to the user that the send actually succeeded, and here they can monitor progress.

  Ideally I would like to highlight the transaction, e.g. by refactoring `TransactionView::focusTransaction(const QModelIndex &idx)` to accept a transaction hash, but I'm not sure how to do that.

Tree-SHA512: 8aa93e03874de8434e18951f8aec47377814c0bcaf7eda4766fc41d5a4e32806346e12e4139e4d45468dfdf0b786f5a7faa393a31b8cd6c65ccac21fb3782c33
This commit is contained in:
Wladimir J. van der Laan 2018-03-01 12:18:25 +01:00
commit be263faf87
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D
6 changed files with 42 additions and 3 deletions

View file

@ -29,6 +29,7 @@
#include <init.h> #include <init.h>
#include <rpc/server.h> #include <rpc/server.h>
#include <ui_interface.h> #include <ui_interface.h>
#include <uint256.h>
#include <util.h> #include <util.h>
#include <warnings.h> #include <warnings.h>
@ -80,6 +81,7 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
// Declare meta types used for QMetaObject::invokeMethod // Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*) Q_DECLARE_METATYPE(bool*)
Q_DECLARE_METATYPE(CAmount) Q_DECLARE_METATYPE(CAmount)
Q_DECLARE_METATYPE(uint256)
static void InitMessage(const std::string &message) static void InitMessage(const std::string &message)
{ {

View file

@ -369,6 +369,7 @@ void SendCoinsDialog::on_sendButton_clicked()
accept(); accept();
CoinControlDialog::coinControl()->UnSelectAll(); CoinControlDialog::coinControl()->UnSelectAll();
coinControlUpdateLabels(); coinControlUpdateLabels();
Q_EMIT coinsSent(currentTransaction.getTransaction()->GetHash());
} }
fNewRecipientAllowed = true; fNewRecipientAllowed = true;
} }

View file

@ -54,6 +54,9 @@ public Q_SLOTS:
void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance); const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
Q_SIGNALS:
void coinsSent(const uint256& txid);
private: private:
Ui::SendCoinsDialog *ui; Ui::SendCoinsDialog *ui;
ClientModel *clientModel; ClientModel *clientModel;

View file

@ -263,8 +263,7 @@ void TransactionView::setModel(WalletModel *_model)
void TransactionView::chooseDate(int idx) void TransactionView::chooseDate(int idx)
{ {
if(!transactionProxyModel) if (!transactionProxyModel) return;
return;
QDate current = QDate::currentDate(); QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false); dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt()) switch(dateWidget->itemData(idx).toInt())
@ -592,6 +591,32 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
transactionView->setFocus(); transactionView->setFocus();
} }
void TransactionView::focusTransaction(const uint256& txid)
{
if (!transactionProxyModel)
return;
const QModelIndexList results = this->model->getTransactionTableModel()->match(
this->model->getTransactionTableModel()->index(0,0),
TransactionTableModel::TxHashRole,
QString::fromStdString(txid.ToString()), -1);
transactionView->setFocus();
transactionView->selectionModel()->clearSelection();
for (const QModelIndex& index : results) {
const QModelIndex targetIndex = transactionProxyModel->mapFromSource(index);
transactionView->selectionModel()->select(
targetIndex,
QItemSelectionModel::Rows | QItemSelectionModel::Select);
// Called once per destination to ensure all results are in view, unless
// transactions are not ordered by (ascending or descending) date.
transactionView->scrollTo(targetIndex);
// scrollTo() does not scroll far enough the first time when transactions
// are ordered by ascending date.
if (index == results[0]) transactionView->scrollTo(targetIndex);
}
}
// We override the virtual resizeEvent of the QWidget to adjust tables column // We override the virtual resizeEvent of the QWidget to adjust tables column
// sizes as the tables width is proportional to the dialogs width. // sizes as the tables width is proportional to the dialogs width.
void TransactionView::resizeEvent(QResizeEvent* event) void TransactionView::resizeEvent(QResizeEvent* event)

View file

@ -7,6 +7,8 @@
#include <qt/guiutil.h> #include <qt/guiutil.h>
#include <uint256.h>
#include <QWidget> #include <QWidget>
#include <QKeyEvent> #include <QKeyEvent>
@ -116,7 +118,7 @@ public Q_SLOTS:
void changedSearch(); void changedSearch();
void exportClicked(); void exportClicked();
void focusTransaction(const QModelIndex&); void focusTransaction(const QModelIndex&);
void focusTransaction(const uint256& txid);
}; };
#endif // BITCOIN_QT_TRANSACTIONVIEW_H #endif // BITCOIN_QT_TRANSACTIONVIEW_H

View file

@ -68,6 +68,9 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent):
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
connect(overviewPage, SIGNAL(outOfSyncWarningClicked()), this, SLOT(requestedSyncWarningInfo())); connect(overviewPage, SIGNAL(outOfSyncWarningClicked()), this, SLOT(requestedSyncWarningInfo()));
// Highlight transaction after send
connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), transactionView, SLOT(focusTransaction(uint256)));
// Double-clicking on a transaction on the transaction history page shows details // Double-clicking on a transaction on the transaction history page shows details
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
@ -91,6 +94,9 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
// Clicking on a transaction on the overview page simply sends you to transaction history page // Clicking on a transaction on the overview page simply sends you to transaction history page
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage())); connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage()));
// Navigate to transaction history page after send
connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), gui, SLOT(gotoHistoryPage()));
// Receive and report messages // Receive and report messages
connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int))); connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));