2019-09-13 06:06:02 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "media/clip/media_clip_reader.h"
|
|
|
|
#include "ui/effects/animations.h"
|
|
|
|
#include "data/data_file_origin.h"
|
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
namespace Data {
|
2020-05-25 14:16:04 +00:00
|
|
|
class PhotoMedia;
|
2020-04-08 15:09:29 +00:00
|
|
|
class DocumentMedia;
|
|
|
|
} // namespace Data
|
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
namespace Lottie {
|
|
|
|
class SinglePlayer;
|
|
|
|
} // namespace Lottie
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
|
|
|
class SessionController;
|
|
|
|
|
2021-07-15 11:12:38 +00:00
|
|
|
class MediaPreviewWidget final : public Ui::RpWidget {
|
2019-09-13 06:06:02 +00:00
|
|
|
public:
|
|
|
|
MediaPreviewWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller);
|
|
|
|
|
|
|
|
void showPreview(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<DocumentData*> document);
|
|
|
|
void showPreview(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<PhotoData*> photo);
|
|
|
|
void hidePreview();
|
|
|
|
|
|
|
|
~MediaPreviewWidget();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2020-05-22 13:29:19 +00:00
|
|
|
void validateGifAnimation();
|
|
|
|
void startGifAnimation(const Media::Clip::ReaderPointer &gif);
|
2019-09-13 06:06:02 +00:00
|
|
|
QSize currentDimensions() const;
|
|
|
|
QPixmap currentImage() const;
|
|
|
|
void setupLottie();
|
|
|
|
void startShow();
|
|
|
|
void fillEmojiString();
|
|
|
|
void resetGifAndCache();
|
|
|
|
[[nodiscard]] QRect updateArea() const;
|
|
|
|
|
|
|
|
not_null<Window::SessionController*> _controller;
|
|
|
|
|
|
|
|
Ui::Animations::Simple _a_shown;
|
|
|
|
bool _hiding = false;
|
|
|
|
Data::FileOrigin _origin;
|
2020-05-25 14:16:04 +00:00
|
|
|
PhotoData *_photo = nullptr;
|
2019-09-13 06:06:02 +00:00
|
|
|
DocumentData *_document = nullptr;
|
2020-05-25 14:16:04 +00:00
|
|
|
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
2020-04-08 15:09:29 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2020-05-22 13:29:19 +00:00
|
|
|
Media::Clip::ReaderPointer _gif, _gifThumbnail;
|
2022-01-25 07:16:42 +00:00
|
|
|
bool _gifWithAlpha = false;
|
2020-05-22 13:29:19 +00:00
|
|
|
crl::time _gifLastPosition = 0;
|
2019-09-13 06:06:02 +00:00
|
|
|
std::unique_ptr<Lottie::SinglePlayer> _lottie;
|
|
|
|
|
|
|
|
int _emojiSize;
|
|
|
|
std::vector<not_null<EmojiPtr>> _emojiList;
|
|
|
|
|
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
|
|
|
|
|
|
|
enum CacheStatus {
|
|
|
|
CacheNotLoaded,
|
|
|
|
CacheThumbLoaded,
|
|
|
|
CacheLoaded,
|
|
|
|
};
|
|
|
|
mutable CacheStatus _cacheStatus = CacheNotLoaded;
|
|
|
|
mutable QPixmap _cache;
|
|
|
|
mutable QSize _cachedSize;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|