2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-25 19:57:20 +00:00
tdesktop/Telegram/SourceFiles/ui/chat/attach/attach_single_media_preview.h

63 lines
1.5 KiB
C
Raw Permalink Normal View History

2020-10-13 20:15:52 +03: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
2021-07-12 14:02:35 +03:00
#include "ui/chat/attach/attach_abstract_single_media_preview.h"
2020-10-13 20:15:52 +03:00
#include "media/clip/media_clip_reader.h"
namespace Lottie {
class SinglePlayer;
} // namespace Lottie
namespace Ui {
struct PreparedFile;
2021-07-12 14:02:35 +03:00
class SingleMediaPreview final : public AbstractSingleMediaPreview {
2020-10-13 20:15:52 +03:00
public:
static SingleMediaPreview *Create(
QWidget *parent,
const style::ComposeControls &st,
2020-10-13 20:15:52 +03:00
Fn<bool()> gifPaused,
const PreparedFile &file,
2025-01-29 09:24:01 +04:00
Fn<bool(AttachActionType)> actionAllowed,
AttachControls::Type type = AttachControls::Type::Full);
2020-10-13 20:15:52 +03:00
SingleMediaPreview(
QWidget *parent,
const style::ComposeControls &st,
2020-10-13 20:15:52 +03:00
Fn<bool()> gifPaused,
QImage preview,
bool animated,
bool sticker,
2022-12-13 16:11:52 +04:00
bool spoiler,
const QString &animatedPreviewPath,
AttachControls::Type type,
2025-01-29 09:24:01 +04:00
Fn<bool(AttachActionType)> actionAllowed);
2020-10-13 20:15:52 +03:00
2021-07-12 14:02:35 +03:00
protected:
bool supportsSpoilers() const override;
2021-07-12 14:02:35 +03:00
bool drawBackground() const override;
2022-09-17 00:23:27 +04:00
bool tryPaintAnimation(QPainter &p) override;
2021-07-12 14:02:35 +03:00
bool isAnimatedPreviewReady() const override;
2020-10-13 20:15:52 +03:00
private:
2021-07-12 14:02:35 +03:00
void prepareAnimatedPreview(
const QString &animatedPreviewPath,
bool animated);
2020-10-13 20:15:52 +03:00
void clipCallback(Media::Clip::Notification notification);
2021-07-12 14:02:35 +03:00
const Fn<bool()> _gifPaused;
const bool _sticker = false;
2020-10-13 20:15:52 +03:00
Media::Clip::ReaderPointer _gifPreview;
std::unique_ptr<Lottie::SinglePlayer> _lottiePreview;
};
} // namespace Ui