tdesktop/Telegram/SourceFiles/data/stickers/data_stickers_set.h

128 lines
3.2 KiB
C
Raw Normal View History

/*
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 "data/data_cloud_file.h"
class DocumentData;
namespace Main {
class Session;
} // namespace Main
namespace Data {
class Session;
using StickersSetsOrder = QList<uint64>;
using SavedGifs = QVector<DocumentData*>;
using StickersPack = QVector<DocumentData*>;
using StickersByEmojiMap = QMap<EmojiPtr, StickersPack>;
2022-07-22 11:39:28 +00:00
enum class StickersType : uchar;
class StickersSet;
using StickersSets = base::flat_map<uint64, std::unique_ptr<StickersSet>>;
class StickersSetThumbnailView final {
public:
explicit StickersSetThumbnailView(not_null<StickersSet*> owner);
2020-05-28 11:58:50 +00:00
[[nodiscard]] not_null<StickersSet*> owner() const;
2020-05-28 11:58:50 +00:00
void set(not_null<Main::Session*> session, QByteArray content);
[[nodiscard]] Image *image() const;
[[nodiscard]] QByteArray content() const;
private:
const not_null<StickersSet*> _owner;
std::unique_ptr<Image> _image;
QByteArray _content;
};
2021-07-09 06:08:58 +00:00
enum class StickersSetFlag {
Installed = (1 << 0),
Archived = (1 << 1),
Masks = (1 << 2),
Official = (1 << 3),
NotLoaded = (1 << 4),
Featured = (1 << 5),
Unread = (1 << 6),
Special = (1 << 7),
Webm = (1 << 8),
2022-07-08 17:04:31 +00:00
Emoji = (1 << 9),
2021-07-09 06:08:58 +00:00
};
inline constexpr bool is_flag_type(StickersSetFlag) { return true; };
using StickersSetFlags = base::flags<StickersSetFlag>;
[[nodiscard]] StickersSetFlags ParseStickersSetFlags(
const MTPDstickerSet &data);
class StickersSet final {
public:
StickersSet(
not_null<Data::Session*> owner,
uint64 id,
2021-08-25 08:15:05 +00:00
uint64 accessHash,
uint64 hash,
const QString &title,
const QString &shortName,
int count,
2021-07-09 06:08:58 +00:00
StickersSetFlags flags,
TimeId installDate);
2020-05-28 11:58:50 +00:00
[[nodiscard]] Data::Session &owner() const;
[[nodiscard]] Main::Session &session() const;
[[nodiscard]] MTPInputStickerSet mtpInput() const;
[[nodiscard]] StickerSetIdentifier identifier() const;
2022-07-22 11:39:28 +00:00
[[nodiscard]] StickersType type() const;
void setThumbnail(const ImageWithLocation &data);
[[nodiscard]] bool hasThumbnail() const;
[[nodiscard]] bool thumbnailLoading() const;
[[nodiscard]] bool thumbnailFailed() const;
2020-05-28 11:58:50 +00:00
void loadThumbnail();
[[nodiscard]] const ImageLocation &thumbnailLocation() const;
[[nodiscard]] Storage::Cache::Key thumbnailBigFileBaseCacheKey() const;
[[nodiscard]] int thumbnailByteSize() const;
[[nodiscard]] DocumentData *lookupThumbnailDocument() const;
[[nodiscard]] std::shared_ptr<StickersSetThumbnailView> createThumbnailView();
[[nodiscard]] std::shared_ptr<StickersSetThumbnailView> activeThumbnailView();
uint64 id = 0;
2021-08-25 08:15:05 +00:00
uint64 accessHash = 0;
uint64 hash = 0;
DocumentId thumbnailDocumentId = 0;
QString title, shortName;
int count = 0;
2022-07-27 09:26:22 +00:00
int locked = 0;
2021-07-09 06:08:58 +00:00
StickersSetFlags flags;
TimeId installDate = 0;
StickersPack covers;
StickersPack stickers;
std::vector<TimeId> dates;
StickersByEmojiMap emoji;
private:
const not_null<Data::Session*> _owner;
CloudFile _thumbnail;
std::weak_ptr<StickersSetThumbnailView> _thumbnailView;
};
[[nodiscard]] MTPInputStickerSet InputStickerSet(StickerSetIdentifier id);
[[nodiscard]] StickerSetIdentifier FromInputSet(const MTPInputStickerSet &id);
} // namespace Data