info_settings_widget.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "info/info_content_widget.h"
  9. #include "info/info_controller.h"
  10. namespace Settings {
  11. class AbstractSection;
  12. } // namespace Settings
  13. namespace Info {
  14. namespace Settings {
  15. using Type = Section::SettingsType;
  16. struct Tag;
  17. struct SectionCustomTopBarData {
  18. rpl::producer<> backButtonEnables;
  19. rpl::producer<Info::Wrap> wrapValue;
  20. };
  21. class Memento final : public ContentMemento {
  22. public:
  23. Memento(not_null<UserData*> self, Type type);
  24. object_ptr<ContentWidget> createWidget(
  25. QWidget *parent,
  26. not_null<Controller*> controller,
  27. const QRect &geometry) override;
  28. Section section() const override;
  29. Type type() const {
  30. return _type;
  31. }
  32. not_null<UserData*> self() const {
  33. return settingsSelf();
  34. }
  35. ~Memento();
  36. private:
  37. Type _type = Type();
  38. };
  39. class Widget final : public ContentWidget {
  40. public:
  41. Widget(
  42. QWidget *parent,
  43. not_null<Controller*> controller);
  44. ~Widget();
  45. not_null<UserData*> self() const;
  46. bool showInternal(
  47. not_null<ContentMemento*> memento) override;
  48. void setInternalState(
  49. const QRect &geometry,
  50. not_null<Memento*> memento);
  51. void saveChanges(FnMut<void()> done) override;
  52. void showFinished() override;
  53. void setInnerFocus() override;
  54. const Ui::RoundRect *bottomSkipRounding() const override;
  55. rpl::producer<bool> desiredShadowVisibility() const override;
  56. bool closeByOutsideClick() const override;
  57. void checkBeforeClose(Fn<void()> close) override;
  58. void checkBeforeCloseByEscape(Fn<void()> close) override;
  59. rpl::producer<QString> title() override;
  60. void enableBackButton() override;
  61. rpl::producer<SelectedItems> selectedListValue() const override;
  62. void selectionAction(SelectionAction action) override;
  63. void fillTopBarMenu(const Ui::Menu::MenuCallback &addAction) override;
  64. private:
  65. void saveState(not_null<Memento*> memento);
  66. void restoreState(not_null<Memento*> memento);
  67. void paintEvent(QPaintEvent *e) override;
  68. std::shared_ptr<ContentMemento> doCreateMemento() override;
  69. not_null<UserData*> _self;
  70. Type _type = Type();
  71. struct {
  72. rpl::event_stream<int> contentHeightValue;
  73. rpl::event_stream<int> fillerWidthValue;
  74. rpl::event_stream<> backButtonEnables;
  75. } _flexibleScroll;
  76. not_null<::Settings::AbstractSection*> _inner;
  77. QPointer<Ui::RpWidget> _pinnedToTop;
  78. QPointer<Ui::RpWidget> _pinnedToBottom;
  79. rpl::event_stream<std::vector<Type>> _removesFromStack;
  80. };
  81. } // namespace Settings
  82. } // namespace Info