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