/* 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 "boxes/abstract_box.h" #include "base/timer.h" #include "mtproto/sender.h" #include "data/stickers/data_stickers_set.h" #include "ui/effects/animations.h" #include "ui/widgets/fields/special_fields.h" namespace style { struct RippleAnimation; struct PeerListItem; } // namespace style namespace Ui { class PlainShadow; class RippleAnimation; class SettingsSlider; class SlideAnimation; class CrossButton; class BoxContentDivider; } // namespace Ui namespace ChatHelpers { class Show; } // namespace ChatHelpers namespace Main { class Session; } // namespace Main namespace Data { class DocumentMedia; enum class StickersType : uchar; } // namespace Data namespace Lottie { class SinglePlayer; } // namespace Lottie namespace Stickers { class Set; } // namespace Stickers class StickersBox final : public Ui::BoxContent { public: enum class Section { Installed, Featured, Archived, Attached, Masks, }; StickersBox( QWidget*, std::shared_ptr show, Section section, bool masks = false); StickersBox( QWidget*, std::shared_ptr show, not_null megagroup); StickersBox( QWidget*, std::shared_ptr show, const QVector &attachedSets); StickersBox( QWidget*, std::shared_ptr show, const std::vector &emojiSets); ~StickersBox(); [[nodiscard]] Main::Session &session() const; void setInnerFocus() override; protected: void prepare() override; void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; private: class Inner; class Tab { public: Tab() = default; template Tab(int index, Args&&... args); object_ptr takeWidget(); void returnWidget(object_ptr widget); [[nodiscard]] Inner *widget() const; [[nodiscard]] int index() const; void saveScrollTop(); int scrollTop() const { return _scrollTop; } private: const int _index = 0; object_ptr _widget = { nullptr }; QPointer _weak; int _scrollTop = 0; }; void handleStickersUpdated(); void refreshTabs(); void rebuildList(Tab *tab = nullptr); void updateTabsGeometry(); void switchTab(); void installSet(uint64 setId); int topSkip() const; void saveChanges(); QPixmap grabContentCache(); void installDone(const MTPmessages_StickerSetInstallResult &result) const; void installFail(const MTP::Error &error, uint64 setId); void preloadArchivedSets(); void requestArchivedSets(); void loadMoreArchived(); void getArchivedDone( const MTPmessages_ArchivedStickers &result, uint64 offsetId); void showAttachedStickers(); const Data::StickersSetsOrder &archivedSetsOrder() const; Data::StickersSetsOrder &archivedSetsOrderRef() const; std::array widgets() const; const style::PeerListItem &_st; const std::shared_ptr _show; const not_null _session; MTP::Sender _api; object_ptr _tabs = { nullptr }; QList
_tabIndices; bool _ignoreTabActivation = false; class CounterWidget; object_ptr _unreadBadge = { nullptr }; Section _section; const bool _isMasks; const bool _isEmoji; Tab _installed; Tab _masks; Tab _featured; Tab _archived; Tab _attached; Tab *_tab = nullptr; const Data::StickersType _attachedType = {}; const QVector _attachedSets; const std::vector _emojiSets; ChannelData *_megagroupSet = nullptr; std::unique_ptr _slideAnimation; object_ptr _titleShadow = { nullptr }; mtpRequestId _archivedRequestId = 0; bool _archivedLoaded = false; bool _allArchivedLoaded = false; bool _someArchivedLoaded = false; Data::StickersSetsOrder _localOrder; Data::StickersSetsOrder _localRemoved; };