mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Fixed display credits in list of gift options.
This commit is contained in:
parent
51dc5d6e37
commit
9491cff1df
1 changed files with 64 additions and 5 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/abstract_button.h"
|
#include "ui/abstract_button.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
#include "ui/effects/credits_graphics.h"
|
||||||
#include "ui/effects/gradient.h"
|
#include "ui/effects/gradient.h"
|
||||||
#include "ui/effects/numbers_animation.h"
|
#include "ui/effects/numbers_animation.h"
|
||||||
#include "ui/effects/premium_bubble.h"
|
#include "ui/effects/premium_bubble.h"
|
||||||
|
@ -917,6 +918,45 @@ void AddGiftOptions(
|
||||||
}, *onceLifetime);
|
}, *onceLifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto kStar = QChar(0x2B50);
|
||||||
|
const auto removedStar = [&](QString s) {
|
||||||
|
return s.replace(kStar, QChar());
|
||||||
|
};
|
||||||
|
const auto &costPerMonthFont = st::shareBoxListItem.nameStyle.font;
|
||||||
|
const auto &costTotalFont = st::normalFont;
|
||||||
|
const auto costPerMonthIcon = info.costPerMonth.startsWith(kStar)
|
||||||
|
? GenerateStars(costPerMonthFont->height, 1)
|
||||||
|
: QImage();
|
||||||
|
const auto costPerMonthText = costPerMonthIcon.isNull()
|
||||||
|
? info.costPerMonth
|
||||||
|
: removedStar(info.costPerMonth);
|
||||||
|
const auto costTotalEntry = [&] {
|
||||||
|
if (!info.costTotal.startsWith(kStar)) {
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
const auto text = removedStar(info.costTotal);
|
||||||
|
const auto icon = GenerateStars(costTotalFont->height, 1);
|
||||||
|
auto result = QImage(
|
||||||
|
QSize(costTotalFont->spacew + costTotalFont->width(text), 0)
|
||||||
|
* style::DevicePixelRatio()
|
||||||
|
+ icon.size(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
result.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
|
result.fill(Qt::transparent);
|
||||||
|
{
|
||||||
|
auto p = QPainter(&result);
|
||||||
|
p.drawImage(0, 0, icon);
|
||||||
|
p.setPen(st::windowSubTextFg);
|
||||||
|
p.setFont(costTotalFont);
|
||||||
|
auto copy = info.costTotal;
|
||||||
|
p.drawText(
|
||||||
|
Rect(result.size() / style::DevicePixelRatio()),
|
||||||
|
text,
|
||||||
|
style::al_right);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}();
|
||||||
|
|
||||||
row->paintRequest(
|
row->paintRequest(
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
) | rpl::start_with_next([=](const QRect &r) {
|
||||||
auto p = QPainter(row);
|
auto p = QPainter(row);
|
||||||
|
@ -979,7 +1019,11 @@ void AddGiftOptions(
|
||||||
if (st.borderWidth && (animation->nowIndex == index)) {
|
if (st.borderWidth && (animation->nowIndex == index)) {
|
||||||
const auto progress = animation->animation.value(1.);
|
const auto progress = animation->animation.value(1.);
|
||||||
const auto w = row->width();
|
const auto w = row->width();
|
||||||
auto gradient = QLinearGradient(w - w * progress, 0, w * 2, 0);
|
auto gradient = QLinearGradient(
|
||||||
|
w - w * progress,
|
||||||
|
0,
|
||||||
|
w * 2,
|
||||||
|
0);
|
||||||
gradient.setSpread(QGradient::Spread::RepeatSpread);
|
gradient.setSpread(QGradient::Spread::RepeatSpread);
|
||||||
gradient.setStops(stops);
|
gradient.setStops(stops);
|
||||||
const auto pen = QPen(
|
const auto pen = QPen(
|
||||||
|
@ -1004,13 +1048,28 @@ void AddGiftOptions(
|
||||||
: bottomLeftRect.width() + discountMargins.left(),
|
: bottomLeftRect.width() + discountMargins.left(),
|
||||||
0);
|
0);
|
||||||
p.setPen(st::windowSubTextFg);
|
p.setPen(st::windowSubTextFg);
|
||||||
p.setFont(st::shareBoxListItem.nameStyle.font);
|
p.setFont(costPerMonthFont);
|
||||||
p.drawText(perRect, info.costPerMonth, style::al_left);
|
const auto perMonthLeft = costPerMonthFont->spacew
|
||||||
|
+ costPerMonthIcon.width() / style::DevicePixelRatio();
|
||||||
|
p.drawText(
|
||||||
|
perRect.translated(perMonthLeft, 0),
|
||||||
|
costPerMonthText,
|
||||||
|
style::al_left);
|
||||||
|
p.drawImage(perRect.topLeft(), costPerMonthIcon);
|
||||||
|
|
||||||
const auto totalRect = row->rect()
|
const auto totalRect = row->rect()
|
||||||
- QMargins(0, 0, st.rowMargins.right(), 0);
|
- QMargins(0, 0, st.rowMargins.right(), 0);
|
||||||
p.setFont(st::normalFont);
|
if (costTotalEntry.isNull()) {
|
||||||
p.drawText(totalRect, info.costTotal, style::al_right);
|
p.setFont(costTotalFont);
|
||||||
|
p.drawText(totalRect, info.costTotal, style::al_right);
|
||||||
|
} else {
|
||||||
|
const auto size = costTotalEntry.size()
|
||||||
|
/ style::DevicePixelRatio();
|
||||||
|
p.drawImage(
|
||||||
|
totalRect.width() - size.width(),
|
||||||
|
(row->height() - size.height()) / 2,
|
||||||
|
costTotalEntry);
|
||||||
|
}
|
||||||
}, row->lifetime());
|
}, row->lifetime());
|
||||||
|
|
||||||
row->setClickedCallback([=, duration = st::defaultCheck.duration] {
|
row->setClickedCallback([=, duration = st::defaultCheck.duration] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue