2015-05-19 15:46:45 +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.
|
2015-05-19 15:46:45 +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
|
2015-05-19 15:46:45 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2017-11-05 17:07:27 +00:00
|
|
|
#include "chat_helpers/stickers.h"
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2016-07-15 15:58:52 +00:00
|
|
|
class ConfirmBox;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
namespace Ui {
|
|
|
|
class PlainShadow;
|
|
|
|
} // namespace Ui
|
2016-07-15 15:58:52 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class StickerSetBox : public BoxContent, public RPCSender {
|
2015-05-19 15:46:45 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
StickerSetBox(QWidget*, const MTPInputStickerSet &set);
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private slots:
|
2016-10-20 16:32:15 +00:00
|
|
|
void onAddStickers();
|
|
|
|
void onShareStickers();
|
|
|
|
void onUpdateButtons();
|
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
void updateButtons();
|
|
|
|
|
|
|
|
MTPInputStickerSet _set;
|
2016-11-18 13:34:58 +00:00
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
class Inner;
|
2016-12-13 17:07:56 +00:00
|
|
|
QPointer<Inner> _inner;
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This class is hold in header because it requires Qt preprocessing.
|
2016-10-26 16:43:13 +00:00
|
|
|
class StickerSetBox::Inner : public TWidget, public RPCSender, private base::Subscriber {
|
2016-10-20 16:32:15 +00:00
|
|
|
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;
|
2015-07-21 15:35:08 +00:00
|
|
|
bool official() const;
|
2018-06-04 15:35:11 +00:00
|
|
|
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 {
|
2017-09-16 16:53:41 +00:00
|
|
|
return _setInstalled.events();
|
|
|
|
}
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
~Inner();
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2016-09-11 08:38:14 +00:00
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2016-09-11 08:38:14 +00:00
|
|
|
|
|
|
|
private slots:
|
2016-02-17 16:37:21 +00:00
|
|
|
void onPreview();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
signals:
|
|
|
|
void updateButtons();
|
|
|
|
|
|
|
|
private:
|
2016-09-11 08:38:14 +00:00
|
|
|
void updateSelected();
|
2016-12-21 15:05:58 +00:00
|
|
|
void setSelected(int selected);
|
2016-09-11 08:38:14 +00:00
|
|
|
void startOverAnimation(int index, float64 from, float64 to);
|
|
|
|
int stickerFromGlobalPos(const QPoint &p) const;
|
2016-02-17 16:37:21 +00:00
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void gotSet(const MTPmessages_StickerSet &set);
|
|
|
|
bool failedSet(const RPCError &error);
|
|
|
|
|
2016-07-18 15:39:10 +00:00
|
|
|
void installDone(const MTPmessages_StickerSetInstallResult &result);
|
2016-07-14 11:59:55 +00:00
|
|
|
bool installFail(const RPCError &error);
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2016-09-19 10:18:21 +00:00
|
|
|
bool isMasksSet() const {
|
|
|
|
return (_setFlags & MTPDstickerSet::Flag::f_masks);
|
|
|
|
}
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::vector<Animation> _packOvers;
|
2017-11-05 17:07:27 +00:00
|
|
|
Stickers::Pack _pack;
|
|
|
|
Stickers::ByEmojiMap _emoji;
|
2016-06-27 16:25:21 +00:00
|
|
|
bool _loaded = false;
|
|
|
|
uint64 _setId = 0;
|
|
|
|
uint64 _setAccess = 0;
|
2017-05-17 14:32:36 +00:00
|
|
|
QString _setTitle, _setShortName;
|
2018-01-25 12:28:48 +00:00
|
|
|
int _setCount = 0;
|
2016-06-27 16:25:21 +00:00
|
|
|
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;
|
|
|
|
|
2016-06-27 16:25:21 +00:00
|
|
|
mtpRequestId _installRequest = 0;
|
2016-02-17 16:37:21 +00:00
|
|
|
|
2016-09-11 08:38:14 +00:00
|
|
|
int _selected = -1;
|
|
|
|
|
2016-02-17 16:37:21 +00:00
|
|
|
QTimer _previewTimer;
|
2016-09-11 08:38:14 +00:00
|
|
|
int _previewShown = -1;
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
rpl::event_stream<uint64> _setInstalled;
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
};
|