From cdc8b8e473c4e3e3cc85d88bf0d59e0919a7fc52 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 20 Nov 2025 21:53:35 +0400 Subject: [PATCH] Show nice userpics in change recipient. --- .../boxes/peers/replace_boost_box.cpp | 41 ++++++++++--------- .../boxes/peers/replace_boost_box.h | 1 + .../boxes/star_gift_auction_box.cpp | 27 ++++++++---- Telegram/SourceFiles/ui/effects/credits.style | 1 + 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp index 6f28d282d0..1990af38cd 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp @@ -577,6 +577,7 @@ object_ptr CreateUserpicsTransfer( rpl::producer>> from, not_null to, UserpicsTransferType type) { + using Type = UserpicsTransferType; struct State { std::vector> from; std::vector> buttons; @@ -676,27 +677,28 @@ object_ptr CreateUserpicsTransfer( button->render(&q, position, QRegion(), QWidget::DrawChildren); } state->painting = false; - const auto boosting = (type == UserpicsTransferType::BoostReplace); const auto last = state->buttons.back().get(); - const auto back = boosting ? last : right; - const auto add = st::boostReplaceIconAdd; - const auto &icon = boosting - ? st::boostReplaceIcon - : st::starrefJoinIcon; - const auto skip = boosting ? st::boostReplaceIconSkip : 0; - const auto w = icon.width() + 2 * skip; - const auto h = icon.height() + 2 * skip; - const auto x = back->x() + back->width() - w + add.x(); - const auto y = back->y() + back->height() - h + add.y(); - - auto brush = QLinearGradient(QPointF(x + w, y + h), QPointF(x, y)); - brush.setStops(Ui::Premium::ButtonGradientStops()); - q.setBrush(brush); - pen.setWidthF(stroke); - q.setPen(pen); - q.drawEllipse(x - half, y - half, w + stroke, h + stroke); - icon.paint(q, x + skip, y + skip, outerw); + if (type != Type::AuctionRecipient) { + const auto boosting = (type == Type::BoostReplace); + const auto back = boosting ? last : right; + const auto add = st::boostReplaceIconAdd; + const auto &icon = boosting + ? st::boostReplaceIcon + : st::starrefJoinIcon; + const auto skip = boosting ? st::boostReplaceIconSkip : 0; + const auto w = icon.width() + 2 * skip; + const auto h = icon.height() + 2 * skip; + const auto x = back->x() + back->width() - w + add.x(); + const auto y = back->y() + back->height() - h + add.y(); + auto brush = QLinearGradient(QPointF(x + w, y + h), QPointF(x, y)); + brush.setStops(Ui::Premium::ButtonGradientStops()); + q.setBrush(brush); + pen.setWidthF(stroke); + q.setPen(pen); + q.drawEllipse(x - half, y - half, w + stroke, h + stroke); + icon.paint(q, x + skip, y + skip, outerw); + } const auto size = st::boostReplaceArrow.size(); st::boostReplaceArrow.paint( q, @@ -705,7 +707,6 @@ object_ptr CreateUserpicsTransfer( + (st::boostReplaceUserpicsSkip - size.width()) / 2), (last->height() - size.height()) / 2, outerw); - q.end(); auto p = QPainter(overlay); diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.h b/Telegram/SourceFiles/boxes/peers/replace_boost_box.h index 5ab453f5bf..1ad668ac81 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.h +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.h @@ -64,6 +64,7 @@ object_ptr ReassignBoostsBox( enum class UserpicsTransferType { BoostReplace, StarRefJoin, + AuctionRecipient, }; [[nodiscard]] object_ptr CreateUserpicsTransfer( not_null parent, diff --git a/Telegram/SourceFiles/boxes/star_gift_auction_box.cpp b/Telegram/SourceFiles/boxes/star_gift_auction_box.cpp index a338d776e6..40c9803174 100644 --- a/Telegram/SourceFiles/boxes/star_gift_auction_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_auction_box.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_text_entities.h" #include "base/unixtime.h" +#include "boxes/peers/replace_boost_box.h" #include "boxes/send_credits_box.h" // CreditsEmojiSmall #include "boxes/star_gift_box.h" #include "calls/group/calls_group_common.h" @@ -1236,12 +1237,13 @@ base::weak_qptr ChooseAndShowAuctionBox( sendBox->boxClosing( ) | rpl::start_with_next(close, sendBox->lifetime()); }; - const auto text = (now.my.to->isSelf() + const auto from = now.my.to; + const auto text = (from->isSelf() ? tr::lng_auction_change_already_me(tr::now, tr::rich) : tr::lng_auction_change_already( tr::now, lt_name, - tr::bold(now.my.to->name()), + tr::bold(from->name()), tr::rich)).append(' ').append(peer->isSelf() ? tr::lng_auction_change_to_me(tr::now, tr::rich) : tr::lng_auction_change_to( @@ -1249,11 +1251,22 @@ base::weak_qptr ChooseAndShowAuctionBox( lt_name, tr::bold(peer->name()), tr::rich)); - box = window->show(MakeConfirmBox({ - .text = text, - .confirmed = change, - .confirmText = tr::lng_auction_change_button(), - .title = tr::lng_auction_change_title(), + box = window->show(Box([=](not_null box) { + box->addRow( + CreateUserpicsTransfer( + box, + rpl::single(std::vector{ not_null(from) }), + peer, + UserpicsTransferType::AuctionRecipient), + st::boxRowPadding + st::auctionChangeRecipientPadding + )->setAttribute(Qt::WA_TransparentForMouseEvents); + + ConfirmBox(box, { + .text = text, + .confirmed = change, + .confirmText = tr::lng_auction_change_button(), + .title = tr::lng_auction_change_title(), + }); })); } else if (showInfoBox) { box = window->show(Box( diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index 8b53e20740..5cf630d3b1 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -452,6 +452,7 @@ auctionCenteredSubtitle: FlatLabel(defaultFlatLabel) { font: font(10px); } } +auctionChangeRecipientPadding: margins(0px, 0px, 0px, 10px); auctionBidPlace: FlatLabel(defaultFlatLabel) { style: semiboldTextStyle;