diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp index a38a34234..87d8ead06 100644 --- a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp @@ -312,7 +312,8 @@ void CreateGiveawayBox( lt_duration, tr::lng_premium_gift_duration_months( lt_count, - rpl::single(prepaid->months) | tr::to_count()))) + rpl::single(prepaid->months) | tr::to_count())), + QImage()) )->setAttribute(Qt::WA_TransparentForMouseEvents); } if (!prepaid) { diff --git a/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.cpp b/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.cpp index e54ba3540..4417bfb25 100644 --- a/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.cpp +++ b/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.cpp @@ -36,7 +36,8 @@ GiveawayTypeRow::GiveawayTypeRow( : (type == Type::AllMembers) ? tr::lng_giveaway_users_all() : tr::lng_giveaway_users_new(), - std::move(subtitle)) { + std::move(subtitle), + QImage()) { } GiveawayTypeRow::GiveawayTypeRow( @@ -44,7 +45,8 @@ GiveawayTypeRow::GiveawayTypeRow( Type type, int colorIndex, rpl::producer title, - rpl::producer subtitle) + rpl::producer subtitle, + QImage badge) : RippleButton(parent, st::defaultRippleAnimation) , _type(type) , _st((_type == Type::SpecificUsers || _type == Type::Random) @@ -54,7 +56,8 @@ GiveawayTypeRow::GiveawayTypeRow( : st::giveawayGiftCodeMembersPeerList.item) , _userpic( Ui::EmptyUserpic::UserpicColor(Ui::EmptyUserpic::ColorIndex(colorIndex)), - QString()) { + QString()) +, _badge(std::move(badge)) { std::move( subtitle ) | rpl::start_with_next([=] (const QString &s) { @@ -111,8 +114,19 @@ void GiveawayTypeRow::paintEvent(QPaintEvent *e) { const auto namey = _st.namePosition.y(); const auto namew = outerWidth - namex - skipRight; + const auto badgew = _badge.width() / style::DevicePixelRatio(); + p.setPen(_st.nameFg); - _name.drawLeftElided(p, namex, namey, namew, width()); + _name.drawLeftElided(p, namex, namey, namew - badgew, width()); + + if (!_badge.isNull()) { + p.drawImage( + std::min( + namex + _name.maxWidth() + st::boostsListBadgePadding.left(), + outerWidth - badgew - skipRight), + namey + st::boostsListMiniIconSkip, + _badge); + } const auto statusx = _st.statusPosition.x(); const auto statusy = _st.statusPosition.y(); diff --git a/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.h b/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.h index 67b1e92ad..9bb96812b 100644 --- a/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.h +++ b/Telegram/SourceFiles/info/boosts/giveaway/giveaway_type_row.h @@ -39,7 +39,8 @@ public: Type type, int colorIndex, rpl::producer title, - rpl::producer subtitle); + rpl::producer subtitle, + QImage badge); void addRadio(std::shared_ptr> typeGroup); @@ -56,6 +57,8 @@ private: Ui::Text::String _status; Ui::Text::String _name; + QImage _badge; + }; } // namespace Giveaway diff --git a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp index e4abe223f..dc787dd60 100644 --- a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp +++ b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_user.h" #include "info/boosts/create_giveaway_box.h" +#include "info/boosts/giveaway/boost_badge.h" #include "info/boosts/giveaway/giveaway_type_row.h" #include "info/boosts/info_boosts_widget.h" #include "info/info_controller.h" @@ -326,6 +327,8 @@ void InnerWidget::fill() { ::Settings::AddSkip(inner); if (!status.prepaidGiveaway.empty()) { + const auto multiplier = Api::PremiumGiftCodeOptions(_peer) + .giveawayBoostsPerPremium(); ::Settings::AddSkip(inner); AddHeader(inner, tr::lng_boosts_prepaid_giveaway_title); ::Settings::AddSkip(inner); @@ -340,7 +343,17 @@ void InnerWidget::fill() { rpl::single(g.quantity) | tr::to_count()), tr::lng_boosts_prepaid_giveaway_moths( lt_count, - rpl::single(g.months) | tr::to_count()))); + rpl::single(g.months) | tr::to_count()), + Info::Statistics::CreateBadge( + st::statisticsDetailsBottomCaptionStyle, + QString::number(g.quantity * multiplier), + st::boostsListBadgeHeight, + st::boostsListBadgeTextPadding, + st::premiumButtonBg2, + st::premiumButtonFg, + 1., + st::boostsListMiniIconPadding, + st::boostsListMiniIcon))); button->setClickedCallback([=] { _controller->uiShow()->showBox(Box( CreateGiveawayBox,