From f86e2d98cc711ef0e7ccea584946a097a675c1ae Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 30 Dec 2021 16:48:48 +0300 Subject: [PATCH] Version 3.4: Show mini-profiles from reactions overview. --- .../view/reactions/message_reactions_list.cpp | 128 +++++++++--------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp b/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp index e32dbaf25..6469a73c8 100644 --- a/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp +++ b/Telegram/SourceFiles/history/view/reactions/message_reactions_list.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/reactions/message_reactions_selector.h" #include "boxes/peer_list_box.h" +#include "boxes/peers/prepare_short_info_box.h" #include "window/window_session_controller.h" #include "history/history_item.h" #include "history/history.h" @@ -23,6 +24,26 @@ namespace { constexpr auto kPerPageFirst = 20; constexpr auto kPerPage = 200; +class Row final : public PeerListRow { +public: + Row(not_null peer, const QString &reaction); + + QSize rightActionSize() const override; + QMargins rightActionMargins() const override; + bool rightActionDisabled() const override; + void rightActionPaint( + Painter &p, + int x, + int y, + int outerWidth, + bool selected, + bool actionSelected) override; + +private: + EmojiPtr _emoji = nullptr; + +}; + class Controller final : public PeerListController { public: Controller( @@ -62,6 +83,46 @@ private: }; +Row::Row(not_null peer, const QString &reaction) +: PeerListRow(peer) +, _emoji(Ui::Emoji::Find(reaction)) { +} + +QSize Row::rightActionSize() const { + const auto size = Ui::Emoji::GetSizeNormal() / style::DevicePixelRatio(); + return _emoji ? QSize(size, size) : QSize(); +} + +QMargins Row::rightActionMargins() const { + if (!_emoji) { + return QMargins(); + } + const auto size = Ui::Emoji::GetSizeNormal() / style::DevicePixelRatio(); + return QMargins( + size / 2, + (st::defaultPeerList.item.height - size) / 2, + (size * 3) / 2, + 0); +} + +bool Row::rightActionDisabled() const { + return true; +} + +void Row::rightActionPaint( + Painter &p, + int x, + int y, + int outerWidth, + bool selected, + bool actionSelected) { + if (!_emoji) { + return; + } + // #TODO reactions + Ui::Emoji::Draw(p, _emoji, Ui::Emoji::GetSizeNormal(), x, y); +} + Controller::Controller( not_null window, not_null item, @@ -177,9 +238,10 @@ void Controller::loadMore(const QString &offset) { } void Controller::rowClicked(not_null row) { - const auto peerId = row->peer()->id; - crl::on_main(&session(), [=] { - _window->showPeerHistory(peerId); + const auto window = _window; + const auto peer = row->peer(); + crl::on_main(window, [=] { + window->show(PrepareShortInfoBox(peer, window)); }); } @@ -191,66 +253,6 @@ bool Controller::appendRow(not_null user, QString reaction) { return true; } -class Row final : public PeerListRow { -public: - Row(not_null peer, const QString &reaction); - - QSize rightActionSize() const override; - QMargins rightActionMargins() const override; - bool rightActionDisabled() const override; - void rightActionPaint( - Painter &p, - int x, - int y, - int outerWidth, - bool selected, - bool actionSelected) override; - -private: - EmojiPtr _emoji = nullptr; - -}; - -Row::Row(not_null peer, const QString &reaction) -: PeerListRow(peer) -, _emoji(Ui::Emoji::Find(reaction)) { -} - -QSize Row::rightActionSize() const { - const auto size = Ui::Emoji::GetSizeNormal() / style::DevicePixelRatio(); - return _emoji ? QSize(size, size) : QSize(); -} - -QMargins Row::rightActionMargins() const { - if (!_emoji) { - return QMargins(); - } - const auto size = Ui::Emoji::GetSizeNormal() / style::DevicePixelRatio(); - return QMargins( - size / 2, - (st::defaultPeerList.item.height - size) / 2, - (size * 3) / 2, - 0); -} - -bool Row::rightActionDisabled() const { - return true; -} - -void Row::rightActionPaint( - Painter &p, - int x, - int y, - int outerWidth, - bool selected, - bool actionSelected) { - if (!_emoji) { - return; - } - // #TODO reactions - Ui::Emoji::Draw(p, _emoji, Ui::Emoji::GetSizeNormal(), x, y); -} - std::unique_ptr Controller::createRow( not_null user, QString reaction) const {