2016-10-20 16:32:15 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-10-20 16:32:15 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2017-08-05 20:01:20 +00:00
|
|
|
#include "base/timer.h"
|
|
|
|
#include "mtproto/sender.h"
|
2020-06-08 17:24:36 +00:00
|
|
|
#include "data/stickers/data_stickers_set.h"
|
2019-04-01 17:44:54 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2022-03-28 10:47:48 +00:00
|
|
|
#include "ui/widgets/fields/special_fields.h"
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2016-11-22 09:48:13 +00:00
|
|
|
namespace style {
|
|
|
|
struct RippleAnimation;
|
2023-08-09 10:46:30 +00:00
|
|
|
struct PeerListItem;
|
2016-11-22 09:48:13 +00:00
|
|
|
} // namespace style
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
namespace Ui {
|
|
|
|
class PlainShadow;
|
2016-11-16 16:04:25 +00:00
|
|
|
class RippleAnimation;
|
2016-11-22 09:48:13 +00:00
|
|
|
class SettingsSlider;
|
2016-11-24 19:28:23 +00:00
|
|
|
class SlideAnimation;
|
2017-08-05 20:01:20 +00:00
|
|
|
class CrossButton;
|
2019-09-18 11:19:05 +00:00
|
|
|
class BoxContentDivider;
|
2016-10-20 16:32:15 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2023-05-02 09:33:19 +00:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class Show;
|
|
|
|
} // namespace ChatHelpers
|
2020-06-23 17:21:58 +00:00
|
|
|
|
2019-08-06 16:40:08 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2020-05-28 10:00:51 +00:00
|
|
|
namespace Data {
|
|
|
|
class DocumentMedia;
|
2022-07-18 13:56:14 +00:00
|
|
|
enum class StickersType : uchar;
|
2020-05-28 10:00:51 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Lottie {
|
|
|
|
class SinglePlayer;
|
|
|
|
} // namespace Lottie
|
|
|
|
|
2020-05-28 11:58:50 +00:00
|
|
|
namespace Stickers {
|
|
|
|
class Set;
|
|
|
|
} // namespace Stickers
|
|
|
|
|
2021-07-15 11:12:38 +00:00
|
|
|
class StickersBox final : public Ui::BoxContent {
|
2016-10-20 16:32:15 +00:00
|
|
|
public:
|
|
|
|
enum class Section {
|
|
|
|
Installed,
|
|
|
|
Featured,
|
|
|
|
Archived,
|
2019-03-10 12:55:24 +00:00
|
|
|
Attached,
|
2021-03-29 17:37:03 +00:00
|
|
|
Masks,
|
2016-10-20 16:32:15 +00:00
|
|
|
};
|
2019-08-06 16:40:08 +00:00
|
|
|
|
|
|
|
StickersBox(
|
|
|
|
QWidget*,
|
2023-05-02 09:33:19 +00:00
|
|
|
std::shared_ptr<ChatHelpers::Show> show,
|
2021-03-30 14:54:11 +00:00
|
|
|
Section section,
|
|
|
|
bool masks = false);
|
2019-08-06 16:40:08 +00:00
|
|
|
StickersBox(
|
|
|
|
QWidget*,
|
2023-05-02 09:33:19 +00:00
|
|
|
std::shared_ptr<ChatHelpers::Show> show,
|
2020-06-23 17:21:58 +00:00
|
|
|
not_null<ChannelData*> megagroup);
|
|
|
|
StickersBox(
|
|
|
|
QWidget*,
|
2023-05-02 09:33:19 +00:00
|
|
|
std::shared_ptr<ChatHelpers::Show> show,
|
2022-08-15 08:33:24 +00:00
|
|
|
const QVector<MTPStickerSetCovered> &attachedSets);
|
2022-07-18 13:56:14 +00:00
|
|
|
StickersBox(
|
|
|
|
QWidget*,
|
2023-05-02 09:33:19 +00:00
|
|
|
std::shared_ptr<ChatHelpers::Show> show,
|
2022-07-18 13:56:14 +00:00
|
|
|
const std::vector<StickerSetIdentifier> &emojiSets);
|
2020-06-11 16:09:46 +00:00
|
|
|
~StickersBox();
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2020-06-23 17:21:58 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
|
2017-08-05 20:01:20 +00:00
|
|
|
void setInnerFocus() override;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Inner;
|
2016-12-13 17:07:56 +00:00
|
|
|
class Tab {
|
|
|
|
public:
|
|
|
|
Tab() = default;
|
|
|
|
|
2016-11-22 09:48:13 +00:00
|
|
|
template <typename ...Args>
|
2016-12-13 17:07:56 +00:00
|
|
|
Tab(int index, Args&&... args);
|
|
|
|
|
|
|
|
object_ptr<Inner> takeWidget();
|
|
|
|
void returnWidget(object_ptr<Inner> widget);
|
|
|
|
|
2021-03-29 17:37:03 +00:00
|
|
|
[[nodiscard]] Inner *widget() const;
|
2020-06-08 17:24:36 +00:00
|
|
|
[[nodiscard]] int index() const;
|
2016-12-13 17:07:56 +00:00
|
|
|
|
|
|
|
void saveScrollTop();
|
|
|
|
int getScrollTop() const {
|
|
|
|
return _scrollTop;
|
2016-11-22 09:48:13 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
private:
|
2021-03-29 17:37:03 +00:00
|
|
|
const int _index = 0;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Inner> _widget = { nullptr };
|
|
|
|
QPointer<Inner> _weak;
|
|
|
|
int _scrollTop = 0;
|
|
|
|
|
2016-11-22 09:48:13 +00:00
|
|
|
};
|
2016-12-22 13:30:27 +00:00
|
|
|
|
2017-08-05 10:48:21 +00:00
|
|
|
void handleStickersUpdated();
|
2016-12-22 13:30:27 +00:00
|
|
|
void refreshTabs();
|
|
|
|
void rebuildList(Tab *tab = nullptr);
|
|
|
|
void updateTabsGeometry();
|
|
|
|
void switchTab();
|
|
|
|
void installSet(uint64 setId);
|
|
|
|
int getTopSkip() const;
|
2017-08-13 16:09:14 +00:00
|
|
|
void saveChanges();
|
2016-12-22 13:30:27 +00:00
|
|
|
|
|
|
|
QPixmap grabContentCache();
|
|
|
|
|
|
|
|
void installDone(const MTPmessages_StickerSetInstallResult &result);
|
2021-03-12 12:48:00 +00:00
|
|
|
void installFail(const MTP::Error &error, uint64 setId);
|
2016-12-22 13:30:27 +00:00
|
|
|
|
|
|
|
void preloadArchivedSets();
|
|
|
|
void requestArchivedSets();
|
|
|
|
void loadMoreArchived();
|
2020-06-11 16:09:46 +00:00
|
|
|
void getArchivedDone(
|
|
|
|
const MTPmessages_ArchivedStickers &result,
|
|
|
|
uint64 offsetId);
|
2019-03-10 12:55:24 +00:00
|
|
|
void showAttachedStickers();
|
2016-12-22 13:30:27 +00:00
|
|
|
|
2021-03-30 15:51:45 +00:00
|
|
|
const Data::StickersSetsOrder &archivedSetsOrder() const;
|
|
|
|
Data::StickersSetsOrder &archivedSetsOrderRef();
|
|
|
|
|
2021-03-29 17:37:03 +00:00
|
|
|
std::array<Inner*, 5> widgets() const;
|
|
|
|
|
2023-08-09 10:46:30 +00:00
|
|
|
const style::PeerListItem &_st;
|
2023-05-02 09:33:19 +00:00
|
|
|
const std::shared_ptr<ChatHelpers::Show> _show;
|
|
|
|
const not_null<Main::Session*> _session;
|
2020-06-11 16:09:46 +00:00
|
|
|
MTP::Sender _api;
|
2019-08-06 16:40:08 +00:00
|
|
|
|
2016-12-22 13:30:27 +00:00
|
|
|
object_ptr<Ui::SettingsSlider> _tabs = { nullptr };
|
|
|
|
QList<Section> _tabIndices;
|
2021-12-31 13:50:43 +00:00
|
|
|
bool _ignoreTabActivation = false;
|
2016-12-22 13:30:27 +00:00
|
|
|
|
|
|
|
class CounterWidget;
|
|
|
|
object_ptr<CounterWidget> _unreadBadge = { nullptr };
|
|
|
|
|
|
|
|
Section _section;
|
2021-03-30 14:54:11 +00:00
|
|
|
const bool _isMasks;
|
2022-07-27 09:26:22 +00:00
|
|
|
const bool _isEmoji;
|
2016-12-22 13:30:27 +00:00
|
|
|
|
2016-11-22 09:48:13 +00:00
|
|
|
Tab _installed;
|
2021-03-29 17:37:03 +00:00
|
|
|
Tab _masks;
|
2016-11-22 09:48:13 +00:00
|
|
|
Tab _featured;
|
|
|
|
Tab _archived;
|
2019-03-10 12:55:24 +00:00
|
|
|
Tab _attached;
|
2016-11-22 09:48:13 +00:00
|
|
|
Tab *_tab = nullptr;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2022-07-18 13:56:14 +00:00
|
|
|
const Data::StickersType _attachedType = {};
|
2022-08-15 08:33:24 +00:00
|
|
|
const QVector<MTPStickerSetCovered> _attachedSets;
|
2022-07-18 13:56:14 +00:00
|
|
|
const std::vector<StickerSetIdentifier> _emojiSets;
|
2019-03-10 12:55:24 +00:00
|
|
|
|
2017-08-05 10:48:21 +00:00
|
|
|
ChannelData *_megagroupSet = nullptr;
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Ui::SlideAnimation> _slideAnimation;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::PlainShadow> _titleShadow = { nullptr };
|
2016-10-20 16:32:15 +00:00
|
|
|
|
|
|
|
mtpRequestId _archivedRequestId = 0;
|
2016-11-22 09:48:13 +00:00
|
|
|
bool _archivedLoaded = false;
|
2016-10-20 16:32:15 +00:00
|
|
|
bool _allArchivedLoaded = false;
|
2016-11-22 09:48:13 +00:00
|
|
|
bool _someArchivedLoaded = false;
|
|
|
|
|
2020-06-08 17:24:36 +00:00
|
|
|
Data::StickersSetsOrder _localOrder;
|
|
|
|
Data::StickersSetsOrder _localRemoved;
|
2016-11-16 16:04:25 +00:00
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
};
|