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

pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:2018/02/qt-goto-transactions-after-send changing 6 files +42 −3
  1. Sjors commented at 11:03 am on February 13, 2018: member

    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.

  2. laanwj added the label GUI on Feb 13, 2018
  3. laanwj commented at 11:19 am on February 13, 2018: member
    Concept ACK
  4. MarcoFalke commented at 1:10 pm on February 13, 2018: member
    utACK ddbc5aaee1bdb69583eb711ad3145fa5f8b67933
  5. promag commented at 6:04 pm on February 13, 2018: member

    just remained on the Send tab, which I found confusing

    IMHO this is more confusing, having such sudden UI change. What if he wants to do multiple sends?

    How about adding a checkbox like [x] View transaction after sending and remembering the checkbox state in settings?

  6. in src/qt/sendcoinsdialog.h:58 in ddbc5aaee1 outdated
    53@@ -54,6 +54,9 @@ public Q_SLOTS:
    54     void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
    55                     const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
    56 
    57+Q_SIGNALS:
    58+    void transactionSent();
    


    promag commented at 6:07 pm on February 13, 2018:
    If the idea is to highlight the transaction, adding the txid or like can help.

    Sjors commented at 9:42 am on February 14, 2018:
    I can extract the tx id and pass it along as a string. The part I couldn’t figure out is how to convert that to whatever focusTransaction(const QModelIndex &idx) needs.

    promag commented at 4:49 pm on February 14, 2018:

    Nit, rename to coinsSent().

    Regarding row focus, see https://stackoverflow.com/a/35154534.


    Sjors commented at 5:57 pm on February 15, 2018:
    Done
  7. Sjors commented at 9:28 am on February 14, 2018: member

    @promag I don’t think I’ve ever seen an online banking application that doesn’t take the user to the transaction overview page after sending money.

    In most financial applications Send is a modal experience, where the Send screen is pushed on top of the transaction screen and popped when the user is done. In a desktop browser that’s usually a modal window, on an iPhone it’s a window that animates in from the right, with an arrow on the top left to dismiss it. Doing another send is then simply a matter of clicking on Send again.

    Making the experience modal might be too much of a change, but e.g. we could get rid of all tabs: merge the Overview and Transactions tab, Send and Receive open a new window.

    I do think highlighting the new transaction would give a better visual clue to the user as to why they moved to this other tab.

  8. jonasschnelli commented at 9:33 am on February 14, 2018: contributor
    utACK ddbc5aaee1bdb69583eb711ad3145fa5f8b67933
  9. in src/qt/sendcoinsdialog.cpp:373 in ddbc5aaee1 outdated
    368@@ -369,6 +369,8 @@ void SendCoinsDialog::on_sendButton_clicked()
    369         accept();
    370         CoinControlDialog::coinControl()->UnSelectAll();
    371         coinControlUpdateLabels();
    372+        // Navigate to transaction history page:
    


    promag commented at 4:48 pm on February 14, 2018:
    Remove comment? It’s only relevant below when connecting.

    promag commented at 5:00 pm on February 14, 2018:

    BTW, add

    0    ui->checkBoxCoinControlChange->setChecked(false);
    1    ui->lineEditCoinControlChange->clear();
    

    like #12432?


    Sjors commented at 4:24 pm on February 15, 2018:
    Coin control fields, custom change address and selected inputs, are already cleared after you send.

    promag commented at 4:36 pm on February 15, 2018:
    Please verify custom change address checkbox and line edit because here they are not cleared.

    Sjors commented at 5:57 pm on February 15, 2018:
    Removed

    Sjors commented at 6:01 pm on February 15, 2018:
    You’re right. Turns out #12432 fixes that, because SendCoinsDialog::accept() is called when the transaction is sent, which in turn calls clear().
  10. promag commented at 4:53 pm on February 14, 2018: member
    @Sjors like you say the current layout is very different from those you mention. Anyway, ACK with the row focus.
  11. practicalswift commented at 5:55 pm on February 14, 2018: contributor
    Concept ACK
  12. randolf commented at 2:31 am on February 15, 2018: contributor
    Concept ACK.
  13. Sjors force-pushed on Feb 15, 2018
  14. Sjors force-pushed on Feb 15, 2018
  15. Sjors force-pushed on Feb 15, 2018
  16. Sjors commented at 5:57 pm on February 15, 2018: member
    It now highlights the transaction.
  17. in src/qt/transactionview.cpp:605 in 44c7768a68 outdated
    600+    const QModelIndexList results = this->model->getTransactionTableModel()->match(
    601+        this->model->getTransactionTableModel()->index(0,0),
    602+        TransactionTableModel::TxHashRole,
    603+        hash);
    604+
    605+    if (!results.length()) 
    


    promag commented at 6:21 pm on February 15, 2018:
    0if (results.isEmpty()) return;
    

    Sjors commented at 3:46 pm on February 16, 2018:
    Fixed.
  18. in src/qt/transactionview.cpp:596 in 44c7768a68 outdated
    591@@ -592,6 +592,22 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
    592     transactionView->setFocus();
    593 }
    594 
    595+void TransactionView::focusTransaction(const QString &hash)
    596+{
    597+    if(!transactionProxyModel)
    


    promag commented at 6:21 pm on February 15, 2018:
    Space after if, one line.

    Sjors commented at 3:46 pm on February 16, 2018:
    Fixed.
  19. in src/qt/sendcoinsdialog.h:58 in 44c7768a68 outdated
    53@@ -54,6 +54,9 @@ public Q_SLOTS:
    54     void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
    55                     const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
    56 
    57+Q_SIGNALS:
    58+    void coinsSent(QString);
    


    promag commented at 6:22 pm on February 15, 2018:
    const QString& txid so that it’s clear what the argument is?

    Sjors commented at 3:46 pm on February 16, 2018:
    Done.
  20. in src/qt/transactionview.cpp:599 in 44c7768a68 outdated
    591@@ -592,6 +592,22 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
    592     transactionView->setFocus();
    593 }
    594 
    595+void TransactionView::focusTransaction(const QString &hash)
    596+{
    597+    if(!transactionProxyModel)
    598+        return;
    599+
    600+    const QModelIndexList results = this->model->getTransactionTableModel()->match(
    


    promag commented at 6:29 pm on February 15, 2018:
    IIRC this performs linear search. Probably something worth to optimise in case of bigger wallets in the future.

    Sjors commented at 3:19 pm on February 16, 2018:
    Are transactions in reverse chronological order? In that case it should be pretty quick, unless some race condition causes the new transaction to be missing.

    luke-jr commented at 3:26 pm on February 27, 2018:
    Transactions are displayed in whatever order the user chooses. I’m not sure what order is internally used, however…

    Sjors commented at 11:32 am on February 28, 2018:
    I created a fresh wallet and then called generate 10000. I didn’t notice any delay when sending transactions, although my machine is relatively fast. I also tried reversing transaction order in the view.
  21. Sjors force-pushed on Feb 16, 2018
  22. in src/qt/sendcoinsdialog.cpp:374 in ea04610f71 outdated
    369@@ -369,6 +370,8 @@ void SendCoinsDialog::on_sendButton_clicked()
    370         accept();
    371         CoinControlDialog::coinControl()->UnSelectAll();
    372         coinControlUpdateLabels();
    373+        const uint256 txid = currentTransaction.getTransaction()->GetHash();
    374+        Q_EMIT coinsSent(QString::fromStdString(txid.ToString()));
    


    jonasschnelli commented at 11:00 am on February 17, 2018:
    Meh on using strings for internal uint256 transport. Why not uint256? Could also register the type if not yet supported.

    Sjors commented at 11:46 am on February 19, 2018:
    I tried passing the uint256 directly and got a bloodbath of compiler errors. How do I go about registering the type?

  23. Sjors force-pushed on Feb 19, 2018
  24. Sjors commented at 3:29 pm on February 19, 2018: member
    Now passing the transaction hash as uint256.
  25. in src/qt/sendcoinsdialog.cpp:16 in fdea3820e2 outdated
    12@@ -13,6 +13,7 @@
    13 #include <qt/optionsmodel.h>
    14 #include <qt/platformstyle.h>
    15 #include <qt/sendcoinsentry.h>
    16+#include <qt/transactiontablemodel.h>
    


    promag commented at 4:03 pm on February 19, 2018:
    Can be removed.

    Sjors commented at 12:22 pm on February 20, 2018:
    Fixed
  26. in src/qt/sendcoinsdialog.h:58 in fdea3820e2 outdated
    53@@ -54,6 +54,9 @@ public Q_SLOTS:
    54     void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
    55                     const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
    56 
    57+Q_SIGNALS:
    58+    void coinsSent(const uint256 txid);
    


    promag commented at 4:04 pm on February 19, 2018:
    Use reference? const uint256& txid.

    Sjors commented at 12:22 pm on February 20, 2018:
    Fixed
  27. in src/qt/transactionview.cpp:594 in fdea3820e2 outdated
    590@@ -592,6 +591,21 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
    591     transactionView->setFocus();
    592 }
    593 
    594+void TransactionView::focusTransaction(const uint256 txid)
    


    promag commented at 4:04 pm on February 19, 2018:
    Use reference? const uint256& txid.
  28. promag commented at 4:05 pm on February 19, 2018: member
    Tested ACK fdea382.
  29. Sjors force-pushed on Feb 20, 2018
  30. promag commented at 2:09 pm on February 20, 2018: member
    reACK b7ebe39, only changes are the suggested above.
  31. luke-jr commented at 3:25 pm on February 27, 2018: member

    What if he wants to do multiple sends? @promag Then he should do them all at once…

  32. in src/qt/transactionview.cpp:606 in b7ebe39ac6 outdated
    601+        TransactionTableModel::TxHashRole,
    602+        QString::fromStdString(txid.ToString()));
    603+
    604+    if (results.isEmpty()) return;
    605+
    606+    focusTransaction(results[0]);
    


    luke-jr commented at 3:27 pm on February 27, 2018:
    We support selecting multiple transactions, so this ought to select all of them…

    Sjors commented at 4:01 pm on February 27, 2018:
    I consider more than 1 result an error, given that we’re passing a single tx id. I could replace the isEmpty() with a check that length is 1.

    luke-jr commented at 4:13 pm on February 27, 2018:
    It’s definitely not an error. The transaction list shows logical transactions, not blockchain transactions. There is 1 txid per blockchain transaction, but that could be many logical transactions.

    Sjors commented at 4:58 pm on February 27, 2018:
    Ah, I see what you mean. E.g. sending to two destinations in one transaction results in two rows in the transactions tab.

    promag commented at 12:26 pm on February 28, 2018:
    @luke-jr :+1:
  33. promag commented at 3:33 pm on February 27, 2018: member
    @luke-jr agree, came to the same conclusion little after.
  34. Sjors commented at 5:39 pm on February 27, 2018: member

    I’d like to select both entries on the transaction screen when a user sends to two addresses. Unfortunately:

    • this->model->getTransactionTableModel()->match(... only returns one entry.
    • transactionView->selectRow(...) deselects whichever row was previously selected (even though the user can manually select multiple transactions)
  35. luke-jr commented at 6:34 pm on February 27, 2018: member

    https://doc.qt.io/qt-5/qtableview.html#setSelection with QItemSelectionModel::Rows (and probably QItemSelectionModel::ClearAndSelect).

    Why would match only return one entry??

  36. Sjors commented at 9:37 am on February 28, 2018: member

    Why would match only return one entry??

    I don’t know. Here’s a WIP commit. The fprintf(stderr, "row: line is only called once.

    I’m confused about the relation between this->model->getTransactionTableModel(), transactionView and transactionProxyModel. E.g. what does QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx); do? My intuitive grasp is that there’s somehow multiple representations of the same data. Maybe @laanwj can explain the big picture here?

  37. Sjors commented at 11:21 am on February 28, 2018: member
    I added @promag’s commit to enable multi row selection. Note that if the user scrolls down, it won’t scroll up. And if the user orders transactions by ascending date and scrolls down, it won’t scroll further down to reveal the new transaction.
  38. in src/qt/transactionview.cpp:606 in 1dc5cfcec5 outdated
    601+        TransactionTableModel::TxHashRole,
    602+        QString::fromStdString(txid.ToString()), -1);
    603+
    604+    transactionView->setFocus();
    605+    transactionView->selectionModel()->clearSelection();
    606+    for (const QModelIndex& index : results) {
    


    promag commented at 12:21 pm on February 28, 2018:

    We could ensure first row is visible:

    0for (...) {
    1    if (index == results[0]) transactionView->scrollTo(index);
    

    Sjors commented at 2:46 pm on February 28, 2018:
    That worked (using transactionProxyModel->mapFromSource) when transactions are ordered by date. Unfortunately when they’re ordered in reverse it doesn’t scroll all the way to the bottom. Maybe we need to wait a little bit for transactionView to become aware of its new size?
  39. in src/qt/transactionview.cpp:596 in 1dc5cfcec5 outdated
    590@@ -592,6 +591,25 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
    591     transactionView->setFocus();
    592 }
    593 
    594+void TransactionView::focusTransaction(const uint256& txid)
    595+{
    596+    if(!transactionProxyModel)
    


    promag commented at 12:22 pm on February 28, 2018:
    Nit, add space after if.

    Sjors commented at 2:46 pm on February 28, 2018:
    Fixed
  40. in src/qt/sendcoinsdialog.cpp:372 in 1dc5cfcec5 outdated
    368@@ -369,6 +369,8 @@ void SendCoinsDialog::on_sendButton_clicked()
    369         accept();
    370         CoinControlDialog::coinControl()->UnSelectAll();
    371         coinControlUpdateLabels();
    372+        const uint256 txid = currentTransaction.getTransaction()->GetHash();
    


    promag commented at 12:23 pm on February 28, 2018:

    Avoid copy here:

    0const uint256& txid = ...
    

    laanwj commented at 12:47 pm on February 28, 2018:

    Or roll it into the Q_EMIT, as txid is not used after this. YMMV. For performance I’d be surprised it makes any difference.

    0Q_EMIT coinsSent(currentTransaction.getTransaction()->GetHash());
    

    Sjors commented at 2:46 pm on February 28, 2018:
    Rolled into Q_EMIT.
  41. promag commented at 12:25 pm on February 28, 2018: member
    Tested ACK after squash and comments addressed.
  42. laanwj commented at 12:42 pm on February 28, 2018: member

    @promag I don’t think I’ve ever seen an online banking application that doesn’t take the user to the transaction overview page after sending money. @promag Then he should do them all at once…

    +1

  43. laanwj approved
  44. laanwj commented at 12:48 pm on February 28, 2018: member
    utACK
  45. Sjors force-pushed on Feb 28, 2018
  46. Sjors force-pushed on Feb 28, 2018
  47. [qt] navigate to transaction history page after send
    The transaction will be selected. When sending to multiple
    destinations, all will be selected (thanks @promag).
    e7d9fc5c53
  48. in src/qt/transactionview.cpp:616 in 48ef8d8986 outdated
    606+    for (const QModelIndex& index : results) {
    607+        const QModelIndex targetIndex = transactionProxyModel->mapFromSource(index);
    608+        transactionView->selectionModel()->select(
    609+            targetIndex,
    610+            QItemSelectionModel::Rows | QItemSelectionModel::Select);
    611+        if (index == results[0]) transactionView->scrollTo(targetIndex);
    


    promag commented at 4:49 pm on February 28, 2018:

    On my system calling transactionView->scrollTo(targetIndex) for every model index fixes it (not sure why). It also works in the default order because scroll hint is QAbstractItemView::EnsureVisible, so focusing the 2nd row will not remove the 1st from the viewport (the 2nd row is already visible).

    But it’s also possible to order by other column (for instance address), and in that case it can be impossible to show the whole selection in the table viewport.

    I see 3 possible solutions for that:

    • do nothing :trollface:;
    • automatically sort by date descending (new rows will be the first);
    • automatically fill the filter field with the new txid.

    Sjors commented at 9:26 am on March 1, 2018:

    When I call scrollTo for every model index and transactions are sort by ascending date, things get weird: if I send to two destinations it scrolls correctly, but if I send to one destination it won’t scroll far enough.

    Calling scollTo() twice “fixes” it. Seems suspiciously similar to this ~I’ll poke around a bit~.

    I prefer your first solution for the case where transactions are not ordered by date. At least one of them will be in view.

  49. Sjors force-pushed on Mar 1, 2018
  50. laanwj merged this on Mar 1, 2018
  51. laanwj closed this on Mar 1, 2018

  52. laanwj referenced this in commit be263faf87 on Mar 1, 2018
  53. Sjors deleted the branch on Mar 1, 2018
  54. MarcoFalke referenced this in commit 4732fa133a on Aug 20, 2018
  55. PastaPastaPasta referenced this in commit bbb7ea36f8 on Jun 10, 2020
  56. PastaPastaPasta referenced this in commit 3f99f5103f on Jun 12, 2020
  57. PastaPastaPasta referenced this in commit 919f1ea547 on Jun 13, 2020
  58. PastaPastaPasta referenced this in commit 20c216430b on Jun 14, 2020
  59. PastaPastaPasta referenced this in commit eaf79feda0 on Jun 14, 2020
  60. Munkybooty referenced this in commit 4b01e6d453 on Jun 30, 2021
  61. Munkybooty referenced this in commit 0d8f98b21e on Jun 30, 2021
  62. Munkybooty referenced this in commit dc4e393e67 on Jun 30, 2021
  63. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-04 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me