info_peer_gifts_widget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 "data/data_star_gift.h"
  9. #include "info/info_content_widget.h"
  10. class UserData;
  11. struct PeerListState;
  12. namespace Ui {
  13. class RpWidget;
  14. template <typename Widget>
  15. class SlideWrap;
  16. } // namespace Ui
  17. namespace Info::PeerGifts {
  18. struct ListState {
  19. std::vector<Data::SavedStarGift> list;
  20. QString offset;
  21. };
  22. struct Filter {
  23. bool sortByValue : 1 = false;
  24. bool skipUnlimited : 1 = false;
  25. bool skipLimited : 1 = false;
  26. bool skipUnique : 1 = false;
  27. bool skipSaved : 1 = false;
  28. bool skipUnsaved : 1 = false;
  29. friend inline bool operator==(Filter, Filter) = default;
  30. };
  31. class InnerWidget;
  32. class Memento final : public ContentMemento {
  33. public:
  34. explicit Memento(not_null<PeerData*> peer);
  35. object_ptr<ContentWidget> createWidget(
  36. QWidget *parent,
  37. not_null<Controller*> controller,
  38. const QRect &geometry) override;
  39. Section section() const override;
  40. void setListState(std::unique_ptr<ListState> state);
  41. std::unique_ptr<ListState> listState();
  42. ~Memento();
  43. private:
  44. std::unique_ptr<ListState> _listState;
  45. };
  46. class Widget final : public ContentWidget {
  47. public:
  48. Widget(
  49. QWidget *parent,
  50. not_null<Controller*> controller,
  51. not_null<PeerData*> peer);
  52. [[nodiscard]] not_null<PeerData*> peer() const;
  53. bool showInternal(
  54. not_null<ContentMemento*> memento) override;
  55. void setInternalState(
  56. const QRect &geometry,
  57. not_null<Memento*> memento);
  58. void fillTopBarMenu(const Ui::Menu::MenuCallback &addAction) override;
  59. rpl::producer<QString> title() override;
  60. rpl::producer<bool> desiredBottomShadowVisibility() override;
  61. void showFinished() override;
  62. private:
  63. void saveState(not_null<Memento*> memento);
  64. void restoreState(not_null<Memento*> memento);
  65. std::shared_ptr<ContentMemento> doCreateMemento() override;
  66. void setupNotifyCheckbox(bool enabled);
  67. InnerWidget *_inner = nullptr;
  68. QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom;
  69. rpl::variable<bool> _hasPinnedToBottom;
  70. rpl::variable<Filter> _filter;
  71. bool _shown = false;
  72. };
  73. } // namespace Info::PeerGifts