From 36fa455aad2a9f2e432ebc4b4cd843e01c7b94a1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 12 Nov 2024 23:19:16 +0300 Subject: [PATCH] Added third line to entries of list for credits history. --- .../info_statistics_list_controllers.cpp | 80 ++++++++++++------- Telegram/SourceFiles/ui/effects/credits.style | 15 ++++ 2 files changed, 68 insertions(+), 27 deletions(-) diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 658059f0b5..67fe36ed54 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -772,6 +772,15 @@ public: bool selected, bool actionSelected) override; + void paintStatusText( + Painter &p, + const style::PeerListItem &st, + int x, + int y, + int available, + int outer, + bool selected) override; + private: void init(); @@ -785,6 +794,7 @@ private: QString _title; QString _name; + Ui::Text::String _description; Ui::Text::String _rightText; base::has_weak_ptr _guard; @@ -831,33 +841,31 @@ void CreditsRow::init() { const auto name = !isSpecial ? PeerListRow::generateName() : Ui::GenerateEntryName(_entry).text; - _name = (_entry.reaction || _entry.stargift || _entry.bareGiveawayMsgId) - ? Ui::GenerateEntryName(_entry).text - : _entry.title.isEmpty() - ? name - : _entry.title; - const auto joiner = QString(QChar(' ')) + QChar(8212) + QChar(' '); + _name = _entry.title.isEmpty() ? name : _entry.title; setSkipPeerBadge(true); - PeerListRow::setCustomStatus( - langDateTime(_entry.date) - + (_entry.floodSkip - ? (joiner + tr::lng_credits_box_history_entry_floodskip_about( - tr::now, - lt_count_decimal, - _entry.floodSkip)) - : _entry.refunded - ? (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)) - : !_entry.subscriptionUntil.isNull() - ? (joiner - + tr::lng_credits_box_history_entry_subscription(tr::now)) - : QString()) - + ((_entry.gift && isSpecial) - ? (joiner + tr::lng_credits_box_history_entry_anonymous(tr::now)) - : ((_name == name) ? QString() : (joiner + name)))); + const auto description = _entry.floodSkip + ? tr::lng_credits_box_history_entry_floodskip_about( + tr::now, + lt_count_decimal, + _entry.floodSkip) + : _entry.refunded + ? tr::lng_channel_earn_history_return(tr::now) + : _entry.pending + ? tr::lng_channel_earn_history_pending(tr::now) + : _entry.failed + ? tr::lng_channel_earn_history_failed(tr::now) + : !_entry.subscriptionUntil.isNull() + ? tr::lng_credits_box_history_entry_subscription(tr::now) + : (_entry.peerType + == Data::CreditsHistoryEntry::PeerType::PremiumBot) + ? tr::lng_credits_box_history_entry_via_premium_bot(tr::now) + : (_entry.gift && isSpecial) + ? tr::lng_credits_box_history_entry_anonymous(tr::now) + : (_name == name) + ? Ui::GenerateEntryName(_entry).text + : name; + _description.setText(st::defaultTextStyle, description); + PeerListRow::setCustomStatus(langDateTime(_entry.date)); if (_subscription) { PeerListRow::setCustomStatus((_subscription.expired ? 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 { public: explicit CreditsController(CreditsDescriptor d); @@ -1019,7 +1045,7 @@ CreditsController::CreditsController(CreditsDescriptor d) .session = _session, .customEmojiRepaint = [] {}, }) { - PeerListController::setStyleOverrides(&st::boostsListBox); + PeerListController::setStyleOverrides(&st::creditsHistoryEntriesList); } Main::Session &CreditsController::session() const { diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index 1b82fe030b..84008e849c 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -157,4 +157,19 @@ giftListAboutMargin: margins(12px, 24px, 12px, 24px); giftBoxEmojiToggleTop: 7px; 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);