/* 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 "ui/round_rect.h" namespace Data { class Thread; } // namespace Data namespace Main { class Session; } // namespace Main namespace Shortcuts { struct ChatSwitchRequest; } // namespace Shortcuts namespace Ui { class AbstractButton; class RpWidget; } // namespace Ui namespace Window { class ChatSwitchProcess final { public: // Create widget in geometry->parentWidget() and geometry->geometry(). ChatSwitchProcess( not_null geometry, not_null session, Data::Thread *opened); ~ChatSwitchProcess(); [[nodiscard]] rpl::producer> chosen() const; [[nodiscard]] rpl::producer<> closeRequests() const; using Request = Shortcuts::ChatSwitchRequest; void process(const Request &request); [[nodiscard]] rpl::lifetime &lifetime(); private: struct Entry; void setupWidget(not_null geometry); void setupContent(Data::Thread *opened); void setupView(); void layout(QSize size); void setSelected(int index); const not_null _session; const std::unique_ptr _widget; const not_null _view; QRect _shadowed; QRect _outer; QRect _inner; Ui::RoundRect _bg; std::vector> _list; std::vector _entries; int _selected = -1; rpl::event_stream> _chosen; rpl::event_stream<> _closeRequests; rpl::lifetime _lifetime; }; } // namespace Window