/* 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 "boxes/peer_list_box.h" #include "base/flat_set.h" #include "base/weak_ptr.h" // Not used for now. // //class MembersAddButton : public Ui::RippleButton { //public: // MembersAddButton(QWidget *parent, const style::TwoIconButton &st); // //protected: // void paintEvent(QPaintEvent *e) override; // // QImage prepareRippleMask() const override; // QPoint prepareRippleStartPosition() const override; // //private: // const style::TwoIconButton &_st; // //}; class History; namespace Window { class SessionNavigation; } // namespace Window class PeerListRowWithLink : public PeerListRow { public: using PeerListRow::PeerListRow; void setActionLink(const QString &action); void lazyInitialize(const style::PeerListItem &st) override; private: void refreshActionLink(); QSize actionSize() const override; QMargins actionMargins() const override; void paintAction( Painter &p, int x, int y, int outerWidth, bool selected, bool actionSelected) override; QString _action; int _actionWidth = 0; }; class PeerListGlobalSearchController : public PeerListSearchController { public: PeerListGlobalSearchController( not_null navigation); void searchQuery(const QString &query) override; bool isLoading() override; bool loadMoreRows() override { return false; } private: bool searchInCache(); void searchOnServer(); void searchDone(const MTPcontacts_Found &result, mtpRequestId requestId); const not_null _navigation; MTP::Sender _api; base::Timer _timer; QString _query; mtpRequestId _requestId = 0; std::map _cache; std::map _queries; }; class ChatsListBoxController : public PeerListController { public: class Row : public PeerListRow { public: Row(not_null history); not_null history() const { return _history; } private: 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) { } virtual QString emptyBoxText() const; private: void rebuildRows(); void checkForEmptyRows(); bool appendRow(not_null history); }; class ContactsBoxController : public PeerListController { public: ContactsBoxController( not_null navigation); ContactsBoxController( not_null navigation, std::unique_ptr searchController); Main::Session &session() const override; void prepare() override final; std::unique_ptr createSearchRow(not_null peer) override final; void rowClicked(not_null row) override; protected: virtual std::unique_ptr createRow(not_null user); virtual void prepareViewHook() { } virtual void updateRowHook(not_null row) { } private: void rebuildRows(); void checkForEmptyRows(); bool appendRow(not_null user); const not_null _navigation; }; class AddBotToGroupBoxController : public ChatsListBoxController , public base::has_weak_ptr { public: static void Start( not_null navigation, not_null bot); AddBotToGroupBoxController( not_null navigation, not_null bot); Main::Session &session() const override; void rowClicked(not_null row) override; protected: std::unique_ptr createRow(not_null history) override; void prepareViewHook() override; QString emptyBoxText() const override; private: static bool SharingBotGame(not_null bot); bool needToCreateRow(not_null peer) const; bool sharingBotGame() const; QString noResultsText() const; QString descriptionText() const; void updateLabels(); void shareBotGame(not_null chat); void addBotToGroup(not_null chat); not_null _bot; }; class ChooseRecipientBoxController : public ChatsListBoxController , public base::has_weak_ptr { public: ChooseRecipientBoxController( not_null navigation, FnMut)> callback); Main::Session &session() const override; void rowClicked(not_null row) override; bool respectSavedMessagesChat() const override { return true; } protected: void prepareViewHook() override; std::unique_ptr createRow(not_null history) override; private: const not_null _navigation; FnMut)> _callback; };