info_statistics_recent_message.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/rp_widget.h"
  9. class HistoryItem;
  10. namespace Data {
  11. class DocumentMedia;
  12. class PhotoMedia;
  13. class Story;
  14. } // namespace Data
  15. namespace Ui {
  16. class SpoilerAnimation;
  17. } // namespace Ui
  18. namespace Info::Statistics {
  19. struct SavedState;
  20. class MessagePreview final : public Ui::RpWidget {
  21. public:
  22. MessagePreview(
  23. not_null<Ui::RpWidget*> parent,
  24. not_null<HistoryItem*> item,
  25. QImage cachedPreview);
  26. MessagePreview(
  27. not_null<Ui::RpWidget*> parent,
  28. not_null<Data::Story*> story,
  29. QImage cachedPreview);
  30. void setInfo(int views, int shares, int reactions);
  31. void saveState(SavedState &state) const;
  32. protected:
  33. void paintEvent(QPaintEvent *e) override;
  34. int resizeGetHeight(int newWidth) override;
  35. private:
  36. void processPreview();
  37. FullMsgId _messageId;
  38. FullStoryId _storyId;
  39. Ui::Text::String _text;
  40. Ui::Text::String _date;
  41. Ui::Text::String _views;
  42. Ui::Text::String _shares;
  43. Ui::Text::String _reactions;
  44. int _viewsWidth = 0;
  45. int _sharesWidth = 0;
  46. int _reactionsWidth = 0;
  47. QImage _cornerCache;
  48. QImage _preview;
  49. std::shared_ptr<Data::PhotoMedia> _photoMedia;
  50. std::shared_ptr<Data::DocumentMedia> _documentMedia;
  51. std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
  52. rpl::lifetime _lifetimeDownload;
  53. };
  54. } // namespace Info::Statistics