2015-05-19 15:46:45 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2015-05-19 15:46:45 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2017-02-21 13:45:56 +00:00
|
|
|
#include <vector>
|
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;
|
|
|
|
int32 notInstalled() const;
|
2015-07-21 15:35:08 +00:00
|
|
|
bool official() const;
|
2017-05-30 15:21:05 +00:00
|
|
|
base::lambda<TextWithEntities()> title() const;
|
2015-05-19 15:46:45 +00:00
|
|
|
QString shortName() const;
|
|
|
|
|
|
|
|
void install();
|
2017-09-16 16:53:41 +00:00
|
|
|
rpl::producer<uint64> setInstalled() const {
|
|
|
|
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;
|
2015-05-19 15:46:45 +00:00
|
|
|
StickerPack _pack;
|
2016-01-09 12:51:42 +00:00
|
|
|
StickersByEmojiMap _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;
|
2016-06-27 16:25:21 +00:00
|
|
|
int32 _setCount = 0;
|
|
|
|
int32 _setHash = 0;
|
|
|
|
MTPDstickerSet::Flags _setFlags = 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
|
|
|
};
|