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
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2015-05-19 15:46:45 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-11-16 16:04:25 +00:00
|
|
|
#include "boxes/abstractbox.h"
|
2016-09-26 12:09:59 +00:00
|
|
|
#include "core/vector_of_moveable.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
|
|
|
signals:
|
|
|
|
void installed(uint64 id);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private slots:
|
2016-10-20 16:32:15 +00:00
|
|
|
void onStickersUpdated();
|
|
|
|
void onAddStickers();
|
|
|
|
void onShareStickers();
|
|
|
|
void onUpdateButtons();
|
|
|
|
|
|
|
|
void onInstalled(uint64 id);
|
|
|
|
|
|
|
|
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
|
|
|
QString _title;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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;
|
2015-05-19 15:46:45 +00:00
|
|
|
QString title() const;
|
|
|
|
QString shortName() const;
|
|
|
|
|
2016-09-11 08:38:14 +00:00
|
|
|
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
2015-05-19 15:46:45 +00:00
|
|
|
void install();
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
private slots:
|
2016-02-17 16:37:21 +00:00
|
|
|
void onPreview();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
signals:
|
|
|
|
void updateButtons();
|
|
|
|
void installed(uint64 id);
|
|
|
|
|
|
|
|
private:
|
2016-09-11 08:38:14 +00:00
|
|
|
void updateSelected();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
std_::vector_of_moveable<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;
|
2015-05-19 15:46:45 +00:00
|
|
|
QString _title, _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
|
|
|
|
2016-09-11 08:38:14 +00:00
|
|
|
int _visibleTop = 0;
|
|
|
|
int _visibleBottom = 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;
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
};
|