/* 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" namespace Main { class Session; } // namespace Main namespace Ui { class ElasticScroll; class SettingsSlider; class VerticalLayout; template class SlideWrap; } // namespace Ui namespace Window { class SessionController; } // namespace Window namespace Dialogs { 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(); 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 _recentPeerChosen.events(); } [[nodiscard]] auto myChannelChosen() const -> rpl::producer> { return _myChannelChosen.events(); } [[nodiscard]] auto recommendationChosen() const -> rpl::producer> { return _recommendationChosen.events(); } private: enum class Tab : uchar { Chats, Channels, }; enum class JumpResult : uchar { NotApplied, Applied, AppliedAndOut, }; void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; void setupTabs(); void setupChats(); void setupChannels(); void selectJumpChats(Qt::Key direction, int pageSize); void selectJumpChannels(Qt::Key direction, int pageSize); [[nodiscard]] object_ptr> setupRecentPeers( RecentPeersList recentPeers); [[nodiscard]] object_ptr> setupEmptyRecent(); [[nodiscard]] object_ptr> setupMyChannels(); [[nodiscard]] auto setupRecommendations() -> object_ptr>; [[nodiscard]] auto setupEmptyChannels() -> object_ptr>; [[nodiscard]] object_ptr> setupEmpty( not_null parent, const QString &animation, rpl::producer text); void switchTab(Tab tab); void startShownAnimation(bool shown, Fn finish); void startSlideAnimation(); void finishShow(); 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::variable _recentCount; Fn _recentPeersChoose; Fn _recentSelectJump; const not_null*> _recentPeers; const not_null*> _emptyRecent; const std::unique_ptr _channelsScroll; const not_null _channelsContent; rpl::variable _myChannelsCount; Fn _myChannelsChoose; Fn _myChannelsSelectJump; const not_null*> _myChannels; rpl::variable _recommendationsCount; Fn _recommendationsChoose; Fn _recommendationsSelectJump; const not_null*> _recommendations; const not_null*> _emptyChannels; rpl::event_stream> _topPeerChosen; rpl::event_stream> _recentPeerChosen; rpl::event_stream> _myChannelChosen; rpl::event_stream> _recommendationChosen; Ui::Animations::Simple _shownAnimation; Fn _showFinished; bool _hidden = false; bool _persist = false; QPixmap _cache; Ui::Animations::Simple _slideAnimation; QPixmap _slideLeft; QPixmap _slideRight; }; [[nodiscard]] rpl::producer TopPeersContent( not_null session); [[nodiscard]] RecentPeersList RecentPeersContent( not_null session); } // namespace Dialogs