2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 02:37:11 +00:00
tdesktop/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h

88 lines
2.3 KiB
C
Raw Normal View History

2024-04-09 19:04:18 +04:00
/*
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/rp_widget.h"
namespace Main {
class Session;
} // namespace Main
namespace Ui {
class ElasticScroll;
class VerticalLayout;
template <typename Widget>
class SlideWrap;
} // namespace Ui
2024-04-11 13:12:57 +04:00
namespace Window {
class SessionController;
} // namespace Window
2024-04-09 19:04:18 +04:00
namespace Dialogs {
2024-04-12 12:25:37 +04:00
struct RecentPeersList {
std::vector<not_null<PeerData*>> list;
};
2024-04-09 19:04:18 +04:00
class Suggestions final : public Ui::RpWidget {
public:
Suggestions(
not_null<QWidget*> parent,
2024-04-11 13:12:57 +04:00
not_null<Window::SessionController*> controller,
2024-04-12 12:25:37 +04:00
rpl::producer<TopPeersList> topPeers,
RecentPeersList recentPeers);
2024-04-09 19:04:18 +04:00
~Suggestions();
2024-04-11 13:55:38 +04:00
void selectSkip(int delta);
void selectSkipPage(int height, int direction);
void selectLeft();
void selectRight();
void chooseRow();
2024-04-12 12:25:37 +04:00
[[nodiscard]] rpl::producer<not_null<PeerData*>> topPeerChosen() const {
2024-04-09 19:04:18 +04:00
return _topPeerChosen.events();
}
2024-04-12 12:25:37 +04:00
[[nodiscard]] rpl::producer<not_null<PeerData*>> recentPeerChosen() const {
return _recentPeerChosen.events();
}
2024-04-09 19:04:18 +04:00
private:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
2024-04-12 12:25:37 +04:00
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupRecentPeers(
not_null<Window::SessionController*> window,
RecentPeersList recentPeers);
[[nodiscard]] object_ptr<Ui::SlideWrap<Ui::RpWidget>> setupEmptyRecent(
not_null<Window::SessionController*> window);
2024-04-09 19:04:18 +04:00
const std::unique_ptr<Ui::ElasticScroll> _scroll;
const not_null<Ui::VerticalLayout*> _content;
const not_null<Ui::SlideWrap<TopPeersStrip>*> _topPeersWrap;
const not_null<TopPeersStrip*> _topPeers;
2024-04-12 12:25:37 +04:00
rpl::variable<int> _recentCount;
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _recentPeers;
const not_null<Ui::SlideWrap<Ui::RpWidget>*> _emptyRecent;
rpl::event_stream<not_null<PeerData*>> _topPeerChosen;
rpl::event_stream<not_null<PeerData*>> _recentPeerChosen;
2024-04-09 19:04:18 +04:00
};
2024-04-11 12:41:32 +04:00
[[nodiscard]] rpl::producer<TopPeersList> TopPeersContent(
2024-04-09 19:04:18 +04:00
not_null<Main::Session*> session);
2024-04-12 12:25:37 +04:00
[[nodiscard]] RecentPeersList RecentPeersContent(
not_null<Main::Session*> session);
2024-04-09 19:04:18 +04:00
} // namespace Dialogs