/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "base/unique_qptr.h" #include "ui/text/text_block.h" #include "ui/widgets/menu/menu_item_base.h" namespace Ui { class PopupMenu; struct WhoReadParticipant { QString name; QString date; bool dateReacted = false; QString customEntityData; QImage userpicSmall; QImage userpicLarge; std::pair userpicKey = {}; uint64 id = 0; static constexpr auto kMaxSmallUserpics = 3; }; bool operator==(const WhoReadParticipant &a, const WhoReadParticipant &b); bool operator!=(const WhoReadParticipant &a, const WhoReadParticipant &b); enum class WhoReadType { Seen, Listened, Watched, Reacted, }; enum class WhoReadState : uchar { Empty, Unknown, MyHidden, HisHidden, TooOld, }; struct WhoReadContent { std::vector participants; WhoReadType type = WhoReadType::Seen; QString singleCustomEntityData; int fullReactionsCount = 0; int fullReadCount = 0; WhoReadState state = WhoReadState::Empty; }; [[nodiscard]] base::unique_qptr WhoReactedContextAction( not_null menu, rpl::producer content, Text::CustomEmojiFactory factory, Fn participantChosen, Fn showAllChosen); [[nodiscard]] base::unique_qptr WhenReadContextAction( not_null menu, rpl::producer content, Fn showOrPremium); enum class WhoReactedType : uchar { Viewed, Reacted, Reposted, Forwarded, Preloader, }; struct WhoReactedEntryData { QString text; QString date; WhoReactedType type = WhoReactedType::Viewed; QString customEntityData; QImage userpic; Fn callback; }; class WhoReactedEntryAction final : public Menu::ItemBase { public: using Data = WhoReactedEntryData; WhoReactedEntryAction( not_null parent, Text::CustomEmojiFactory factory, const style::Menu &st, Data &&data); void setData(Data &&data); not_null action() const override; bool isEnabled() const override; private: int contentHeight() const override; void paint(Painter &&p); const not_null _dummyAction; const Text::CustomEmojiFactory _customEmojiFactory; const style::Menu &_st; const int _height = 0; Text::String _text; Text::String _date; std::unique_ptr _custom; QImage _userpic; int _textWidth = 0; int _customSize = 0; WhoReactedType _type = WhoReactedType::Viewed; }; class WhoReactedListMenu final { public: WhoReactedListMenu( Text::CustomEmojiFactory factory, Fn participantChosen, Fn showAllChosen); void clear(); void populate( not_null menu, const WhoReadContent &content, Fn refillTopActions = nullptr, int addedToBottom = 0, Fn appendBottomActions = nullptr); private: const Text::CustomEmojiFactory _customEmojiFactory; const Fn _participantChosen; const Fn _showAllChosen; std::vector> _actions; }; } // namespace Ui