From 594b2bc8f240e55b93d00ece46cc2c1a547b442b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 10 Oct 2023 16:20:04 +0300 Subject: [PATCH] Improved style of recent posts in statistical info. --- .../info_statistics_recent_message.cpp | 33 ++++++++++--------- .../statistics/info_statistics_widget.cpp | 14 ++++---- .../SourceFiles/statistics/statistics.style | 4 +++ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_recent_message.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_recent_message.cpp index b6d3346fef..9ffdb7fbc3 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_recent_message.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_recent_message.cpp @@ -42,7 +42,7 @@ namespace { return QImage(); } const auto factor = style::DevicePixelRatio(); - const auto size = st::statisticsRecentPostRowHeight * factor; + const auto size = st::peerListBoxItem.photoSize * factor; const auto scaled = original.scaled( QSize(size, size), Qt::KeepAspectRatioByExpanding, @@ -73,16 +73,16 @@ MessagePreview::MessagePreview( : Ui::RpWidget(parent) , _item(item) , _date( - st::statisticsHeaderDatesTextStyle, + st::statisticsHeaderTitleTextStyle, Ui::FormatDateTime(ItemDateTime(item))) , _views( - st::statisticsDetailsPopupHeaderStyle, + st::defaultPeerListItem.nameStyle, tr::lng_stats_recent_messages_views( tr::now, lt_count_decimal, views)) , _shares( - st::statisticsHeaderDatesTextStyle, + st::statisticsHeaderTitleTextStyle, tr::lng_stats_recent_messages_shares( tr::now, lt_count_decimal, @@ -90,7 +90,7 @@ MessagePreview::MessagePreview( , _viewsWidth(_views.maxWidth()) , _sharesWidth(_shares.maxWidth()) { _text.setMarkedText( - st::statisticsDetailsPopupHeaderStyle, + st::defaultPeerListItem.nameStyle, _item->toPreview({ .generateImages = false }).text, Ui::DialogTextOptions(), Core::MarkedTextContext{ @@ -166,7 +166,7 @@ void MessagePreview::processPreview(not_null item) { } int MessagePreview::resizeGetHeight(int newWidth) { - return st::statisticsRecentPostRowHeight; + return st::peerListBoxItem.height; } void MessagePreview::paintEvent(QPaintEvent *e) { @@ -175,13 +175,14 @@ void MessagePreview::paintEvent(QPaintEvent *e) { const auto padding = st::boxRowPadding.left() / 2; const auto rightWidth = std::max(_viewsWidth, _sharesWidth) + padding; const auto left = _preview.isNull() - ? 0 - : (_preview.width() / style::DevicePixelRatio()) + padding; + ? st::peerListBoxItem.photoPosition.x() + : st::peerListBoxItem.namePosition.x(); if (left) { - p.drawImage(0, 0, _preview); + p.drawImage(st::peerListBoxItem.photoPosition, _preview); if (_spoiler) { - const auto rect = Rect( - _preview.size() / _preview.devicePixelRatio()); + const auto rect = QRect( + st::peerListBoxItem.photoPosition, + Size(st::peerListBoxItem.photoSize)); const auto paused = On(PowerSaving::kChatSpoiler); FillSpoilerRect( p, @@ -193,11 +194,13 @@ void MessagePreview::paintEvent(QPaintEvent *e) { _cornerCache); } } + const auto topTextTop = st::peerListBoxItem.namePosition.y(); + const auto bottomTextTop = st::peerListBoxItem.statusPosition.y(); p.setBrush(Qt::NoBrush); p.setPen(st::boxTextFg); _text.draw(p, { - .position = { left, 0 }, + .position = { left, topTextTop }, .outerWidth = width() - left, .availableWidth = width() - rightWidth - left, .spoiler = Ui::Text::DefaultSpoilerCache(), @@ -205,19 +208,19 @@ void MessagePreview::paintEvent(QPaintEvent *e) { .elisionHeight = st::statisticsDetailsPopupHeaderStyle.font->height, }); _views.draw(p, { - .position = { width() - _viewsWidth, 0 }, + .position = { width() - _viewsWidth, topTextTop }, .outerWidth = _viewsWidth, .availableWidth = _viewsWidth, }); p.setPen(st::windowSubTextFg); _date.draw(p, { - .position = { left, height() / 2 }, + .position = { left, bottomTextTop }, .outerWidth = width() - left, .availableWidth = width() - rightWidth - left, }); _shares.draw(p, { - .position = { width() - _sharesWidth, height() / 2 }, + .position = { width() - _sharesWidth, bottomTextTop }, .outerWidth = _sharesWidth, .availableWidth = _sharesWidth, }); diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp index cf3a0f43e4..b5faca4e28 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp @@ -495,12 +495,13 @@ void FillRecentPosts( not_null messageWrap, not_null item, const Data::StatisticsMessageInteractionInfo &info) { - const auto button = ::Settings::AddButton( - messageWrap, - nullptr, - st::settingsButton); + const auto button = messageWrap->add( + object_ptr( + messageWrap, + rpl::never(), + st::statisticsRecentPostButton)); const auto raw = Ui::CreateChild( - button.get(), + button, item, info.viewsCount, info.forwardsCount); @@ -508,7 +509,8 @@ void FillRecentPosts( button->sizeValue( ) | rpl::start_with_next([=](const QSize &s) { if (!s.isNull()) { - raw->setGeometry(Rect(s) - st::boxRowPadding); + raw->setGeometry(Rect(s) + - st::statisticsRecentPostButton.padding); } }, raw->lifetime()); button->setClickedCallback([=, fullId = item->fullId()] { diff --git a/Telegram/SourceFiles/statistics/statistics.style b/Telegram/SourceFiles/statistics/statistics.style index b41d30c301..71e21a687e 100644 --- a/Telegram/SourceFiles/statistics/statistics.style +++ b/Telegram/SourceFiles/statistics/statistics.style @@ -100,3 +100,7 @@ statisticsOverviewMidSkip: 50px; statisticsOverviewRightSkip: 14px; statisticsRecentPostRowHeight: 40px; +statisticsRecentPostButton: SettingsButton(defaultSettingsButton) { + height: 56px; + padding: margins(7px, 0px, 24px, 0px); +}