info_memento.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 "ui/rp_widget.h"
  9. #include "info/info_wrap_widget.h"
  10. #include "dialogs/dialogs_key.h"
  11. #include "window/section_memento.h"
  12. #include "base/object_ptr.h"
  13. namespace Api {
  14. struct WhoReadList;
  15. } // namespace Api
  16. namespace Storage {
  17. enum class SharedMediaType : signed char;
  18. } // namespace Storage
  19. namespace Data {
  20. class ForumTopic;
  21. struct ReactionId;
  22. } // namespace Data
  23. namespace Ui {
  24. class ScrollArea;
  25. struct ScrollToRequest;
  26. } // namespace Ui
  27. namespace Info {
  28. namespace Settings {
  29. struct Tag;
  30. } // namespace Settings
  31. namespace Downloads {
  32. struct Tag;
  33. } // namespace Downloads
  34. class ContentMemento;
  35. class WrapWidget;
  36. class Memento final : public Window::SectionMemento {
  37. public:
  38. explicit Memento(not_null<PeerData*> peer);
  39. Memento(not_null<PeerData*> peer, Section section);
  40. explicit Memento(not_null<Data::ForumTopic*> topic);
  41. Memento(not_null<Data::ForumTopic*> topic, Section section);
  42. Memento(Settings::Tag settings, Section section);
  43. Memento(not_null<PollData*> poll, FullMsgId contextId);
  44. Memento(
  45. std::shared_ptr<Api::WhoReadList> whoReadIds,
  46. FullMsgId contextId,
  47. Data::ReactionId selected);
  48. explicit Memento(std::vector<std::shared_ptr<ContentMemento>> stack);
  49. object_ptr<Window::SectionWidget> createWidget(
  50. QWidget *parent,
  51. not_null<Window::SessionController*> controller,
  52. Window::Column column,
  53. const QRect &geometry) override;
  54. object_ptr<Ui::LayerWidget> createLayer(
  55. not_null<Window::SessionController*> controller,
  56. const QRect &geometry) override;
  57. rpl::producer<> removeRequests() const override {
  58. return _removeRequests.events();
  59. }
  60. int stackSize() const {
  61. return int(_stack.size());
  62. }
  63. std::vector<std::shared_ptr<ContentMemento>> takeStack();
  64. not_null<ContentMemento*> content() {
  65. Expects(!_stack.empty());
  66. return _stack.back().get();
  67. }
  68. static Section DefaultSection(not_null<PeerData*> peer);
  69. static std::shared_ptr<Memento> Default(not_null<PeerData*> peer);
  70. ~Memento();
  71. private:
  72. static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
  73. not_null<PeerData*> peer,
  74. Section section);
  75. static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
  76. not_null<Data::ForumTopic*> topic,
  77. Section section);
  78. static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
  79. Settings::Tag settings,
  80. Section section);
  81. static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
  82. not_null<PollData*> poll,
  83. FullMsgId contextId);
  84. static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
  85. std::shared_ptr<Api::WhoReadList> whoReadIds,
  86. FullMsgId contextId,
  87. Data::ReactionId selected);
  88. static std::shared_ptr<ContentMemento> DefaultContent(
  89. not_null<PeerData*> peer,
  90. Section section);
  91. static std::shared_ptr<ContentMemento> DefaultContent(
  92. not_null<Data::ForumTopic*> topic,
  93. Section section);
  94. std::vector<std::shared_ptr<ContentMemento>> _stack;
  95. rpl::event_stream<> _removeRequests;
  96. rpl::lifetime _lifetime;
  97. };
  98. class MoveMemento final : public Window::SectionMemento {
  99. public:
  100. MoveMemento(object_ptr<WrapWidget> content);
  101. object_ptr<Window::SectionWidget> createWidget(
  102. QWidget *parent,
  103. not_null<Window::SessionController*> controller,
  104. Window::Column column,
  105. const QRect &geometry) override;
  106. object_ptr<Ui::LayerWidget> createLayer(
  107. not_null<Window::SessionController*> controller,
  108. const QRect &geometry) override;
  109. bool instant() const override {
  110. return true;
  111. }
  112. object_ptr<WrapWidget> takeContent(
  113. QWidget *parent,
  114. Wrap wrap);
  115. private:
  116. object_ptr<WrapWidget> _content;
  117. };
  118. } // namespace Info