info_statistics_inner_widget.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "base/object_ptr.h"
  9. #include "info/statistics/info_statistics_common.h"
  10. #include "ui/widgets/scroll_area.h"
  11. #include "ui/wrap/vertical_layout.h"
  12. namespace Info {
  13. class Controller;
  14. } // namespace Info
  15. namespace Info::Statistics {
  16. class Memento;
  17. class MessagePreview;
  18. enum class LoadingType {
  19. Statistic,
  20. Boosts,
  21. Earn,
  22. };
  23. void FillLoading(
  24. not_null<Ui::VerticalLayout*> container,
  25. LoadingType type,
  26. rpl::producer<bool> toggleOn,
  27. rpl::producer<> showFinished);
  28. class InnerWidget final : public Ui::VerticalLayout {
  29. public:
  30. struct ShowRequest final {
  31. PeerId info = PeerId(0);
  32. FullMsgId history;
  33. FullMsgId messageStatistic;
  34. FullStoryId storyStatistic;
  35. FullStoryId story;
  36. };
  37. InnerWidget(
  38. QWidget *parent,
  39. not_null<Controller*> controller,
  40. not_null<PeerData*> peer,
  41. FullMsgId contextId,
  42. FullStoryId storyId);
  43. [[nodiscard]] rpl::producer<Ui::ScrollToRequest> scrollToRequests() const;
  44. [[nodiscard]] rpl::producer<ShowRequest> showRequests() const;
  45. void showFinished();
  46. void saveState(not_null<Memento*> memento);
  47. void restoreState(not_null<Memento*> memento);
  48. private:
  49. void load();
  50. void fill();
  51. void fillRecentPosts(not_null<Ui::VerticalLayout*> container);
  52. not_null<Controller*> _controller;
  53. not_null<PeerData*> _peer;
  54. FullMsgId _contextId;
  55. FullStoryId _storyId;
  56. std::vector<not_null<MessagePreview*>> _messagePreviews;
  57. SavedState _state;
  58. rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
  59. rpl::event_stream<ShowRequest> _showRequests;
  60. rpl::event_stream<> _showFinished;
  61. rpl::event_stream<bool> _loaded;
  62. };
  63. } // namespace Info::Statistics