sticker_set_box.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/layers/box_content.h"
  9. #include "base/timer.h"
  10. #include "data/stickers/data_stickers.h"
  11. #include "ui/rect_part.h"
  12. namespace Window {
  13. class SessionController;
  14. } // namespace Window
  15. namespace Ui {
  16. class PlainShadow;
  17. } // namespace Ui
  18. namespace Data {
  19. class StickersSet;
  20. } // namespace Data
  21. namespace ChatHelpers {
  22. struct FileChosen;
  23. class Show;
  24. } // namespace ChatHelpers
  25. class StickerPremiumMark final {
  26. public:
  27. StickerPremiumMark(
  28. not_null<Main::Session*> session,
  29. const style::icon &lockIcon,
  30. RectPart part = RectPart::Bottom);
  31. void paint(
  32. QPainter &p,
  33. const QImage &frame,
  34. QImage &backCache,
  35. QPoint position,
  36. QSize singleSize,
  37. int outerWidth);
  38. private:
  39. void validateLock(const QImage &frame, QImage &backCache);
  40. void validateStar();
  41. const style::icon &_lockIcon;
  42. QImage _lockGray;
  43. QImage _star;
  44. RectPart _part = RectPart::Bottom;
  45. bool _premium = false;
  46. rpl::lifetime _lifetime;
  47. };
  48. class StickerSetBox final : public Ui::BoxContent {
  49. public:
  50. StickerSetBox(
  51. QWidget*,
  52. std::shared_ptr<ChatHelpers::Show> show,
  53. const StickerSetIdentifier &set,
  54. Data::StickersType type);
  55. StickerSetBox(
  56. QWidget*,
  57. std::shared_ptr<ChatHelpers::Show> show,
  58. not_null<Data::StickersSet*> set);
  59. static QPointer<Ui::BoxContent> Show(
  60. std::shared_ptr<ChatHelpers::Show> show,
  61. not_null<DocumentData*> document);
  62. protected:
  63. void prepare() override;
  64. void resizeEvent(QResizeEvent *e) override;
  65. private:
  66. enum class Error {
  67. NotFound,
  68. };
  69. void updateTitleAndButtons();
  70. void updateButtons();
  71. void addStickers();
  72. void copyStickersLink();
  73. void handleError(Error error);
  74. const std::shared_ptr<ChatHelpers::Show> _show;
  75. const not_null<Main::Session*> _session;
  76. const StickerSetIdentifier _set;
  77. const Data::StickersType _type;
  78. class Inner;
  79. QPointer<Inner> _inner;
  80. };