ZaStoGram_desktop/Telegram/SourceFiles/api/api_stickers_creator.h
loop-uh 5bce8c10e5 Merge upstream dev through a1ea1ddd8c (7.2.9)
Keeps the ZaStoGram MTProto layout and its unaligned-access fixes, the
Forgejo update checker and the rich-page layout contract; takes the
upstream IV editor edge restore, horizontal overflow width, round video
seek, tlottie renderer and the lib_ui text shaper.
2026-09-23 16:21:17 +03:00

127 lines
3.1 KiB
C++

/*
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 "base/weak_ptr.h"
#include "data/stickers/data_stickers.h"
#include "mtproto/instance/sender.h"
class DocumentData;
namespace ChatHelpers {
class Show;
} // namespace ChatHelpers
namespace Main {
class Session;
} // namespace Main
namespace Ui {
class PopupMenu;
namespace Menu {
struct MenuCallback;
} // namespace Menu
} // namespace Ui
namespace Api {
inline constexpr auto kStickersInOwnedSetMax = 120;
inline constexpr auto kEmojiInOwnedSetMax = 200;
inline constexpr auto kEmojiStickerSideMax = 100;
void AddExistingStickerToSet(
not_null<Main::Session*> session,
const StickerSetIdentifier &set,
not_null<DocumentData*> document,
const QString &emoji,
Fn<void(MTPmessages_StickerSet)> done,
Fn<void(QString)> fail);
void DeleteStickerSet(
not_null<Main::Session*> session,
const StickerSetIdentifier &set,
Fn<void()> done,
Fn<void(QString)> fail);
[[nodiscard]] bool HasOwnedStickerSets(not_null<Main::Session*> session);
[[nodiscard]] bool HasOwnedEmojiSets(not_null<Main::Session*> session);
[[nodiscard]] QString StickerEmojiOrDefault(
not_null<DocumentData*> document);
void FillChooseStickerSetMenu(
not_null<Ui::PopupMenu*> menu,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void FillChooseEmojiSetMenu(
not_null<Ui::PopupMenu*> menu,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void AddAddToStickerSetAction(
const Ui::Menu::MenuCallback &addAction,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void AddAddToEmojiSetAction(
const Ui::Menu::MenuCallback &addAction,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void AddAddToOwnedSetAction(
const Ui::Menu::MenuCallback &addAction,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
class StickerUpload final : public base::has_weak_ptr {
public:
StickerUpload(
not_null<Main::Session*> session,
StickerSetIdentifier set,
QByteArray bytes,
QSize dimensions,
QString emoji,
Data::StickersType type = Data::StickersType::Stickers,
crl::time videoDuration = 0);
~StickerUpload();
void start(
Fn<void(MTPmessages_StickerSet)> done,
Fn<void(QString)> fail,
Fn<void(int /*percent*/)> progress = nullptr);
void cancel();
private:
void uploadReady(const MTPInputFile &file);
void uploadFailed();
void uploadProgressed();
void requestAddSticker(const MTPInputDocument &document);
const not_null<Main::Session*> _session;
StickerSetIdentifier _set;
QByteArray _bytes;
QSize _dimensions;
QString _emoji;
Data::StickersType _type = Data::StickersType::Stickers;
crl::time _videoDuration = 0;
MTP::Sender _api;
rpl::lifetime _uploadLifetime;
FullMsgId _uploadId;
DocumentId _documentId = 0;
mtpRequestId _addRequestId = 0;
Fn<void(MTPmessages_StickerSet)> _done;
Fn<void(QString)> _fail;
Fn<void(int)> _progress;
int _lastReportedPercent = -1;
};
} // namespace Api