info_statistics_widget.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/statistics/info_statistics_common.h"
  10. namespace Info::Statistics {
  11. class InnerWidget;
  12. class Memento final : public ContentMemento {
  13. public:
  14. Memento(not_null<Controller*> controller);
  15. Memento(not_null<PeerData*> peer, FullMsgId contextId);
  16. Memento(not_null<PeerData*> peer, FullStoryId storyId);
  17. ~Memento();
  18. object_ptr<ContentWidget> createWidget(
  19. QWidget *parent,
  20. not_null<Controller*> controller,
  21. const QRect &geometry) override;
  22. Section section() const override;
  23. void setState(SavedState states);
  24. [[nodiscard]] SavedState state();
  25. private:
  26. SavedState _state;
  27. };
  28. class Widget final : public ContentWidget {
  29. public:
  30. Widget(QWidget *parent, not_null<Controller*> controller);
  31. bool showInternal(not_null<ContentMemento*> memento) override;
  32. rpl::producer<QString> title() override;
  33. rpl::producer<bool> desiredShadowVisibility() const override;
  34. void showFinished() override;
  35. void setInternalState(
  36. const QRect &geometry,
  37. not_null<Memento*> memento);
  38. private:
  39. void saveState(not_null<Memento*> memento);
  40. void restoreState(not_null<Memento*> memento);
  41. std::shared_ptr<ContentMemento> doCreateMemento() override;
  42. const not_null<InnerWidget*> _inner;
  43. };
  44. [[nodiscard]] std::shared_ptr<Info::Memento> Make(
  45. not_null<PeerData*> peer,
  46. FullMsgId contextId,
  47. FullStoryId storyId);
  48. } // namespace Info::Statistics