mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added subscription icon to channel photo in ReceiptCreditsBox.
This commit is contained in:
parent
e5886862c3
commit
b1e537e54e
4 changed files with 81 additions and 18 deletions
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_credits_graphics.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/credits_graphics.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_stars_colored.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
|
@ -129,6 +130,7 @@ void ConfirmSubscriptionBox(
|
|||
struct State final {
|
||||
std::shared_ptr<Data::PhotoMedia> photoMedia;
|
||||
std::unique_ptr<Ui::EmptyUserpic> photoEmpty;
|
||||
QImage frame;
|
||||
|
||||
std::optional<MTP::Sender> api;
|
||||
Ui::RpWidget* saveButton = nullptr;
|
||||
|
@ -146,25 +148,45 @@ void ConfirmSubscriptionBox(
|
|||
const auto userpic = userpicWrap->entity();
|
||||
const auto photoSize = st::confirmInvitePhotoSize;
|
||||
userpic->resize(Size(photoSize));
|
||||
const auto creditsIconSize = photoSize / 3;
|
||||
const auto creditsIconCallback =
|
||||
Ui::PaintOutlinedColoredCreditsIconCallback(
|
||||
creditsIconSize,
|
||||
1.5);
|
||||
state->frame = QImage(
|
||||
Size(photoSize * style::DevicePixelRatio()),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
state->frame.setDevicePixelRatio(style::DevicePixelRatio());
|
||||
const auto options = Images::Option::RoundCircle;
|
||||
userpic->paintRequest(
|
||||
) | rpl::start_with_next([=, small = Data::PhotoSize::Small] {
|
||||
auto p = QPainter(userpic);
|
||||
if (state->photoMedia) {
|
||||
if (const auto image = state->photoMedia->image(small)) {
|
||||
p.drawPixmap(
|
||||
state->frame.fill(Qt::transparent);
|
||||
{
|
||||
auto p = QPainter(&state->frame);
|
||||
if (state->photoMedia) {
|
||||
if (const auto image = state->photoMedia->image(small)) {
|
||||
p.drawPixmap(
|
||||
0,
|
||||
0,
|
||||
image->pix(Size(photoSize), { .options = options }));
|
||||
}
|
||||
} else if (state->photoEmpty) {
|
||||
state->photoEmpty->paintCircle(
|
||||
p,
|
||||
0,
|
||||
0,
|
||||
image->pix(Size(photoSize), { .options = options }));
|
||||
userpic->width(),
|
||||
photoSize);
|
||||
}
|
||||
if (creditsIconCallback) {
|
||||
p.translate(
|
||||
photoSize - creditsIconSize,
|
||||
photoSize - creditsIconSize);
|
||||
creditsIconCallback(p);
|
||||
}
|
||||
} else if (state->photoEmpty) {
|
||||
state->photoEmpty->paintCircle(
|
||||
p,
|
||||
0,
|
||||
0,
|
||||
userpic->width(),
|
||||
photoSize);
|
||||
}
|
||||
auto p = QPainter(userpic);
|
||||
p.drawImage(0, 0, state->frame);
|
||||
}, userpicWrap->lifetime());
|
||||
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
if (photo) {
|
||||
|
|
|
@ -956,12 +956,11 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
|
|||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
const auto &stUser = st::boostReplaceUserpic;
|
||||
const auto photoSize = st::boostReplaceUserpic.photoSize;
|
||||
const auto session = &row->peer()->session();
|
||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
object_ptr<Ui::UserpicButton>(content, channel, stUser))
|
||||
)->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
Settings::SubscriptionUserpic(content, channel, photoSize)));
|
||||
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
|
|
@ -52,6 +52,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "statistics/widgets/chart_header_widget.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/dynamic_image.h"
|
||||
#include "ui/dynamic_thumbnails.h"
|
||||
#include "ui/effects/credits_graphics.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_stars_colored.h"
|
||||
|
@ -772,9 +774,15 @@ void ReceiptCreditsBox(
|
|||
GenericEntryPhoto(content, callback, stUser.photoSize)));
|
||||
AddViewMediaHandler(thumb->entity(), controller, e);
|
||||
} else if (peer && !e.gift) {
|
||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
object_ptr<Ui::UserpicButton>(content, peer, stUser)));
|
||||
if (e.subscriptionUntil.isNull() && s.until.isNull()) {
|
||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
object_ptr<Ui::UserpicButton>(content, peer, stUser)));
|
||||
} else {
|
||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
SubscriptionUserpic(content, peer, stUser.photoSize)));
|
||||
}
|
||||
} else if (e.gift || isPrize) {
|
||||
struct State final {
|
||||
DocumentData *sticker = nullptr;
|
||||
|
@ -1541,6 +1549,35 @@ object_ptr<Ui::RpWidget> PaidMediaThumbnail(
|
|||
photoSize);
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> SubscriptionUserpic(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer,
|
||||
int photoSize) {
|
||||
auto widget = object_ptr<Ui::RpWidget>(parent);
|
||||
const auto raw = widget.data();
|
||||
widget->resize(photoSize, photoSize);
|
||||
const auto userpicMedia = Ui::MakeUserpicThumbnail(peer, false);
|
||||
userpicMedia->subscribeToUpdates([=] { raw->update(); });
|
||||
const auto creditsIconSize = photoSize / 3;
|
||||
const auto creditsIconCallback =
|
||||
Ui::PaintOutlinedColoredCreditsIconCallback(
|
||||
creditsIconSize,
|
||||
1.5);
|
||||
widget->paintRequest() | rpl::start_with_next([=] {
|
||||
auto p = QPainter(raw);
|
||||
p.fillRect(Rect(Size(photoSize)), Qt::transparent);
|
||||
auto image = userpicMedia->image(photoSize);
|
||||
{
|
||||
auto q = QPainter(&image);
|
||||
q.translate(photoSize, photoSize);
|
||||
q.translate(-creditsIconSize, -creditsIconSize);
|
||||
creditsIconCallback(q);
|
||||
}
|
||||
p.drawImage(0, 0, image);
|
||||
}, widget->lifetime());
|
||||
return widget;
|
||||
}
|
||||
|
||||
void SmallBalanceBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
|
|
|
@ -126,6 +126,11 @@ void ShowRefundInfoBox(
|
|||
int totalCount,
|
||||
int photoSize);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> SubscriptionUserpic(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer,
|
||||
int photoSize);
|
||||
|
||||
struct SmallBalanceBot {
|
||||
UserId botId = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue