Show all .webp as stickers.

Allow opening stickers not from stickerpacks in media viewer.
This commit is contained in:
John Preston 2021-02-16 19:23:16 +04:00
parent dcebefe2bb
commit 8ec60e0321
3 changed files with 16 additions and 6 deletions

View file

@ -168,3 +168,12 @@ TimeId DateFromMessage(const MTPmessage &message) {
return message.vdate().v;
});
}
bool GoodStickerDimensions(int width, int height) {
// Show all .webp (except very large ones) as stickers,
// allow to open them in media viewer to see details.
constexpr auto kLargetsStickerSide = 2560;
return (width > 0)
&& (height > 0)
&& (width * height <= kLargetsStickerSide * kLargetsStickerSide);
}

View file

@ -325,12 +325,7 @@ enum DocumentType {
};
inline constexpr auto kStickerSideSize = 512;
[[nodiscard]] inline bool GoodStickerDimensions(int width, int height) {
return (width > 0 && width <= kStickerSideSize)
&& (height > 0 && height <= kStickerSideSize)
&& (width == kStickerSideSize || height == kStickerSideSize);
}
[[nodiscard]] bool GoodStickerDimensions(int width, int height);
using MediaKey = QPair<uint64, uint64>;

View file

@ -273,6 +273,12 @@ void Sticker::refreshLink() {
_link = std::make_shared<LambdaClickHandler>([document = _data] {
StickerSetBox::Show(App::wnd()->sessionController(), document);
});
} else if (sticker
&& !_parent->data()->isSending()
&& !_parent->data()->hasFailed()) {
_link = std::make_shared<DocumentOpenClickHandler>(
_data,
_parent->data()->fullId());
}
}