/* 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/object_ptr.h" #include "dialogs/ui/top_peers_strip.h" #include "ui/effects/animations.h" #include "ui/rp_widget.h" class PeerListContent; namespace Data { class Thread; } // namespace Data namespace Main { class Session; } // namespace Main namespace Ui { class BoxContent; class ElasticScroll; class SettingsSlider; class VerticalLayout; template class SlideWrap; } // namespace Ui namespace Window { class SessionController; } // namespace Window namespace Dialogs { enum class SearchEmptyIcon; struct RecentPeersList { std::vector> list; }; class Suggestions final : public Ui::RpWidget { public: Suggestions( not_null parent, not_null controller, rpl::producer topPeers, RecentPeersList recentPeers); ~Suggestions(); void selectJump(Qt::Key direction, int pageSize = 0); void chooseRow(); [[nodiscard]] Data::Thread *updateFromParentDrag(QPoint globalPosition); void dragLeft(); void show(anim::type animated, Fn finish); void hide(anim::type animated, Fn finish); [[nodiscard]] float64 shownOpacity() const; [[nodiscard]] bool persist() const; void clearPersistance(); [[nodiscard]] rpl::producer> topPeerChosen() const { return _topPeerChosen.events(); } [[nodiscard]] auto recentPeerChosen() const -> rpl::producer> { return _recent->chosen.events(); } [[nodiscard]] auto myChannelChosen() const -> rpl::producer> { return _myChannels->chosen.events(); } [[nodiscard]] auto recommendationChosen() const -> rpl::producer> { return _recommendations->chosen.events(); } [[nodiscard]] auto recentAppChosen() const -> rpl::producer> { return _recentApps->chosen.events(); } [[nodiscard]] auto popularAppChosen() const -> rpl::producer> { return _popularApps->chosen.events(); } class ObjectListController; private: enum class Tab : uchar { Chats, Channels, Apps, }; enum class JumpResult : uchar { NotApplied, Applied, AppliedAndOut, }; struct ObjectList { not_null*> wrap; rpl::variable count; Fn choose; Fn selectJump; Fn updateFromParentDrag; Fn dragLeft; Fn)> processTouch; rpl::event_stream> chosen; }; void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; void setupTabs(); void setupChats(); void setupChannels(); void setupApps(); void selectJumpChats(Qt::Key direction, int pageSize); void selectJumpChannels(Qt::Key direction, int pageSize); void selectJumpApps(Qt::Key direction, int pageSize); [[nodiscard]] Data::Thread *updateFromChatsDrag(QPoint globalPosition); [[nodiscard]] Data::Thread *updateFromChannelsDrag( QPoint globalPosition); [[nodiscard]] Data::Thread *updateFromAppsDrag(QPoint globalPosition); [[nodiscard]] Data::Thread *fromListId(uint64 peerListRowId); [[nodiscard]] std::unique_ptr setupRecentPeers( RecentPeersList recentPeers); [[nodiscard]] auto setupEmptyRecent() -> object_ptr>; [[nodiscard]] std::unique_ptr setupMyChannels(); [[nodiscard]] std::unique_ptr setupRecommendations(); [[nodiscard]] auto setupEmptyChannels() -> object_ptr>; [[nodiscard]] std::unique_ptr setupRecentApps(); [[nodiscard]] std::unique_ptr setupPopularApps(); [[nodiscard]] std::unique_ptr setupObjectList( not_null scroll, not_null parent, not_null controller, Fn addToScroll = nullptr); [[nodiscard]] object_ptr> setupEmpty( not_null parent, SearchEmptyIcon icon, rpl::producer text); void switchTab(Tab tab); void startShownAnimation(bool shown, Fn finish); void startSlideAnimation(Tab was, Tab now); void finishShow(); void handlePressForChatPreview(PeerId id, Fn callback); const not_null _controller; const std::unique_ptr _tabs; rpl::variable _tab = Tab::Chats; const std::unique_ptr _chatsScroll; const not_null _chatsContent; const not_null*> _topPeersWrap; const not_null _topPeers; rpl::event_stream> _topPeerChosen; const std::unique_ptr _recent; const not_null*> _emptyRecent; const std::unique_ptr _channelsScroll; const not_null _channelsContent; const std::unique_ptr _myChannels; const std::unique_ptr _recommendations; const not_null*> _emptyChannels; const std::unique_ptr _appsScroll; const not_null _appsContent; rpl::producer<> _recentAppsRefreshed; Fn)> _recentAppsShows; const std::unique_ptr _recentApps; const std::unique_ptr _popularApps; Ui::Animations::Simple _shownAnimation; Fn _showFinished; bool _hidden = false; bool _persist = false; QPixmap _cache; Ui::Animations::Simple _slideAnimation; QPixmap _slideLeft; QPixmap _slideRight; int _slideLeftTop = 0; int _slideRightTop = 0; }; [[nodiscard]] rpl::producer TopPeersContent( not_null session); [[nodiscard]] RecentPeersList RecentPeersContent( not_null session); [[nodiscard]] object_ptr StarsExamplesBox( not_null window); } // namespace Dialogs