Added third line to entries of list for credits history.

This commit is contained in:
23rd 2024-11-12 23:19:16 +03:00 committed by John Preston
parent 1c64e90537
commit 36fa455aad
2 changed files with 68 additions and 27 deletions

View File

@ -772,6 +772,15 @@ public:
bool selected, bool selected,
bool actionSelected) override; bool actionSelected) override;
void paintStatusText(
Painter &p,
const style::PeerListItem &st,
int x,
int y,
int available,
int outer,
bool selected) override;
private: private:
void init(); void init();
@ -785,6 +794,7 @@ private:
QString _title; QString _title;
QString _name; QString _name;
Ui::Text::String _description;
Ui::Text::String _rightText; Ui::Text::String _rightText;
base::has_weak_ptr _guard; base::has_weak_ptr _guard;
@ -831,33 +841,31 @@ void CreditsRow::init() {
const auto name = !isSpecial const auto name = !isSpecial
? PeerListRow::generateName() ? PeerListRow::generateName()
: Ui::GenerateEntryName(_entry).text; : Ui::GenerateEntryName(_entry).text;
_name = (_entry.reaction || _entry.stargift || _entry.bareGiveawayMsgId) _name = _entry.title.isEmpty() ? name : _entry.title;
? Ui::GenerateEntryName(_entry).text
: _entry.title.isEmpty()
? name
: _entry.title;
const auto joiner = QString(QChar(' ')) + QChar(8212) + QChar(' ');
setSkipPeerBadge(true); setSkipPeerBadge(true);
PeerListRow::setCustomStatus( const auto description = _entry.floodSkip
langDateTime(_entry.date) ? tr::lng_credits_box_history_entry_floodskip_about(
+ (_entry.floodSkip tr::now,
? (joiner + tr::lng_credits_box_history_entry_floodskip_about( lt_count_decimal,
tr::now, _entry.floodSkip)
lt_count_decimal, : _entry.refunded
_entry.floodSkip)) ? tr::lng_channel_earn_history_return(tr::now)
: _entry.refunded : _entry.pending
? (joiner + tr::lng_channel_earn_history_return(tr::now)) ? tr::lng_channel_earn_history_pending(tr::now)
: _entry.pending : _entry.failed
? (joiner + tr::lng_channel_earn_history_pending(tr::now)) ? tr::lng_channel_earn_history_failed(tr::now)
: _entry.failed : !_entry.subscriptionUntil.isNull()
? (joiner + tr::lng_channel_earn_history_failed(tr::now)) ? tr::lng_credits_box_history_entry_subscription(tr::now)
: !_entry.subscriptionUntil.isNull() : (_entry.peerType
? (joiner == Data::CreditsHistoryEntry::PeerType::PremiumBot)
+ tr::lng_credits_box_history_entry_subscription(tr::now)) ? tr::lng_credits_box_history_entry_via_premium_bot(tr::now)
: QString()) : (_entry.gift && isSpecial)
+ ((_entry.gift && isSpecial) ? tr::lng_credits_box_history_entry_anonymous(tr::now)
? (joiner + tr::lng_credits_box_history_entry_anonymous(tr::now)) : (_name == name)
: ((_name == name) ? QString() : (joiner + name)))); ? Ui::GenerateEntryName(_entry).text
: name;
_description.setText(st::defaultTextStyle, description);
PeerListRow::setCustomStatus(langDateTime(_entry.date));
if (_subscription) { if (_subscription) {
PeerListRow::setCustomStatus((_subscription.expired PeerListRow::setCustomStatus((_subscription.expired
? tr::lng_credits_subscription_status_none ? tr::lng_credits_subscription_status_none
@ -978,6 +986,24 @@ void CreditsRow::rightActionPaint(
}); });
} }
void CreditsRow::paintStatusText(
Painter &p,
const style::PeerListItem &st,
int x,
int y,
int available,
int outer,
bool selected) {
PeerListRow::paintStatusText(p, st, x, y, available, outer, selected);
p.setPen(st.nameFg);
_description.draw(p, {
.position = QPoint(x, y - _description.minHeight() - st::lineWidth),
.outerWidth = outer,
.availableWidth = available,
.elisionLines = 1,
});
}
class CreditsController final : public PeerListController { class CreditsController final : public PeerListController {
public: public:
explicit CreditsController(CreditsDescriptor d); explicit CreditsController(CreditsDescriptor d);
@ -1019,7 +1045,7 @@ CreditsController::CreditsController(CreditsDescriptor d)
.session = _session, .session = _session,
.customEmojiRepaint = [] {}, .customEmojiRepaint = [] {},
}) { }) {
PeerListController::setStyleOverrides(&st::boostsListBox); PeerListController::setStyleOverrides(&st::creditsHistoryEntriesList);
} }
Main::Session &CreditsController::session() const { Main::Session &CreditsController::session() const {

View File

@ -157,4 +157,19 @@ giftListAboutMargin: margins(12px, 24px, 12px, 24px);
giftBoxEmojiToggleTop: 7px; giftBoxEmojiToggleTop: 7px;
giftBoxLimitTop: 28px; giftBoxLimitTop: 28px;
creditsHistoryEntriesList: PeerList(defaultPeerList) {
padding: margins(
0px,
7px,
0px,
7px);
item: PeerListItem(defaultPeerListItem) {
height: 66px;
photoPosition: point(18px, 6px);
namePosition: point(70px, 6px);
statusPosition: point(70px, 43px);
photoSize: 42px;
}
}
subscriptionCreditsBadgePadding: margins(10px, 1px, 8px, 3px); subscriptionCreditsBadgePadding: margins(10px, 1px, 8px, 3px);