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
|
|
|
|
|
|
|
|
#include "abstractbox.h"
|
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
class StickerSetInner : public TWidget, public RPCSender {
|
2015-05-19 15:46:45 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StickerSetInner(const MTPInputStickerSet &set);
|
|
|
|
|
2016-02-17 16:37:21 +00:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
2015-05-19 15:46:45 +00:00
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
2016-01-09 12:51:42 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
void setScrollBottom(int32 bottom);
|
|
|
|
void install();
|
|
|
|
|
|
|
|
~StickerSetInner();
|
|
|
|
|
2016-02-17 16:37:21 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onPreview();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void updateButtons();
|
|
|
|
void installed(uint64 id);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-02-17 16:37:21 +00:00
|
|
|
int32 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 MTPBool &result);
|
|
|
|
bool installFailed(const RPCError &error);
|
|
|
|
|
|
|
|
StickerPack _pack;
|
2016-01-09 12:51:42 +00:00
|
|
|
StickersByEmojiMap _emoji;
|
2015-05-19 15:46:45 +00:00
|
|
|
bool _loaded;
|
|
|
|
uint64 _setId, _setAccess;
|
|
|
|
QString _title, _setTitle, _setShortName;
|
2015-06-28 12:37:10 +00:00
|
|
|
int32 _setCount, _setHash, _setFlags;
|
2015-05-19 15:46:45 +00:00
|
|
|
|
|
|
|
int32 _bottom;
|
|
|
|
MTPInputStickerSet _input;
|
|
|
|
|
|
|
|
mtpRequestId _installRequest;
|
2016-02-17 16:37:21 +00:00
|
|
|
|
|
|
|
QTimer _previewTimer;
|
|
|
|
int32 _previewShown;
|
2015-05-19 15:46:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class StickerSetBox : public ScrollableBox, public RPCSender {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StickerSetBox(const MTPInputStickerSet &set);
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onStickersUpdated();
|
|
|
|
void onAddStickers();
|
|
|
|
void onShareStickers();
|
|
|
|
void onUpdateButtons();
|
|
|
|
|
|
|
|
void onScroll();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void installed(uint64 id);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void hideAll();
|
|
|
|
void showAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
StickerSetInner _inner;
|
2015-10-11 08:37:24 +00:00
|
|
|
ScrollableBoxShadow _shadow;
|
2015-10-12 21:02:10 +00:00
|
|
|
BoxButton _add, _share, _cancel, _done;
|
2015-10-11 08:37:24 +00:00
|
|
|
QString _title;
|
2015-05-19 15:46:45 +00:00
|
|
|
};
|
2015-12-02 17:17:53 +00:00
|
|
|
|
|
|
|
class StickersInner : public TWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StickersInner();
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
2016-01-09 12:51:42 +00:00
|
|
|
|
2015-12-02 17:17:53 +00:00
|
|
|
void rebuild();
|
|
|
|
bool savingStart() {
|
|
|
|
if (_saving) return false;
|
|
|
|
_saving = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<uint64> getOrder() const;
|
|
|
|
QVector<uint64> getDisabledSets() const;
|
|
|
|
|
|
|
|
void setVisibleScrollbar(int32 width);
|
|
|
|
|
|
|
|
~StickersInner();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void checkDraggingScroll(int localY);
|
|
|
|
void noDraggingScroll();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onUpdateSelected();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_shifting(uint64 ms, bool timer);
|
2015-12-02 17:17:53 +00:00
|
|
|
void paintRow(Painter &p, int32 index);
|
|
|
|
void clear();
|
|
|
|
void setRemoveSel(int32 removeSel);
|
|
|
|
float64 aboveShadowOpacity() const;
|
|
|
|
|
|
|
|
int32 _rowHeight;
|
|
|
|
struct StickerSetRow {
|
2015-12-06 15:50:02 +00:00
|
|
|
StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool official, bool disabled, int32 pixw, int32 pixh) : id(id)
|
2015-12-02 17:17:53 +00:00
|
|
|
, sticker(sticker)
|
|
|
|
, count(count)
|
|
|
|
, title(title)
|
2015-12-06 15:50:02 +00:00
|
|
|
, official(official)
|
2015-12-02 17:17:53 +00:00
|
|
|
, disabled(disabled)
|
|
|
|
, pixw(pixw)
|
|
|
|
, pixh(pixh)
|
|
|
|
, yadd(0, 0) {
|
|
|
|
}
|
|
|
|
uint64 id;
|
|
|
|
DocumentData *sticker;
|
|
|
|
int32 count;
|
|
|
|
QString title;
|
2015-12-06 15:50:02 +00:00
|
|
|
bool official, disabled;
|
2015-12-02 17:17:53 +00:00
|
|
|
int32 pixw, pixh;
|
2015-12-05 12:37:08 +00:00
|
|
|
anim::ivalue yadd;
|
2015-12-02 17:17:53 +00:00
|
|
|
};
|
|
|
|
typedef QList<StickerSetRow*> StickerSetRows;
|
|
|
|
StickerSetRows _rows;
|
|
|
|
QList<uint64> _animStartTimes;
|
|
|
|
uint64 _aboveShadowFadeStart;
|
|
|
|
anim::fvalue _aboveShadowFadeOpacity;
|
|
|
|
Animation _a_shifting;
|
|
|
|
|
2015-12-06 15:50:02 +00:00
|
|
|
int32 _itemsTop;
|
|
|
|
|
2015-12-02 17:17:53 +00:00
|
|
|
bool _saving;
|
|
|
|
|
2015-12-06 15:50:02 +00:00
|
|
|
int32 _removeSel, _removeDown, _removeWidth, _returnWidth, _restoreWidth;
|
2015-12-02 17:17:53 +00:00
|
|
|
|
|
|
|
QPoint _mouse;
|
|
|
|
int32 _selected;
|
|
|
|
QPoint _dragStart;
|
|
|
|
int32 _started, _dragging, _above;
|
|
|
|
|
|
|
|
BoxShadow _aboveShadow;
|
|
|
|
|
|
|
|
int32 _scrollbar;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StickersBox : public ItemListBox, public RPCSender {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StickersBox();
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
2016-01-09 12:51:42 +00:00
|
|
|
|
2015-12-02 17:17:53 +00:00
|
|
|
void closePressed();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onStickersUpdated();
|
|
|
|
|
|
|
|
void onCheckDraggingScroll(int localY);
|
|
|
|
void onNoDraggingScroll();
|
|
|
|
void onScrollTimer();
|
|
|
|
|
|
|
|
void onSave();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void hideAll();
|
|
|
|
void showAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
int32 countHeight() const;
|
|
|
|
|
|
|
|
void disenableDone(const MTPBool &result, mtpRequestId req);
|
|
|
|
bool disenableFail(const RPCError &error, mtpRequestId req);
|
|
|
|
void reorderDone(const MTPBool &result);
|
|
|
|
bool reorderFail(const RPCError &result);
|
|
|
|
void saveOrder();
|
|
|
|
|
|
|
|
StickersInner _inner;
|
|
|
|
BoxButton _save, _cancel;
|
|
|
|
QMap<mtpRequestId, NullType> _disenableRequests;
|
|
|
|
mtpRequestId _reorderRequest;
|
2015-12-06 15:50:02 +00:00
|
|
|
PlainShadow _topShadow;
|
2015-12-02 17:17:53 +00:00
|
|
|
ScrollableBoxShadow _bottomShadow;
|
|
|
|
|
|
|
|
QTimer _scrollTimer;
|
|
|
|
int32 _scrollDelta;
|
|
|
|
|
2015-12-06 15:50:02 +00:00
|
|
|
int32 _aboutWidth;
|
|
|
|
Text _about;
|
|
|
|
int32 _aboutHeight;
|
|
|
|
|
2015-12-02 17:17:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int32 stickerPacksCount(bool includeDisabledOfficial = false);
|