mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Show nice userpics in change recipient.
This commit is contained in:
@@ -577,6 +577,7 @@ object_ptr<Ui::RpWidget> CreateUserpicsTransfer(
|
||||
rpl::producer<std::vector<not_null<PeerData*>>> from,
|
||||
not_null<PeerData*> to,
|
||||
UserpicsTransferType type) {
|
||||
using Type = UserpicsTransferType;
|
||||
struct State {
|
||||
std::vector<not_null<PeerData*>> from;
|
||||
std::vector<std::unique_ptr<Ui::UserpicButton>> buttons;
|
||||
@@ -676,27 +677,28 @@ object_ptr<Ui::RpWidget> 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<Ui::RpWidget> CreateUserpicsTransfer(
|
||||
+ (st::boostReplaceUserpicsSkip - size.width()) / 2),
|
||||
(last->height() - size.height()) / 2,
|
||||
outerw);
|
||||
|
||||
q.end();
|
||||
|
||||
auto p = QPainter(overlay);
|
||||
|
||||
@@ -64,6 +64,7 @@ object_ptr<Ui::BoxContent> ReassignBoostsBox(
|
||||
enum class UserpicsTransferType {
|
||||
BoostReplace,
|
||||
StarRefJoin,
|
||||
AuctionRecipient,
|
||||
};
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> CreateUserpicsTransfer(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
||||
@@ -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<BoxContent> 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<BoxContent> 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<GenericBox*> box) {
|
||||
box->addRow(
|
||||
CreateUserpicsTransfer(
|
||||
box,
|
||||
rpl::single(std::vector{ not_null<PeerData*>(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(
|
||||
|
||||
@@ -452,6 +452,7 @@ auctionCenteredSubtitle: FlatLabel(defaultFlatLabel) {
|
||||
font: font(10px);
|
||||
}
|
||||
}
|
||||
auctionChangeRecipientPadding: margins(0px, 0px, 0px, 10px);
|
||||
|
||||
auctionBidPlace: FlatLabel(defaultFlatLabel) {
|
||||
style: semiboldTextStyle;
|
||||
|
||||
Reference in New Issue
Block a user