mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added phrases to credits history entries when peer type is premium bot.
This commit is contained in:
parent
4b9eb37bd5
commit
4f7a124f3e
5 changed files with 53 additions and 7 deletions
|
@ -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_app_store" = "App Store";
|
||||||
"lng_credits_box_history_entry_fragment" = "Fragment";
|
"lng_credits_box_history_entry_fragment" = "Fragment";
|
||||||
"lng_credits_box_history_entry_ads" = "Ads Platform";
|
"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" = "Transaction ID";
|
||||||
"lng_credits_box_history_entry_id_copied" = "Transaction ID copied to clipboard.";
|
"lng_credits_box_history_entry_id_copied" = "Transaction ID copied to clipboard.";
|
||||||
"lng_credits_box_history_entry_success_date" = "Transaction date";
|
"lng_credits_box_history_entry_success_date" = "Transaction date";
|
||||||
|
|
|
@ -1702,6 +1702,12 @@ void AddCreditsHistoryEntryTable(
|
||||||
table,
|
table,
|
||||||
tr::lng_credits_box_history_entry_via(),
|
tr::lng_credits_box_history_entry_via(),
|
||||||
tr::lng_credits_box_history_entry_ads(Ui::Text::RichLangValue));
|
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()) {
|
if (!entry.id.isEmpty()) {
|
||||||
constexpr auto kOneLineCount = 18;
|
constexpr auto kOneLineCount = 18;
|
||||||
|
|
|
@ -954,8 +954,6 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) {
|
||||||
if (const auto peerId = PeerId(item.barePeerId)) {
|
if (const auto peerId = PeerId(item.barePeerId)) {
|
||||||
const auto peer = session().data().peer(peerId);
|
const auto peer = session().data().peer(peerId);
|
||||||
return std::make_unique<CreditsRow>(peer, descriptor);
|
return std::make_unique<CreditsRow>(peer, descriptor);
|
||||||
} else if (item.peerType == Type::PremiumBot) {
|
|
||||||
return std::make_unique<CreditsRow>(_premiumBot, descriptor);
|
|
||||||
} else {
|
} else {
|
||||||
return std::make_unique<CreditsRow>(descriptor);
|
return std::make_unique<CreditsRow>(descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,7 +448,7 @@ void ReceiptCreditsBox(
|
||||||
const auto &stUser = st::boostReplaceUserpic;
|
const auto &stUser = st::boostReplaceUserpic;
|
||||||
const auto session = &controller->session();
|
const auto session = &controller->session();
|
||||||
const auto peer = (e.peerType == Type::PremiumBot)
|
const auto peer = (e.peerType == Type::PremiumBot)
|
||||||
? premiumBot
|
? nullptr
|
||||||
: e.barePeerId
|
: e.barePeerId
|
||||||
? session->data().peer(PeerId(e.barePeerId)).get()
|
? session->data().peer(PeerId(e.barePeerId)).get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
@ -622,6 +622,33 @@ void ReceiptCreditsBox(
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
|
if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) {
|
||||||
|
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||||
|
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
||||||
|
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
||||||
|
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(), [=] {
|
const auto button = box->addButton(tr::lng_box_ok(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
|
|
|
@ -193,6 +193,21 @@ not_null<MaskedInputField*> AddInputFieldForCredits(
|
||||||
|
|
||||||
PaintRoundImageCallback GenerateCreditsPaintUserpicCallback(
|
PaintRoundImageCallback GenerateCreditsPaintUserpicCallback(
|
||||||
const Data::CreditsHistoryEntry &entry) {
|
const Data::CreditsHistoryEntry &entry) {
|
||||||
|
using PeerType = Data::CreditsHistoryEntry::PeerType;
|
||||||
|
if (entry.peerType == PeerType::PremiumBot) {
|
||||||
|
const auto svg = std::make_shared<QSvgRenderer>(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 {
|
const auto bg = [&]() -> EmptyUserpic::BgColors {
|
||||||
switch (entry.peerType) {
|
switch (entry.peerType) {
|
||||||
case Data::CreditsHistoryEntry::PeerType::Peer:
|
case Data::CreditsHistoryEntry::PeerType::Peer:
|
||||||
|
@ -218,10 +233,6 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback(
|
||||||
const auto userpic = std::make_shared<EmptyUserpic>(bg, QString());
|
const auto userpic = std::make_shared<EmptyUserpic>(bg, QString());
|
||||||
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
|
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
|
||||||
userpic->paintCircle(p, x, y, outerWidth, size);
|
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);
|
const auto rect = QRect(x, y, size, size);
|
||||||
((entry.peerType == PeerType::AppStore)
|
((entry.peerType == PeerType::AppStore)
|
||||||
? st::sessionIconiPhone
|
? st::sessionIconiPhone
|
||||||
|
@ -446,6 +457,8 @@ Fn<PaintRoundImageCallback(Fn<void()>)> PaintPreviewCallback(
|
||||||
TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) {
|
TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) {
|
||||||
return ((entry.peerType == Data::CreditsHistoryEntry::PeerType::Fragment)
|
return ((entry.peerType == Data::CreditsHistoryEntry::PeerType::Fragment)
|
||||||
? tr::lng_bot_username_description1_link
|
? 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)
|
: (entry.peerType == Data::CreditsHistoryEntry::PeerType::Ads)
|
||||||
? tr::lng_credits_box_history_entry_ads
|
? tr::lng_credits_box_history_entry_ads
|
||||||
: tr::lng_credits_summary_history_entry_inner_in)(
|
: tr::lng_credits_summary_history_entry_inner_in)(
|
||||||
|
|
Loading…
Add table
Reference in a new issue