1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "ui/rp_widget.h" 11 #include "info/info_wrap_widget.h" 12 #include "dialogs/dialogs_key.h" 13 #include "window/section_memento.h" 14 #include "base/object_ptr.h" 15 16 namespace Storage { 17 enum class SharedMediaType : signed char; 18 } // namespace Storage 19 20 namespace Ui { 21 class ScrollArea; 22 struct ScrollToRequest; 23 } // namespace Ui 24 25 namespace Info { 26 namespace Settings { 27 struct Tag; 28 } // namespace Settings 29 30 class ContentMemento; 31 class WrapWidget; 32 33 class Memento final : public Window::SectionMemento { 34 public: 35 explicit Memento(not_null<PeerData*> peer); 36 Memento(not_null<PeerData*> peer, Section section); 37 Memento(Settings::Tag settings, Section section); 38 Memento(not_null<PollData*> poll, FullMsgId contextId); 39 explicit Memento(std::vector<std::shared_ptr<ContentMemento>> stack); 40 41 object_ptr<Window::SectionWidget> createWidget( 42 QWidget *parent, 43 not_null<Window::SessionController*> controller, 44 Window::Column column, 45 const QRect &geometry) override; 46 47 object_ptr<Ui::LayerWidget> createLayer( 48 not_null<Window::SessionController*> controller, 49 const QRect &geometry) override; 50 stackSize()51 int stackSize() const { 52 return int(_stack.size()); 53 } 54 std::vector<std::shared_ptr<ContentMemento>> takeStack(); 55 content()56 not_null<ContentMemento*> content() { 57 Expects(!_stack.empty()); 58 59 return _stack.back().get(); 60 } 61 62 static Section DefaultSection(not_null<PeerData*> peer); 63 static std::shared_ptr<Memento> Default(not_null<PeerData*> peer); 64 65 ~Memento(); 66 67 private: 68 static std::vector<std::shared_ptr<ContentMemento>> DefaultStack( 69 not_null<PeerData*> peer, 70 Section section); 71 static std::vector<std::shared_ptr<ContentMemento>> DefaultStack( 72 Settings::Tag settings, 73 Section section); 74 static std::vector<std::shared_ptr<ContentMemento>> DefaultStack( 75 not_null<PollData*> poll, 76 FullMsgId contextId); 77 78 static std::shared_ptr<ContentMemento> DefaultContent( 79 not_null<PeerData*> peer, 80 Section section); 81 82 std::vector<std::shared_ptr<ContentMemento>> _stack; 83 84 }; 85 86 class MoveMemento final : public Window::SectionMemento { 87 public: 88 MoveMemento(object_ptr<WrapWidget> content); 89 90 object_ptr<Window::SectionWidget> createWidget( 91 QWidget *parent, 92 not_null<Window::SessionController*> controller, 93 Window::Column column, 94 const QRect &geometry) override; 95 96 object_ptr<Ui::LayerWidget> createLayer( 97 not_null<Window::SessionController*> controller, 98 const QRect &geometry) override; 99 instant()100 bool instant() const override { 101 return true; 102 } 103 104 object_ptr<WrapWidget> takeContent( 105 QWidget *parent, 106 Wrap wrap); 107 108 private: 109 object_ptr<WrapWidget> _content; 110 111 }; 112 113 } // namespace Info 114