mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Respected option from app config in emoji preview for userpic builder.
This commit is contained in:
parent
36190258be
commit
d6bf5513ff
2 changed files with 32 additions and 1 deletions
|
@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "history/view/media/history_view_sticker_player.h"
|
||||
#include "info/userpic/info_userpic_emoji_builder_common.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/rect.h"
|
||||
|
||||
|
@ -29,6 +31,10 @@ not_null<DocumentData*> PreviewPainter::document() const {
|
|||
return _media->owner();
|
||||
}
|
||||
|
||||
void PreviewPainter::setPlayOnce(bool value) {
|
||||
_playOnce = value;
|
||||
}
|
||||
|
||||
void PreviewPainter::setDocument(
|
||||
not_null<DocumentData*> document,
|
||||
Fn<void()> updateCallback) {
|
||||
|
@ -43,6 +49,13 @@ void PreviewPainter::setDocument(
|
|||
_media->checkStickerLarge();
|
||||
_media->goodThumbnailWanted();
|
||||
|
||||
if (_playOnce) {
|
||||
_firstFrameShown = false;
|
||||
_paused = false;
|
||||
} else {
|
||||
_paused = true;
|
||||
}
|
||||
|
||||
rpl::single() | rpl::then(
|
||||
document->owner().session().downloaderTaskFinished()
|
||||
) | rpl::start_with_next([=] {
|
||||
|
@ -94,6 +107,14 @@ bool PreviewPainter::paintForeground(QPainter &p) {
|
|||
crl::now(),
|
||||
_paused);
|
||||
|
||||
if (_playOnce) {
|
||||
if (!_firstFrameShown && (frame.index == 1)) {
|
||||
_firstFrameShown = true;
|
||||
} else if (_firstFrameShown && !frame.index) {
|
||||
_paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (frame.image.width() == frame.image.height()) {
|
||||
p.drawImage(_frameRect, frame.image);
|
||||
} else {
|
||||
|
@ -119,7 +140,12 @@ EmojiUserpic::EmojiUserpic(not_null<Ui::RpWidget*> parent, const QSize &size)
|
|||
}
|
||||
|
||||
void EmojiUserpic::setDocument(not_null<DocumentData*> document) {
|
||||
if (!_playOnce.has_value()) {
|
||||
const auto &c = document->owner().session().account().appConfig();
|
||||
_playOnce = !c.get<bool>(u"upload_markup_video"_q, false);
|
||||
}
|
||||
_painter.setDocument(document, [=] { update(); });
|
||||
_painter.setPlayOnce(*_playOnce);
|
||||
}
|
||||
|
||||
void EmojiUserpic::result(int size, Fn<void(QImage &&image)> done) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
|
||||
[[nodiscard]] not_null<DocumentData*> document() const;
|
||||
|
||||
void setPlayOnce(bool value);
|
||||
void setDocument(
|
||||
not_null<DocumentData*> document,
|
||||
Fn<void()> updateCallback);
|
||||
|
@ -43,7 +44,9 @@ private:
|
|||
|
||||
std::shared_ptr<Data::DocumentMedia> _media;
|
||||
std::unique_ptr<HistoryView::StickerPlayer> _player;
|
||||
bool _paused = true;
|
||||
bool _playOnce = false;
|
||||
bool _paused = false;
|
||||
bool _firstFrameShown = false;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
@ -63,6 +66,8 @@ protected:
|
|||
private:
|
||||
PreviewPainter _painter;
|
||||
|
||||
std::optional<bool> _playOnce;
|
||||
|
||||
QImage _previousImage;
|
||||
QImage _image;
|
||||
std::vector<QColor> _colors;
|
||||
|
|
Loading…
Add table
Reference in a new issue