2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Click on sticker now opens sticker pack, if the sticker is from pack.

This commit is contained in:
John Preston
2016-04-06 16:02:00 +04:00
parent 259a996276
commit 1947d8e5be
3 changed files with 48 additions and 8 deletions

View File

@@ -5138,6 +5138,33 @@ bool HistoryGif::dataLoaded() const {
return (!_parent || _parent->id > 0) ? _data->loaded() : false;
}
namespace {
class StickerClickHandler : public LeftButtonClickHandler {
public:
StickerClickHandler(const HistoryItem *item) : _item(item) {
}
protected:
void onClickImpl() const override {
if (HistoryMedia *media = _item->getMedia()) {
if (DocumentData *document = media->getDocument()) {
if (StickerData *sticker = document->sticker()) {
if (sticker->set.type() != mtpc_inputStickerSetEmpty && App::main()) {
App::main()->stickersBox(sticker->set);
}
}
}
}
}
private:
const HistoryItem *_item;
};
} // namespace
HistorySticker::HistorySticker(DocumentData *document) : HistoryMedia()
, _pixw(1)
, _pixh(1)
@@ -5150,6 +5177,9 @@ HistorySticker::HistorySticker(DocumentData *document) : HistoryMedia()
}
void HistorySticker::initDimensions(const HistoryItem *parent) {
if (!_packLink && _data->sticker() && _data->sticker()->set.type() != mtpc_inputStickerSetEmpty) {
_packLink = ClickHandlerPtr(new StickerClickHandler(parent));
}
_pixw = _data->dimensions.width();
_pixh = _data->dimensions.height();
if (_pixw > st::maxStickerSize) {
@@ -5262,6 +5292,12 @@ void HistorySticker::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i
state = HistoryInDateCursorState;
}
}
int pixLeft = usex + (usew - _pixw) / 2, pixTop = (_minh - _pixh) / 2;
if (x >= pixLeft && x < pixLeft + _pixw && y >= pixTop && y < pixTop + _pixh) {
lnk = _packLink;
return;
}
}
const QString HistorySticker::inDialogsText() const {