mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 "settings/settings_credits_graphics.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
#include "ui/effects/credits_graphics.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/effects/premium_stars_colored.h"
|
#include "ui/effects/premium_stars_colored.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
|
@ -129,6 +130,7 @@ void ConfirmSubscriptionBox(
|
||||||
struct State final {
|
struct State final {
|
||||||
std::shared_ptr<Data::PhotoMedia> photoMedia;
|
std::shared_ptr<Data::PhotoMedia> photoMedia;
|
||||||
std::unique_ptr<Ui::EmptyUserpic> photoEmpty;
|
std::unique_ptr<Ui::EmptyUserpic> photoEmpty;
|
||||||
|
QImage frame;
|
||||||
|
|
||||||
std::optional<MTP::Sender> api;
|
std::optional<MTP::Sender> api;
|
||||||
Ui::RpWidget* saveButton = nullptr;
|
Ui::RpWidget* saveButton = nullptr;
|
||||||
|
@ -146,25 +148,45 @@ void ConfirmSubscriptionBox(
|
||||||
const auto userpic = userpicWrap->entity();
|
const auto userpic = userpicWrap->entity();
|
||||||
const auto photoSize = st::confirmInvitePhotoSize;
|
const auto photoSize = st::confirmInvitePhotoSize;
|
||||||
userpic->resize(Size(photoSize));
|
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;
|
const auto options = Images::Option::RoundCircle;
|
||||||
userpic->paintRequest(
|
userpic->paintRequest(
|
||||||
) | rpl::start_with_next([=, small = Data::PhotoSize::Small] {
|
) | rpl::start_with_next([=, small = Data::PhotoSize::Small] {
|
||||||
auto p = QPainter(userpic);
|
state->frame.fill(Qt::transparent);
|
||||||
if (state->photoMedia) {
|
{
|
||||||
if (const auto image = state->photoMedia->image(small)) {
|
auto p = QPainter(&state->frame);
|
||||||
p.drawPixmap(
|
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,
|
||||||
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->lifetime());
|
||||||
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents);
|
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
if (photo) {
|
if (photo) {
|
||||||
|
|
|
@ -956,12 +956,11 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
const auto &stUser = st::boostReplaceUserpic;
|
const auto photoSize = st::boostReplaceUserpic.photoSize;
|
||||||
const auto session = &row->peer()->session();
|
const auto session = &row->peer()->session();
|
||||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||||
content,
|
content,
|
||||||
object_ptr<Ui::UserpicButton>(content, channel, stUser))
|
Settings::SubscriptionUserpic(content, channel, photoSize)));
|
||||||
)->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
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 "statistics/widgets/chart_header_widget.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/controls/userpic_button.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/credits_graphics.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/effects/premium_stars_colored.h"
|
#include "ui/effects/premium_stars_colored.h"
|
||||||
|
@ -772,9 +774,15 @@ void ReceiptCreditsBox(
|
||||||
GenericEntryPhoto(content, callback, stUser.photoSize)));
|
GenericEntryPhoto(content, callback, stUser.photoSize)));
|
||||||
AddViewMediaHandler(thumb->entity(), controller, e);
|
AddViewMediaHandler(thumb->entity(), controller, e);
|
||||||
} else if (peer && !e.gift) {
|
} else if (peer && !e.gift) {
|
||||||
content->add(object_ptr<Ui::CenterWrap<>>(
|
if (e.subscriptionUntil.isNull() && s.until.isNull()) {
|
||||||
content,
|
content->add(object_ptr<Ui::CenterWrap<>>(
|
||||||
object_ptr<Ui::UserpicButton>(content, peer, stUser)));
|
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) {
|
} else if (e.gift || isPrize) {
|
||||||
struct State final {
|
struct State final {
|
||||||
DocumentData *sticker = nullptr;
|
DocumentData *sticker = nullptr;
|
||||||
|
@ -1541,6 +1549,35 @@ object_ptr<Ui::RpWidget> PaidMediaThumbnail(
|
||||||
photoSize);
|
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(
|
void SmallBalanceBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
|
|
|
@ -126,6 +126,11 @@ void ShowRefundInfoBox(
|
||||||
int totalCount,
|
int totalCount,
|
||||||
int photoSize);
|
int photoSize);
|
||||||
|
|
||||||
|
[[nodiscard]] object_ptr<Ui::RpWidget> SubscriptionUserpic(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
int photoSize);
|
||||||
|
|
||||||
struct SmallBalanceBot {
|
struct SmallBalanceBot {
|
||||||
UserId botId = 0;
|
UserId botId = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue