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