From f2379b36944bdfc26d5658c9ebd0b0fb154910ff Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 5 Jul 2021 23:43:26 +0300 Subject: [PATCH] Merge bitcoin-core/gui#365: Draw "eye" sign at the beginning of watch-only addresses cd46c11577a05f3dc9eac94f27a6985f6ba0509e qt: Draw "eye" sign at the beginning of watch-only addresses (Hennadii Stepanov) 9ea1da6fc91e17bdaa722001b97aadf576f07f65 qt: Do not extend recent transaction width to address/label string (Hennadii Stepanov) Pull request description: This PR guaranties that the "eye" sign won't be hidden for very long addresses/labels. No longer need to extend `TransactionOverviewWidget` widget width to make "eye" signs shown: ![Screenshot from 2021-06-15 00-21-05](https://user-images.githubusercontent.com/32963518/121961807-9123b600-cd70-11eb-8cdd-8b2b0d1bf44f.png) Fixes https://github.com/bitcoin-core/gui/issues/373 ACKs for top commit: jarolrod: ACK cd46c11577a05f3dc9eac94f27a6985f6ba0509e Tree-SHA512: 0602b5bb65d53c5b18e86260750006bba03adbae181917b5a2b7f89b17290bd1f57b4f80adaba32f42cc6fb468598a888b12c0b6b09005d2f2c07bd4d1ad334a --- src/qt/overviewpage.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 30b238d4dbe79d..ca079d9e89d160 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -95,17 +95,21 @@ class TxViewDelegate : public QAbstractItemDelegate // Address/Label colorForeground = qvariant_cast(indexAddress.data(Qt::ForegroundRole)); QString address = indexAddress.data(Qt::DisplayRole).toString(); - painter->setPen(colorForeground); - painter->drawText(rectBottomHalf, Qt::AlignLeft | Qt::AlignVCenter, address, &rectBounding); - int address_rect_min_width = rectBounding.width(); + // Optional Watchonly indicator + QRect addressRect{rectBottomHalf}; if (index.data(TransactionTableModel::WatchonlyRole).toBool()) { QIcon iconWatchonly = qvariant_cast(index.data(TransactionTableModel::WatchonlyDecorationRole)); - QRect rectWatchonly(rectBounding.right() + 5, rectBottomHalf.top(), 16, halfheight); - iconWatchonly.paint(painter, rectWatchonly); + QRect watchonlyRect(rectBottomHalf.left(), rectBottomHalf.top(), rectBottomHalf.height(), halfheight); + iconWatchonly.paint(painter, watchonlyRect); + addressRect.setLeft(addressRect.left() + watchonlyRect.width() + 5); } + painter->setPen(colorForeground); + painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &rectBounding); + int address_rect_min_width = rectBounding.width(); + const int minimum_width = std::max(address_rect_min_width, amount_bounding_rect.width() /*+ date_bounding_rect.width() */); const auto search = m_minimum_width.find(index.row()); if (search == m_minimum_width.end() || search->second != minimum_width) {