Improved style of list of credits history entries for refunded entry.

This commit is contained in:
23rd 2024-05-29 03:50:52 +03:00 committed by John Preston
parent d3a01b6235
commit 57ecc2be1d

View file

@ -744,6 +744,7 @@ private:
const int _rowHeight; const int _rowHeight;
PaintRoundImageCallback _paintUserpicCallback; PaintRoundImageCallback _paintUserpicCallback;
QString _name;
Ui::Text::String _rightText; Ui::Text::String _rightText;
}; };
@ -773,12 +774,21 @@ CreditsRow::CreditsRow(const Descriptor &descriptor)
} }
void CreditsRow::init() { void CreditsRow::init() {
PeerListRow::setCustomStatus(langDateTimeFull(_entry.date)); _name = !PeerListRow::special()
? PeerListRow::generateName()
: Ui::GenerateEntryName(_entry).text;
const auto joiner = QString(QChar(' ')) + QChar(8212) + QChar(' ');
PeerListRow::setCustomStatus(
langDateTimeFull(_entry.date)
+ (_entry.refunded
? (joiner + tr::lng_channel_earn_history_return(tr::now))
: QString())
+ (_entry.title.isEmpty() ? QString() : (joiner + _name)));
{ {
constexpr auto kMinus = QChar(0x2212); constexpr auto kMinus = QChar(0x2212);
_rightText.setText( _rightText.setText(
st::semiboldTextStyle, st::semiboldTextStyle,
(!_entry.bareId ? QChar('+') : kMinus) ((!_entry.bareId || _entry.refunded) ? QChar('+') : kMinus)
+ Lang::FormatCountDecimal(std::abs(int64(_entry.credits)))); + Lang::FormatCountDecimal(std::abs(int64(_entry.credits))));
} }
if (!_paintUserpicCallback) { if (!_paintUserpicCallback) {
@ -793,9 +803,7 @@ const Data::CreditsHistoryEntry &CreditsRow::entry() const {
} }
QString CreditsRow::generateName() { QString CreditsRow::generateName() {
return !PeerListRow::special() return _entry.title.isEmpty() ? _name : _entry.title;
? PeerListRow::generateName()
: Ui::GenerateEntryName(_entry).text;
} }
PaintRoundImageCallback CreditsRow::generatePaintUserpicCallback(bool force) { PaintRoundImageCallback CreditsRow::generatePaintUserpicCallback(bool force) {
@ -828,7 +836,7 @@ void CreditsRow::rightActionPaint(
bool actionSelected) { bool actionSelected) {
const auto &font = _rightText.style()->font; const auto &font = _rightText.style()->font;
y += _rowHeight / 2; y += _rowHeight / 2;
p.setPen(!_entry.bareId p.setPen((!_entry.bareId || _entry.refunded)
? st::boxTextFgGood ? st::boxTextFgGood
: st::menuIconAttentionColor); : st::menuIconAttentionColor);
x += st::creditsHistoryRightSkip; x += st::creditsHistoryRightSkip;