session_show.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "main/session/session_show.h"
  8. namespace Main {
  9. namespace {
  10. class SimpleSessionShow final : public SessionShow {
  11. public:
  12. SimpleSessionShow(
  13. std::shared_ptr<Ui::Show> show,
  14. not_null<Session*> session);
  15. void showOrHideBoxOrLayer(
  16. std::variant<
  17. v::null_t,
  18. object_ptr<Ui::BoxContent>,
  19. std::unique_ptr<Ui::LayerWidget>> &&layer,
  20. Ui::LayerOptions options,
  21. anim::type animated) const override;
  22. not_null<QWidget*> toastParent() const override;
  23. bool valid() const override;
  24. operator bool() const override;
  25. Session &session() const override;
  26. private:
  27. const std::shared_ptr<Ui::Show> _show;
  28. const not_null<Session*> _session;
  29. };
  30. SimpleSessionShow::SimpleSessionShow(
  31. std::shared_ptr<Ui::Show> show,
  32. not_null<Session*> session)
  33. : _show(std::move(show))
  34. , _session(session) {
  35. }
  36. void SimpleSessionShow::showOrHideBoxOrLayer(
  37. std::variant<
  38. v::null_t,
  39. object_ptr<Ui::BoxContent>,
  40. std::unique_ptr<Ui::LayerWidget>> &&layer,
  41. Ui::LayerOptions options,
  42. anim::type animated) const {
  43. _show->showOrHideBoxOrLayer(std::move(layer), options, animated);
  44. }
  45. not_null<QWidget*> SimpleSessionShow::toastParent() const {
  46. return _show->toastParent();
  47. }
  48. bool SimpleSessionShow::valid() const {
  49. return _show->valid();
  50. }
  51. SimpleSessionShow::operator bool() const {
  52. return _show->operator bool();
  53. }
  54. Session &SimpleSessionShow::session() const {
  55. return *_session;
  56. }
  57. } // namespace
  58. std::shared_ptr<SessionShow> MakeSessionShow(
  59. std::shared_ptr<Ui::Show> show,
  60. not_null<Session*> session) {
  61. return std::make_shared<SimpleSessionShow>(std::move(show), session);
  62. }
  63. } // namespace Main