2020-05-28 10:00:51 +00: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 "data/data_cloud_file.h"
|
|
|
|
|
|
|
|
class DocumentData;
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class Session;
|
2020-05-28 10:00:51 +00:00
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
using StickersSetsOrder = QList<uint64>;
|
2020-05-28 10:00:51 +00:00
|
|
|
using SavedGifs = QVector<DocumentData*>;
|
2020-06-08 17:24:36 +00:00
|
|
|
using StickersPack = QVector<DocumentData*>;
|
|
|
|
using StickersByEmojiMap = QMap<EmojiPtr, StickersPack>;
|
2020-05-28 10:00:51 +00:00
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
class StickersSet;
|
|
|
|
using StickersSets = base::flat_map<uint64, std::unique_ptr<StickersSet>>;
|
2020-05-28 10:00:51 +00:00
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
class StickersSetThumbnailView final {
|
2020-05-28 10:00:51 +00:00
|
|
|
public:
|
2020-06-08 17:24:36 +00:00
|
|
|
explicit StickersSetThumbnailView(not_null<StickersSet*> owner);
|
2020-05-28 11:58:50 +00:00
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
[[nodiscard]] not_null<StickersSet*> owner() const;
|
2020-05-28 11:58:50 +00:00
|
|
|
|
2020-05-28 10:00:51 +00:00
|
|
|
void set(not_null<Main::Session*> session, QByteArray content);
|
|
|
|
|
|
|
|
[[nodiscard]] Image *image() const;
|
|
|
|
[[nodiscard]] QByteArray content() const;
|
|
|
|
|
|
|
|
private:
|
2020-06-08 17:24:36 +00:00
|
|
|
const not_null<StickersSet*> _owner;
|
2020-05-28 10:00:51 +00:00
|
|
|
std::unique_ptr<Image> _image;
|
|
|
|
QByteArray _content;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
class StickersSet final {
|
2020-05-28 10:00:51 +00:00
|
|
|
public:
|
2020-06-08 17:24:36 +00:00
|
|
|
StickersSet(
|
2020-05-28 10:00:51 +00:00
|
|
|
not_null<Data::Session*> owner,
|
|
|
|
uint64 id,
|
|
|
|
uint64 access,
|
|
|
|
const QString &title,
|
|
|
|
const QString &shortName,
|
|
|
|
int count,
|
|
|
|
int32 hash,
|
|
|
|
MTPDstickerSet::Flags flags,
|
|
|
|
TimeId installDate);
|
|
|
|
|
2020-05-28 11:58:50 +00:00
|
|
|
[[nodiscard]] Data::Session &owner() const;
|
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
|
2020-05-28 10:00:51 +00:00
|
|
|
[[nodiscard]] MTPInputStickerSet mtpInput() 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();
|
2020-05-28 10:00:51 +00:00
|
|
|
[[nodiscard]] const ImageLocation &thumbnailLocation() const;
|
|
|
|
[[nodiscard]] int thumbnailByteSize() const;
|
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
[[nodiscard]] std::shared_ptr<StickersSetThumbnailView> createThumbnailView();
|
|
|
|
[[nodiscard]] std::shared_ptr<StickersSetThumbnailView> activeThumbnailView();
|
2020-05-28 10:00:51 +00:00
|
|
|
|
|
|
|
uint64 id = 0;
|
|
|
|
uint64 access = 0;
|
|
|
|
QString title, shortName;
|
|
|
|
int count = 0;
|
|
|
|
int32 hash = 0;
|
|
|
|
MTPDstickerSet::Flags flags;
|
|
|
|
TimeId installDate = 0;
|
2020-06-08 17:24:36 +00:00
|
|
|
StickersPack covers;
|
|
|
|
StickersPack stickers;
|
2020-05-28 10:00:51 +00:00
|
|
|
std::vector<TimeId> dates;
|
2020-06-08 17:24:36 +00:00
|
|
|
StickersByEmojiMap emoji;
|
2020-05-28 10:00:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const not_null<Data::Session*> _owner;
|
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
CloudFile _thumbnail;
|
|
|
|
std::weak_ptr<StickersSetThumbnailView> _thumbnailView;
|
2020-05-28 10:00:51 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Stickers
|