tdesktop/Telegram/SourceFiles/boxes/sticker_set_box.h

118 lines
2.5 KiB
C
Raw Normal View History

2015-05-19 15:46:45 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2015-05-19 15:46:45 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2015-05-19 15:46:45 +00:00
*/
#pragma once
2017-04-06 14:38:10 +00:00
#include "boxes/abstract_box.h"
#include "chat_helpers/stickers.h"
2015-05-19 15:46:45 +00:00
2016-07-15 15:58:52 +00:00
class ConfirmBox;
namespace Ui {
class PlainShadow;
} // namespace Ui
2016-07-15 15:58:52 +00:00
class StickerSetBox : public BoxContent, public RPCSender {
2015-05-19 15:46:45 +00:00
Q_OBJECT
public:
StickerSetBox(QWidget*, const MTPInputStickerSet &set);
protected:
void prepare() override;
void resizeEvent(QResizeEvent *e) override;
private slots:
void onAddStickers();
void onShareStickers();
void onUpdateButtons();
private:
void updateButtons();
MTPInputStickerSet _set;
class Inner;
QPointer<Inner> _inner;
};
// This class is hold in header because it requires Qt preprocessing.
class StickerSetBox::Inner : public TWidget, public RPCSender, private base::Subscriber {
Q_OBJECT
public:
Inner(QWidget *parent, const MTPInputStickerSet &set);
2015-05-19 15:46:45 +00:00
bool loaded() const;
2018-01-25 12:28:48 +00:00
bool notInstalled() const;
bool official() const;
Fn<TextWithEntities()> title() const;
2015-05-19 15:46:45 +00:00
QString shortName() const;
void install();
2017-09-27 12:04:19 +00:00
auto setInstalled() const {
return _setInstalled.events();
}
2015-05-19 15:46:45 +00:00
~Inner();
2015-05-19 15:46:45 +00:00
protected:
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void leaveEventHook(QEvent *e) override;
private slots:
void onPreview();
2015-05-19 15:46:45 +00:00
signals:
void updateButtons();
private:
void updateSelected();
void setSelected(int selected);
void startOverAnimation(int index, float64 from, float64 to);
int stickerFromGlobalPos(const QPoint &p) const;
2015-05-19 15:46:45 +00:00
void gotSet(const MTPmessages_StickerSet &set);
bool failedSet(const RPCError &error);
void installDone(const MTPmessages_StickerSetInstallResult &result);
bool installFail(const RPCError &error);
2015-05-19 15:46:45 +00:00
bool isMasksSet() const {
return (_setFlags & MTPDstickerSet::Flag::f_masks);
}
std::vector<Animation> _packOvers;
Stickers::Pack _pack;
Stickers::ByEmojiMap _emoji;
bool _loaded = false;
uint64 _setId = 0;
uint64 _setAccess = 0;
QString _setTitle, _setShortName;
2018-01-25 12:28:48 +00:00
int _setCount = 0;
int32 _setHash = 0;
MTPDstickerSet::Flags _setFlags = 0;
2018-01-25 12:28:48 +00:00
TimeId _setInstallDate = TimeId(0);
2015-05-19 15:46:45 +00:00
MTPInputStickerSet _input;
mtpRequestId _installRequest = 0;
int _selected = -1;
QTimer _previewTimer;
int _previewShown = -1;
rpl::event_stream<uint64> _setInstalled;
2015-05-19 15:46:45 +00:00
};