diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp index b95333613c..f288f92891 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp @@ -234,19 +234,35 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) { top += st.height; } for (const auto &[history, button] : _removePeer) { - history->peer->paintUserpicLeft( - p, - iconLeft, - top + iconTop, - width(), - st.photoSize); - p.setPen(st::contactsNameFg); - history->peer->nameText().drawLeftElided( - p, - nameLeft, - top + nameTop, - button->x() - nameLeft, - width()); + const auto savedMessages = history->peer->isSelf(); + if (savedMessages) { + Ui::EmptyUserpic::PaintSavedMessages( + p, + iconLeft, + top + iconTop, + width(), + st.photoSize); + p.setPen(st::contactsNameFg); + p.drawTextLeft( + nameLeft, + top + nameTop, + width(), + tr::lng_saved_messages(tr::now)); + } else { + history->peer->paintUserpicLeft( + p, + iconLeft, + top + iconTop, + width(), + st.photoSize); + p.setPen(st::contactsNameFg); + history->peer->nameText().drawLeftElided( + p, + nameLeft, + top + nameTop, + button->x() - nameLeft, + width()); + } top += st.height; } } diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp index e0a64e8347..a3a1b015ef 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp @@ -52,6 +52,16 @@ private: }; +class ExceptionRow final : public ChatsListBoxController::Row { +public: + explicit ExceptionRow(not_null history); + + QString generateName() override; + QString generateShortName() override; + PaintRoundImageCallback generatePaintUserpicCallback() override; + +}; + class TypeDelegate final : public PeerListContentDelegate { public: void peerListSetTitle(rpl::producer title) override; @@ -151,6 +161,34 @@ Flag TypeRow::flag() const { return static_cast(id() & 0xFF); } +ExceptionRow::ExceptionRow(not_null history) : Row(history) { + if (peer()->isSelf()) { + setCustomStatus(tr::lng_saved_forward_here(tr::now)); + } +} + +QString ExceptionRow::generateName() { + return peer()->isSelf() + ? tr::lng_saved_messages(tr::now) + : Row::generateName(); +} + +QString ExceptionRow::generateShortName() { + return generateName(); +} + +PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback() { + const auto peer = this->peer(); + const auto saved = peer->isSelf(); + return [=](Painter &p, int x, int y, int outerWidth, int size) { + if (saved) { + Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size); + } else { + peer->paintUserpicLeft(p, x, y, outerWidth, size); + } + }; +} + void TypeDelegate::peerListSetTitle(rpl::producer title) { } @@ -349,8 +387,19 @@ bool EditFilterChatsListController::handleDeselectForeignRow( void EditFilterChatsListController::prepareViewHook() { delegate()->peerListSetTitle(std::move(_title)); delegate()->peerListSetAboveWidget(prepareTypesList()); - delegate()->peerListAddSelectedPeers( - _peers | ranges::view::transform(&History::peer)); + + const auto count = int(_peers.size()); + const auto rows = std::make_unique[]>(count); + auto i = 0; + for (const auto history : _peers) { + rows[i++].emplace(history); + } + auto pointers = std::vector(); + pointers.reserve(count); + for (auto i = 0; i != count; ++i) { + pointers.push_back(&*rows[i]); + } + delegate()->peerListAddSelectedRows(pointers); updateTitle(); } @@ -416,7 +465,9 @@ object_ptr EditFilterChatsListController::prepareTypesList() { auto EditFilterChatsListController::createRow(not_null history) -> std::unique_ptr { - return history->inChatList() ? std::make_unique(history) : nullptr; + return history->inChatList() + ? std::make_unique(history) + : nullptr; } void EditFilterChatsListController::updateTitle() { diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index a1a52e7016..b6ca666f9d 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -87,14 +87,6 @@ private: class ChatsListBoxController : public PeerListController { public: - ChatsListBoxController(not_null navigation); - ChatsListBoxController( - std::unique_ptr searchController); - - void prepare() override final; - std::unique_ptr createSearchRow(not_null peer) override final; - -protected: class Row : public PeerListRow { public: Row(not_null history); @@ -107,6 +99,15 @@ protected: not_null _history; }; + + ChatsListBoxController(not_null navigation); + ChatsListBoxController( + std::unique_ptr searchController); + + void prepare() override final; + std::unique_ptr createSearchRow(not_null peer) override final; + +protected: virtual std::unique_ptr createRow(not_null history) = 0; virtual void prepareViewHook() = 0; virtual void updateRowHook(not_null row) {