diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 451f34da5..5c461c1ef 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2370,6 +2370,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_app_store" = "App Store"; "lng_credits_box_history_entry_fragment" = "Fragment"; "lng_credits_box_history_entry_ads" = "Ads Platform"; +"lng_credits_box_history_entry_premium_bot" = "Stars Top-Up"; +"lng_credits_box_history_entry_via_premium_bot" = "Premium Bot"; "lng_credits_box_history_entry_id" = "Transaction ID"; "lng_credits_box_history_entry_id_copied" = "Transaction ID copied to clipboard."; "lng_credits_box_history_entry_success_date" = "Transaction date"; diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 58dc2941f..fdf1eda03 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1702,6 +1702,12 @@ void AddCreditsHistoryEntryTable( table, tr::lng_credits_box_history_entry_via(), tr::lng_credits_box_history_entry_ads(Ui::Text::RichLangValue)); + } else if (entry.peerType == Type::PremiumBot) { + AddTableRow( + table, + tr::lng_credits_box_history_entry_via(), + tr::lng_credits_box_history_entry_via_premium_bot( + Ui::Text::RichLangValue)); } if (!entry.id.isEmpty()) { constexpr auto kOneLineCount = 18; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 956c7d0c3..a176be565 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -954,8 +954,6 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) { if (const auto peerId = PeerId(item.barePeerId)) { const auto peer = session().data().peer(peerId); return std::make_unique(peer, descriptor); - } else if (item.peerType == Type::PremiumBot) { - return std::make_unique(_premiumBot, descriptor); } else { return std::make_unique(descriptor); } diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 3b88e8d48..282945d9e 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -448,7 +448,7 @@ void ReceiptCreditsBox( const auto &stUser = st::boostReplaceUserpic; const auto session = &controller->session(); const auto peer = (e.peerType == Type::PremiumBot) - ? premiumBot + ? nullptr : e.barePeerId ? session->data().peer(PeerId(e.barePeerId)).get() : nullptr; @@ -622,6 +622,33 @@ void ReceiptCreditsBox( Ui::AddSkip(content); + if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) { + const auto widget = Ui::CreateChild(content); + using ColoredMiniStars = Ui::Premium::ColoredMiniStars; + const auto stars = widget->lifetime().make_state( + widget, + false, + Ui::Premium::MiniStars::Type::BiStars); + stars->setColorOverride(Ui::Premium::CreditsIconGradientStops()); + widget->resize( + st::boxWidth - stUser.photoSize, + stUser.photoSize * 2); + content->sizeValue( + ) | rpl::start_with_next([=](const QSize &size) { + widget->moveToLeft(stUser.photoSize / 2, 0); + const auto starsRect = Rect(widget->size()); + stars->setPosition(starsRect.topLeft()); + stars->setSize(starsRect.size()); + widget->lower(); + }, widget->lifetime()); + widget->paintRequest( + ) | rpl::start_with_next([=](const QRect &r) { + auto p = QPainter(widget); + p.fillRect(r, Qt::transparent); + stars->paint(p); + }, widget->lifetime()); + } + const auto button = box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); }); diff --git a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp index 3f4ce02f2..e99a4d4eb 100644 --- a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp @@ -193,6 +193,21 @@ not_null AddInputFieldForCredits( PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( const Data::CreditsHistoryEntry &entry) { + using PeerType = Data::CreditsHistoryEntry::PeerType; + if (entry.peerType == PeerType::PremiumBot) { + const auto svg = std::make_shared(Ui::Premium::Svg()); + return [=](Painter &p, int x, int y, int, int size) mutable { + const auto hq = PainterHighQualityEnabler(p); + p.setPen(Qt::NoPen); + { + auto gradient = QLinearGradient(x + size, y + size, x, y); + gradient.setStops(Ui::Premium::ButtonGradientStops()); + p.setBrush(gradient); + } + p.drawEllipse(x, y, size, size); + svg->render(&p, QRectF(x, y, size, size) - Margins(size / 5.)); + }; + } const auto bg = [&]() -> EmptyUserpic::BgColors { switch (entry.peerType) { case Data::CreditsHistoryEntry::PeerType::Peer: @@ -218,10 +233,6 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( const auto userpic = std::make_shared(bg, QString()); return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { userpic->paintCircle(p, x, y, outerWidth, size); - using PeerType = Data::CreditsHistoryEntry::PeerType; - if (entry.peerType == PeerType::PremiumBot) { - return; - } const auto rect = QRect(x, y, size, size); ((entry.peerType == PeerType::AppStore) ? st::sessionIconiPhone @@ -446,6 +457,8 @@ Fn)> PaintPreviewCallback( TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) { return ((entry.peerType == Data::CreditsHistoryEntry::PeerType::Fragment) ? tr::lng_bot_username_description1_link + : (entry.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) + ? tr::lng_credits_box_history_entry_premium_bot : (entry.peerType == Data::CreditsHistoryEntry::PeerType::Ads) ? tr::lng_credits_box_history_entry_ads : tr::lng_credits_summary_history_entry_inner_in)(