attach_single_media_preview.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/chat/attach/attach_abstract_single_media_preview.h"
  9. #include "media/clip/media_clip_reader.h"
  10. namespace Lottie {
  11. class SinglePlayer;
  12. } // namespace Lottie
  13. namespace Ui {
  14. struct PreparedFile;
  15. class SingleMediaPreview final : public AbstractSingleMediaPreview {
  16. public:
  17. static SingleMediaPreview *Create(
  18. QWidget *parent,
  19. const style::ComposeControls &st,
  20. Fn<bool()> gifPaused,
  21. const PreparedFile &file,
  22. Fn<bool(AttachActionType)> actionAllowed,
  23. AttachControls::Type type = AttachControls::Type::Full);
  24. SingleMediaPreview(
  25. QWidget *parent,
  26. const style::ComposeControls &st,
  27. Fn<bool()> gifPaused,
  28. QImage preview,
  29. bool animated,
  30. bool sticker,
  31. bool spoiler,
  32. const QString &animatedPreviewPath,
  33. AttachControls::Type type,
  34. Fn<bool(AttachActionType)> actionAllowed);
  35. protected:
  36. bool supportsSpoilers() const override;
  37. bool drawBackground() const override;
  38. bool tryPaintAnimation(QPainter &p) override;
  39. bool isAnimatedPreviewReady() const override;
  40. private:
  41. void prepareAnimatedPreview(
  42. const QString &animatedPreviewPath,
  43. bool animated);
  44. void clipCallback(Media::Clip::Notification notification);
  45. const Fn<bool()> _gifPaused;
  46. const bool _sticker = false;
  47. Media::Clip::ReaderPointer _gifPreview;
  48. std::unique_ptr<Lottie::SinglePlayer> _lottiePreview;
  49. };
  50. } // namespace Ui