2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-27 12:57:09 +00:00
kotatogram-desktop/Telegram/SourceFiles/ui/chat/attach/attach_single_media_preview.h

71 lines
1.7 KiB
C
Raw 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
#include "ui/rp_widget.h"
#include "ui/round_rect.h"
2020-10-13 20:15:52 +03:00
#include "media/clip/media_clip_reader.h"
#include "base/object_ptr.h"
2020-10-13 20:15:52 +03:00
namespace Lottie {
class SinglePlayer;
} // namespace Lottie
namespace Ui {
struct PreparedFile;
class IconButton;
2020-10-13 20:15:52 +03:00
class SingleMediaPreview final : public RpWidget {
2020-10-13 20:15:52 +03:00
public:
static SingleMediaPreview *Create(
QWidget *parent,
Fn<bool()> gifPaused,
const PreparedFile &file);
SingleMediaPreview(
QWidget *parent,
Fn<bool()> gifPaused,
QImage preview,
bool animated,
bool sticker,
const QString &animatedPreviewPath);
~SingleMediaPreview();
[[nodiscard]] rpl::producer<> deleteRequests() const;
[[nodiscard]] rpl::producer<> editRequests() const;
2020-10-13 20:15:52 +03:00
private:
2020-10-13 20:15:52 +03:00
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
2020-10-13 20:15:52 +03:00
void preparePreview(
QImage preview,
const QString &animatedPreviewPath);
void prepareAnimatedPreview(const QString &animatedPreviewPath);
void paintButtonsBackground(QPainter &p);
2020-10-13 20:15:52 +03:00
void clipCallback(Media::Clip::Notification notification);
Fn<bool()> _gifPaused;
bool _animated = false;
bool _sticker = false;
QPixmap _preview;
int _previewLeft = 0;
int _previewWidth = 0;
int _previewHeight = 0;
Media::Clip::ReaderPointer _gifPreview;
std::unique_ptr<Lottie::SinglePlayer> _lottiePreview;
object_ptr<IconButton> _editMedia = { nullptr };
object_ptr<IconButton> _deleteMedia = { nullptr };
RoundRect _buttonsRect;
2020-10-13 20:15:52 +03:00
};
} // namespace Ui