| 71 | } |
| 72 | |
| 73 | void AddressInputWidget::paintEvent(QPaintEvent* const event) |
| 74 | { |
| 75 | QLineEdit::paintEvent(event); |
| 76 | |
| 77 | const QColor placeholderTextColor{palette().color(QPalette::PlaceholderText)}; |
| 78 | const QColor textColor{palette().color(QPalette::Text)}; |
| 79 | const QColor prefixColor{ |
| 80 | (placeholderTextColor.red() + textColor.red()) / 2, |
| 81 | (placeholderTextColor.green() + textColor.green()) / 2, |
| 82 | (placeholderTextColor.blue() + textColor.blue()) / 2, |
| 83 | }; |
| 84 | |
| 85 | QStyleOptionFrame panel{}; |
| 86 | initStyleOption(&panel); |
| 87 | const QRect contentsRect{style()->subElementRect(QStyle::SE_LineEditContents, &panel, this)}; |
| 88 | const int x{contentsRect.x() + horizontalMargin - AddressInputWidget::calcPrefixWidth()}; |
| 89 | const int y{(rect().height() + fontMetrics().tightBoundingRect("0x").height()) / 2}; |
| 90 | |
| 91 | QPainter painter(this); |
| 92 | painter.setPen(prefixColor); |
| 93 | painter.setFont(font()); |
| 94 | painter.drawText(x, y, "0x"); |
| 95 | } |
| 96 | |
| 97 | int AddressInputWidget::calcPrefixWidth() |
| 98 | { |
nothing calls this directly
no outgoing calls
no test coverage detected