From 53933db077e1502b544a7dbb2a15cca1a827a029 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 9 Oct 2025 09:42:31 +0300 Subject: [PATCH] Added userpic for monoforum broadcasts to profile top bar. --- .../info/profile/info_profile_top_bar.cpp | 34 ++++++++++++++++--- .../info/profile/info_profile_top_bar.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index bd744ab311..3398fd2757 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "core/shortcuts.h" #include "data/data_changes.h" +#include "data/data_channel.h" #include "data/data_emoji_statuses.h" #include "data/data_peer_values.h" #include "data/data_peer.h" @@ -38,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/show_or_premium_box.h" #include "ui/controls/stars_rating.h" #include "ui/effects/animations.h" +#include "ui/empty_userpic.h" #include "ui/layers/generic_box.h" #include "ui/painter.h" #include "ui/rect.h" @@ -467,10 +469,34 @@ void TopBar::paintUserpic(QPainter &p) { _userpicUniqueKey = key; const auto fullSize = st::infoLayerProfileTopBarPhotoSize; const auto scaled = fullSize * style::DevicePixelRatio(); - _cachedUserpic = PeerData::GenerateUserpicImage( - _peer, - _userpicView, - scaled); + auto image = QImage(); + if (const auto broadcast = _peer->monoforumBroadcast()) { + image = PeerData::GenerateUserpicImage( + broadcast, + _userpicView, + scaled, + 0); + if (_monoforumMask.isNull()) { + _monoforumMask = Ui::MonoforumShapeMask(Size(scaled)); + } + constexpr auto kFormat = QImage::Format_ARGB32_Premultiplied; + if (image.format() != kFormat) { + image = std::move(image).convertToFormat(kFormat); + } + auto q = QPainter(&image); + q.setCompositionMode(QPainter::CompositionMode_DestinationIn); + q.drawImage( + Rect(image.size() / image.devicePixelRatio()), + _monoforumMask); + q.end(); + } else { + image = PeerData::GenerateUserpicImage( + _peer, + _userpicView, + scaled, + std::nullopt); + } + _cachedUserpic = std::move(image); _cachedUserpic.setDevicePixelRatio(style::DevicePixelRatio()); } p.drawImage(geometry, _cachedUserpic); diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index 01944130ab..8152b10eba 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -121,6 +121,7 @@ private: Ui::PeerUserpicView _userpicView; InMemoryKey _userpicUniqueKey; QImage _cachedUserpic; + QImage _monoforumMask; base::unique_qptr _close; base::unique_qptr> _back;