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
This commit is contained in:
Hennadii Stepanov 2021-07-05 23:43:26 +03:00 committed by Konstantin Akimov
parent c52a582a3f
commit 7aeb0adeb9
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -95,17 +95,21 @@ public:
// Address/Label // Address/Label
colorForeground = qvariant_cast<QColor>(indexAddress.data(Qt::ForegroundRole)); colorForeground = qvariant_cast<QColor>(indexAddress.data(Qt::ForegroundRole));
QString address = indexAddress.data(Qt::DisplayRole).toString(); 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 // Optional Watchonly indicator
QRect addressRect{rectBottomHalf};
if (index.data(TransactionTableModel::WatchonlyRole).toBool()) if (index.data(TransactionTableModel::WatchonlyRole).toBool())
{ {
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole)); QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect rectWatchonly(rectBounding.right() + 5, rectBottomHalf.top(), 16, halfheight); QRect watchonlyRect(rectBottomHalf.left(), rectBottomHalf.top(), rectBottomHalf.height(), halfheight);
iconWatchonly.paint(painter, rectWatchonly); 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 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()); const auto search = m_minimum_width.find(index.row());
if (search == m_minimum_width.end() || search->second != minimum_width) { if (search == m_minimum_width.end() || search->second != minimum_width) {