diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d34b064f3..17bc96f9c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -5164,6 +5164,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_channel_earn_history_return" = "Refund"; "lng_channel_earn_history_return_about" = "Refunded back"; "lng_channel_earn_history_pending" = "Pending"; +"lng_channel_earn_history_failed" = "Failed"; "lng_channel_earn_history_show_more#one" = "Show {count} More Transaction"; "lng_channel_earn_history_show_more#other" = "Show {count} More Transactions"; "lng_channel_earn_off" = "Switch Off Ads"; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index f319f873b..92920d2fc 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -782,13 +782,17 @@ void CreditsRow::init() { langDateTimeFull(_entry.date) + (_entry.refunded ? (joiner + tr::lng_channel_earn_history_return(tr::now)) + : _entry.pending + ? (joiner + tr::lng_channel_earn_history_pending(tr::now)) + : _entry.failed + ? (joiner + tr::lng_channel_earn_history_failed(tr::now)) : QString()) + (_entry.title.isEmpty() ? QString() : (joiner + _name))); { constexpr auto kMinus = QChar(0x2212); _rightText.setText( st::semiboldTextStyle, - ((!_entry.bareId || _entry.refunded) ? QChar('+') : kMinus) + (_entry.in ? QChar('+') : kMinus) + Lang::FormatCountDecimal(std::abs(int64(_entry.credits)))); } if (!_paintUserpicCallback) { @@ -836,7 +840,9 @@ void CreditsRow::rightActionPaint( bool actionSelected) { const auto &font = _rightText.style()->font; y += _rowHeight / 2; - p.setPen((!_entry.bareId || _entry.refunded) + p.setPen(_entry.pending + ? st::creditsStroke + : _entry.in ? st::boxTextFgGood : st::menuIconAttentionColor); x += st::creditsHistoryRightSkip; diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index a8aab17c3..4eec43924 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -389,14 +389,19 @@ void ReceiptCreditsBox( auto &lifetime = content->lifetime(); const auto text = lifetime.make_state( st::semiboldTextStyle, - ((!e.bareId || e.refunded) ? QChar('+') : kMinus) + (e.in ? QChar('+') : kMinus) + Lang::FormatCountDecimal(std::abs(int64(e.credits)))); - const auto refundedText = tr::lng_channel_earn_history_return( - tr::now); - const auto refunded = e.refunded + const auto roundedText = e.refunded + ? tr::lng_channel_earn_history_return(tr::now) + : e.pending + ? tr::lng_channel_earn_history_pending(tr::now) + : e.failed + ? tr::lng_channel_earn_history_failed(tr::now) + : QString(); + const auto rounded = !roundedText.isEmpty() ? lifetime.make_state( st::defaultTextStyle, - refundedText) + roundedText) : (Ui::Text::String*)(nullptr); const auto amount = content->add( @@ -404,23 +409,25 @@ void ReceiptCreditsBox( content, star.height() / style::DevicePixelRatio())); const auto font = text->style()->font; - const auto refundedFont = st::defaultTextStyle.font; + const auto roundedFont = st::defaultTextStyle.font; const auto starWidth = star.width() / style::DevicePixelRatio(); - const auto refundedSkip = refundedFont->spacew * 2; - const auto refundedWidth = refunded - ? refundedFont->width(refundedText) - + refundedSkip - + refundedFont->height + const auto roundedSkip = roundedFont->spacew * 2; + const auto roundedWidth = rounded + ? roundedFont->width(roundedText) + + roundedSkip + + roundedFont->height : 0; const auto fullWidth = text->maxWidth() + font->spacew * 1 + starWidth - + refundedWidth; + + roundedWidth; amount->paintRequest( ) | rpl::start_with_next([=] { auto p = Painter(amount); - p.setPen((!e.bareId || e.refunded) + p.setPen(e.pending + ? st::creditsStroke + : e.in ? st::boxTextFgGood : st::menuIconAttentionColor); const auto x = (amount->width() - fullWidth) / 2; @@ -432,15 +439,15 @@ void ReceiptCreditsBox( .availableWidth = amount->width(), }); p.drawImage( - x + fullWidth - starWidth - refundedWidth, + x + fullWidth - starWidth - roundedWidth, 0, star); - if (refunded) { - const auto refundedLeft = fullWidth + if (rounded) { + const auto roundedLeft = fullWidth + x - - refundedWidth - + refundedSkip; + - roundedWidth + + roundedSkip; const auto pen = p.pen(); auto color = pen.color(); color.setAlphaF(color.alphaF() * 0.15); @@ -449,20 +456,20 @@ void ReceiptCreditsBox( { auto hq = PainterHighQualityEnabler(p); p.drawRoundedRect( - refundedLeft, - (amount->height() - refundedFont->height) / 2, - refundedWidth - refundedSkip, - refundedFont->height, - refundedFont->height / 2, - refundedFont->height / 2); + roundedLeft, + (amount->height() - roundedFont->height) / 2, + roundedWidth - roundedSkip, + roundedFont->height, + roundedFont->height / 2, + roundedFont->height / 2); } p.setPen(pen); - refunded->draw(p, Ui::Text::PaintContext{ + rounded->draw(p, Ui::Text::PaintContext{ .position = QPoint( - refundedLeft + refundedFont->height / 2, - (amount->height() - refundedFont->height) / 2), - .outerWidth = refundedWidth, - .availableWidth = refundedWidth, + roundedLeft + roundedFont->height / 2, + (amount->height() - roundedFont->height) / 2), + .outerWidth = roundedWidth, + .availableWidth = roundedWidth, }); } }, amount->lifetime());