mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added support of new statuses of credits history entries.
This commit is contained in:
parent
7d115b3fab
commit
b5bd0f53ad
3 changed files with 45 additions and 31 deletions
|
@ -5164,6 +5164,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_channel_earn_history_return" = "Refund";
|
"lng_channel_earn_history_return" = "Refund";
|
||||||
"lng_channel_earn_history_return_about" = "Refunded back";
|
"lng_channel_earn_history_return_about" = "Refunded back";
|
||||||
"lng_channel_earn_history_pending" = "Pending";
|
"lng_channel_earn_history_pending" = "Pending";
|
||||||
|
"lng_channel_earn_history_failed" = "Failed";
|
||||||
"lng_channel_earn_history_show_more#one" = "Show {count} More Transaction";
|
"lng_channel_earn_history_show_more#one" = "Show {count} More Transaction";
|
||||||
"lng_channel_earn_history_show_more#other" = "Show {count} More Transactions";
|
"lng_channel_earn_history_show_more#other" = "Show {count} More Transactions";
|
||||||
"lng_channel_earn_off" = "Switch Off Ads";
|
"lng_channel_earn_off" = "Switch Off Ads";
|
||||||
|
|
|
@ -782,13 +782,17 @@ void CreditsRow::init() {
|
||||||
langDateTimeFull(_entry.date)
|
langDateTimeFull(_entry.date)
|
||||||
+ (_entry.refunded
|
+ (_entry.refunded
|
||||||
? (joiner + tr::lng_channel_earn_history_return(tr::now))
|
? (joiner + tr::lng_channel_earn_history_return(tr::now))
|
||||||
|
: _entry.pending
|
||||||
|
? (joiner + tr::lng_channel_earn_history_pending(tr::now))
|
||||||
|
: _entry.failed
|
||||||
|
? (joiner + tr::lng_channel_earn_history_failed(tr::now))
|
||||||
: QString())
|
: QString())
|
||||||
+ (_entry.title.isEmpty() ? QString() : (joiner + _name)));
|
+ (_entry.title.isEmpty() ? QString() : (joiner + _name)));
|
||||||
{
|
{
|
||||||
constexpr auto kMinus = QChar(0x2212);
|
constexpr auto kMinus = QChar(0x2212);
|
||||||
_rightText.setText(
|
_rightText.setText(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
((!_entry.bareId || _entry.refunded) ? QChar('+') : kMinus)
|
(_entry.in ? QChar('+') : kMinus)
|
||||||
+ Lang::FormatCountDecimal(std::abs(int64(_entry.credits))));
|
+ Lang::FormatCountDecimal(std::abs(int64(_entry.credits))));
|
||||||
}
|
}
|
||||||
if (!_paintUserpicCallback) {
|
if (!_paintUserpicCallback) {
|
||||||
|
@ -836,7 +840,9 @@ void CreditsRow::rightActionPaint(
|
||||||
bool actionSelected) {
|
bool actionSelected) {
|
||||||
const auto &font = _rightText.style()->font;
|
const auto &font = _rightText.style()->font;
|
||||||
y += _rowHeight / 2;
|
y += _rowHeight / 2;
|
||||||
p.setPen((!_entry.bareId || _entry.refunded)
|
p.setPen(_entry.pending
|
||||||
|
? st::creditsStroke
|
||||||
|
: _entry.in
|
||||||
? st::boxTextFgGood
|
? st::boxTextFgGood
|
||||||
: st::menuIconAttentionColor);
|
: st::menuIconAttentionColor);
|
||||||
x += st::creditsHistoryRightSkip;
|
x += st::creditsHistoryRightSkip;
|
||||||
|
|
|
@ -389,14 +389,19 @@ void ReceiptCreditsBox(
|
||||||
auto &lifetime = content->lifetime();
|
auto &lifetime = content->lifetime();
|
||||||
const auto text = lifetime.make_state<Ui::Text::String>(
|
const auto text = lifetime.make_state<Ui::Text::String>(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
((!e.bareId || e.refunded) ? QChar('+') : kMinus)
|
(e.in ? QChar('+') : kMinus)
|
||||||
+ Lang::FormatCountDecimal(std::abs(int64(e.credits))));
|
+ Lang::FormatCountDecimal(std::abs(int64(e.credits))));
|
||||||
const auto refundedText = tr::lng_channel_earn_history_return(
|
const auto roundedText = e.refunded
|
||||||
tr::now);
|
? tr::lng_channel_earn_history_return(tr::now)
|
||||||
const auto refunded = e.refunded
|
: e.pending
|
||||||
|
? tr::lng_channel_earn_history_pending(tr::now)
|
||||||
|
: e.failed
|
||||||
|
? tr::lng_channel_earn_history_failed(tr::now)
|
||||||
|
: QString();
|
||||||
|
const auto rounded = !roundedText.isEmpty()
|
||||||
? lifetime.make_state<Ui::Text::String>(
|
? lifetime.make_state<Ui::Text::String>(
|
||||||
st::defaultTextStyle,
|
st::defaultTextStyle,
|
||||||
refundedText)
|
roundedText)
|
||||||
: (Ui::Text::String*)(nullptr);
|
: (Ui::Text::String*)(nullptr);
|
||||||
|
|
||||||
const auto amount = content->add(
|
const auto amount = content->add(
|
||||||
|
@ -404,23 +409,25 @@ void ReceiptCreditsBox(
|
||||||
content,
|
content,
|
||||||
star.height() / style::DevicePixelRatio()));
|
star.height() / style::DevicePixelRatio()));
|
||||||
const auto font = text->style()->font;
|
const auto font = text->style()->font;
|
||||||
const auto refundedFont = st::defaultTextStyle.font;
|
const auto roundedFont = st::defaultTextStyle.font;
|
||||||
const auto starWidth = star.width()
|
const auto starWidth = star.width()
|
||||||
/ style::DevicePixelRatio();
|
/ style::DevicePixelRatio();
|
||||||
const auto refundedSkip = refundedFont->spacew * 2;
|
const auto roundedSkip = roundedFont->spacew * 2;
|
||||||
const auto refundedWidth = refunded
|
const auto roundedWidth = rounded
|
||||||
? refundedFont->width(refundedText)
|
? roundedFont->width(roundedText)
|
||||||
+ refundedSkip
|
+ roundedSkip
|
||||||
+ refundedFont->height
|
+ roundedFont->height
|
||||||
: 0;
|
: 0;
|
||||||
const auto fullWidth = text->maxWidth()
|
const auto fullWidth = text->maxWidth()
|
||||||
+ font->spacew * 1
|
+ font->spacew * 1
|
||||||
+ starWidth
|
+ starWidth
|
||||||
+ refundedWidth;
|
+ roundedWidth;
|
||||||
amount->paintRequest(
|
amount->paintRequest(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
auto p = Painter(amount);
|
auto p = Painter(amount);
|
||||||
p.setPen((!e.bareId || e.refunded)
|
p.setPen(e.pending
|
||||||
|
? st::creditsStroke
|
||||||
|
: e.in
|
||||||
? st::boxTextFgGood
|
? st::boxTextFgGood
|
||||||
: st::menuIconAttentionColor);
|
: st::menuIconAttentionColor);
|
||||||
const auto x = (amount->width() - fullWidth) / 2;
|
const auto x = (amount->width() - fullWidth) / 2;
|
||||||
|
@ -432,15 +439,15 @@ void ReceiptCreditsBox(
|
||||||
.availableWidth = amount->width(),
|
.availableWidth = amount->width(),
|
||||||
});
|
});
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
x + fullWidth - starWidth - refundedWidth,
|
x + fullWidth - starWidth - roundedWidth,
|
||||||
0,
|
0,
|
||||||
star);
|
star);
|
||||||
|
|
||||||
if (refunded) {
|
if (rounded) {
|
||||||
const auto refundedLeft = fullWidth
|
const auto roundedLeft = fullWidth
|
||||||
+ x
|
+ x
|
||||||
- refundedWidth
|
- roundedWidth
|
||||||
+ refundedSkip;
|
+ roundedSkip;
|
||||||
const auto pen = p.pen();
|
const auto pen = p.pen();
|
||||||
auto color = pen.color();
|
auto color = pen.color();
|
||||||
color.setAlphaF(color.alphaF() * 0.15);
|
color.setAlphaF(color.alphaF() * 0.15);
|
||||||
|
@ -449,20 +456,20 @@ void ReceiptCreditsBox(
|
||||||
{
|
{
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.drawRoundedRect(
|
p.drawRoundedRect(
|
||||||
refundedLeft,
|
roundedLeft,
|
||||||
(amount->height() - refundedFont->height) / 2,
|
(amount->height() - roundedFont->height) / 2,
|
||||||
refundedWidth - refundedSkip,
|
roundedWidth - roundedSkip,
|
||||||
refundedFont->height,
|
roundedFont->height,
|
||||||
refundedFont->height / 2,
|
roundedFont->height / 2,
|
||||||
refundedFont->height / 2);
|
roundedFont->height / 2);
|
||||||
}
|
}
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
refunded->draw(p, Ui::Text::PaintContext{
|
rounded->draw(p, Ui::Text::PaintContext{
|
||||||
.position = QPoint(
|
.position = QPoint(
|
||||||
refundedLeft + refundedFont->height / 2,
|
roundedLeft + roundedFont->height / 2,
|
||||||
(amount->height() - refundedFont->height) / 2),
|
(amount->height() - roundedFont->height) / 2),
|
||||||
.outerWidth = refundedWidth,
|
.outerWidth = roundedWidth,
|
||||||
.availableWidth = refundedWidth,
|
.availableWidth = roundedWidth,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, amount->lifetime());
|
}, amount->lifetime());
|
||||||
|
|
Loading…
Add table
Reference in a new issue