diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp index 75b1487fa1..e1aacddf9f 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp @@ -49,7 +49,8 @@ public: QString generateName() override; QString generateShortName() override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; private: [[nodiscard]] Flag flag() const; @@ -62,7 +63,8 @@ public: QString generateName() override; QString generateShortName() override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; }; @@ -124,7 +126,8 @@ QString TypeRow::generateShortName() { return generateName(); } -PaintRoundImageCallback TypeRow::generatePaintUserpicCallback() { +PaintRoundImageCallback TypeRow::generatePaintUserpicCallback( + bool forceRound) { const auto flag = this->flag(); return [=](QPainter &p, int x, int y, int outerWidth, int size) { PaintFilterChatsTypeIcon(p, flag, x, y, outerWidth, size); @@ -153,11 +156,15 @@ QString ExceptionRow::generateShortName() { return generateName(); } -PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback() { +PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback( + bool forceRound) { const auto peer = this->peer(); const auto saved = peer->isSelf(); const auto replies = peer->isRepliesChat(); auto userpic = saved ? Ui::PeerUserpicView() : ensureUserpicView(); + if (forceRound && peer->isForum()) { + return ForceRoundUserpicCallback(peer); + } return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { if (saved) { Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index c4bd163f50..b3db937d82 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -54,6 +54,25 @@ PaintRoundImageCallback PaintUserpicCallback( }; } +PaintRoundImageCallback ForceRoundUserpicCallback(not_null peer) { + auto userpic = Ui::PeerUserpicView(); + auto cache = std::make_shared(); + return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { + const auto ratio = style::DevicePixelRatio(); + const auto cacheSize = QSize(size, size) * ratio; + if (cache->size() != cacheSize) { + *cache = QImage(cacheSize, QImage::Format_ARGB32_Premultiplied); + cache->setDevicePixelRatio(ratio); + } + auto q = Painter(cache.get()); + peer->paintUserpicLeft(q, userpic, 0, 0, outerWidth, size); + q.end(); + + *cache = Images::Circle(std::move(*cache)); + p.drawImage(x, y, *cache); + }; +} + PeerListContentDelegateShow::PeerListContentDelegateShow( std::shared_ptr show) : _show(show) { @@ -412,7 +431,9 @@ void PeerListBox::addSelectItem( addSelectItem( peer->id.value, text, - PaintUserpicCallback(peer, respect), + (peer->isForum() + ? ForceRoundUserpicCallback(peer) + : PaintUserpicCallback(peer, respect)), animated); } @@ -422,7 +443,7 @@ void PeerListBox::addSelectItem( addSelectItem( row->id(), row->generateShortName(), - row->generatePaintUserpicCallback(), + row->generatePaintUserpicCallback(true), animated); } @@ -642,11 +663,15 @@ Ui::PeerUserpicView &PeerListRow::ensureUserpicView() { return _userpic; } -PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback() { +PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback( + bool forceRound) { const auto saved = _isSavedMessagesChat; const auto replies = _isRepliesMessagesChat; const auto peer = this->peer(); auto userpic = saved ? Ui::PeerUserpicView() : ensureUserpicView(); + if (forceRound && peer->isForum()) { + return ForceRoundUserpicCallback(peer); + } return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { if (saved) { Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size); @@ -769,7 +794,7 @@ void PeerListRow::paintUserpic( paintDisabledCheckUserpic(p, st, x, y, outerWidth); } else if (_checkbox) { _checkbox->paint(p, x, y, outerWidth); - } else if (const auto callback = generatePaintUserpicCallback()) { + } else if (const auto callback = generatePaintUserpicCallback(false)) { callback(p, x, y, outerWidth, st.photoSize); } } @@ -848,7 +873,7 @@ void PeerListRow::createCheckbox( _checkbox = std::make_unique( st, std::move(updateCallback), - generatePaintUserpicCallback(), + generatePaintUserpicCallback(false), generateRadius); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index f0c887d6b2..c14541aa6a 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -47,6 +47,8 @@ using PaintRoundImageCallback = Fn peer, bool respectSavedMessagesChat); +[[nodiscard]] PaintRoundImageCallback ForceRoundUserpicCallback( + not_null peer); using PeerListRowId = uint64; @@ -89,8 +91,8 @@ public: [[nodiscard]] virtual QString generateName(); [[nodiscard]] virtual QString generateShortName(); - [[nodiscard]] virtual auto generatePaintUserpicCallback() - -> PaintRoundImageCallback; + [[nodiscard]] virtual auto generatePaintUserpicCallback( + bool forceRound) -> PaintRoundImageCallback; [[nodiscard]] virtual auto generateNameFirstLetters() const -> const base::flat_set &; diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 35613e4b83..9516130b13 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -624,7 +624,8 @@ QString ChooseTopicBoxController::Row::generateShortName() { return _topic->title(); } -auto ChooseTopicBoxController::Row::generatePaintUserpicCallback() +auto ChooseTopicBoxController::Row::generatePaintUserpicCallback( + bool forceRound) -> PaintRoundImageCallback { return [=]( Painter &p, diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index b8c149fc61..00106c3929 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -235,7 +235,8 @@ private: QString generateName() override; QString generateShortName() override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; auto generateNameFirstLetters() const -> const base::flat_set & override; diff --git a/Telegram/SourceFiles/boxes/peer_lists_box.cpp b/Telegram/SourceFiles/boxes/peer_lists_box.cpp index eb29c75d56..9c65f294bc 100644 --- a/Telegram/SourceFiles/boxes/peer_lists_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_lists_box.cpp @@ -402,7 +402,9 @@ void PeerListsBox::addSelectItem( addSelectItem( peer->id.value, peer->shortName(), - PaintUserpicCallback(peer, false), + (peer->isForum() + ? ForceRoundUserpicCallback(peer) + : PaintUserpicCallback(peer, false)), animated); } @@ -412,7 +414,7 @@ void PeerListsBox::addSelectItem( addSelectItem( row->id(), row->generateShortName(), - row->generatePaintUserpicCallback(), + row->generatePaintUserpicCallback(true), animated); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp index 96fd207894..5df5929f27 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp @@ -91,7 +91,8 @@ public: QString generateName() override; QString generateShortName() override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; QSize rightActionSize() const override; QMargins rightActionMargins() const override; @@ -327,7 +328,7 @@ QString Row::generateShortName() { return generateName(); } -PaintRoundImageCallback Row::generatePaintUserpicCallback() { +PaintRoundImageCallback Row::generatePaintUserpicCallback(bool forceRound) { return [=]( QPainter &p, int x, diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 430bd32352..8c529e8b5a 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -77,7 +77,8 @@ public: QString generateName() override; QString generateShortName() override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; int elementsCount() const override; QRect elementGeometry(int element, int outerWidth) const override; @@ -520,7 +521,7 @@ QString Row::generateShortName() { return generateName(); } -PaintRoundImageCallback Row::generatePaintUserpicCallback() { +PaintRoundImageCallback Row::generatePaintUserpicCallback(bool forceRound) { return [=]( QPainter &p, int x, diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 65a643710a..e8c4b4987e 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -535,25 +535,6 @@ void ShareBox::applyFilterUpdate(const QString &query) { _inner->updateFilter(query); } -PaintRoundImageCallback ForceRoundUserpicCallback(not_null peer) { - auto userpic = Ui::PeerUserpicView(); - auto cache = std::make_shared(); - return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { - const auto ratio = style::DevicePixelRatio(); - const auto cacheSize = QSize(size, size) * ratio; - if (cache->size() != cacheSize) { - *cache = QImage(cacheSize, QImage::Format_ARGB32_Premultiplied); - cache->setDevicePixelRatio(ratio); - } - auto q = Painter(cache.get()); - peer->paintUserpicLeft(q, userpic, 0, 0, outerWidth, size); - q.end(); - - *cache = Images::Circle(std::move(*cache)); - p.drawImage(x, y, *cache); - }; -} - void ShareBox::addPeerToMultiSelect(not_null thread) { auto addItemWay = Ui::MultiSelect::AddItemWay::Default; const auto peer = thread->peer(); diff --git a/Telegram/SourceFiles/calls/group/calls_group_members_row.cpp b/Telegram/SourceFiles/calls/group/calls_group_members_row.cpp index 7081c9dc00..3bba7087c0 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_members_row.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_members_row.cpp @@ -448,7 +448,8 @@ void MembersRow::paintMuteIcon( _delegate->rowPaintIcon(p, iconRect, computeIconState(style)); } -auto MembersRow::generatePaintUserpicCallback() -> PaintRoundImageCallback { +auto MembersRow::generatePaintUserpicCallback(bool forceRound) +-> PaintRoundImageCallback { return [=](Painter &p, int x, int y, int outerWidth, int size) { const auto outer = outerWidth; paintComplexUserpic(p, x, y, outer, size, size, PanelMode::Default); diff --git a/Telegram/SourceFiles/calls/group/calls_group_members_row.h b/Telegram/SourceFiles/calls/group/calls_group_members_row.h index 745b324599..8dd02f1def 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_members_row.h +++ b/Telegram/SourceFiles/calls/group/calls_group_members_row.h @@ -122,7 +122,8 @@ public: bool selected, bool actionSelected) override; - PaintRoundImageCallback generatePaintUserpicCallback() override; + PaintRoundImageCallback generatePaintUserpicCallback( + bool forceRound) override; void paintComplexUserpic( Painter &p, int x, diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp index 3677a620f9..02158cef68 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp @@ -390,7 +390,7 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) const { if (selectionLevel > 0) { const auto radius = _roundingRadius - ? _roundingRadius(_st.imageRadius) + ? _roundingRadius(_st.imageRadius * 2) : std::optional(); PainterHighQualityEnabler hq(p); p.setOpacity(std::clamp(selectionLevel, 0., 1.));